Percona Server

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索

Percona Server是一套数据库软件,源自MySQL

安装

MySQL系的数据库在使用jemalloc时效能都会提升不少,所以在不少衍生版本都有支援jemalloc。其中Percona Server在侦测到系统内有jemalloc时会自动启用[1],减少了设定所需的手续。

Ubuntu上先安装gnupg2,等下会用到:

sudo apt install -y gnupg2

首先安装Percona的APT设定,以及对应所需的Key:

cd /tmp; wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; sudo dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb

装完后可以更新系统并且安装Percona Server 5.7与libjemalloc1

sudo apt update; sudo apt install -y libjemalloc1 percona-server-server-5.7

或是Percona Server 8.0:

sudo percona-release setup ps80; sudo apt install -y libjemalloc1 percona-server-server

设定

在第一次设定前先停掉Percona Server:

sudo service mysql stop

接着到/etc/mysql/percona-server.conf.d/下将本来的设定档改名,然后可以参考mysql-5.7.cnf这边的设定档:

cd /etc/mysql/percona-server.conf.d/; sudo mv mysqld.cnf mysqld.cnf.bak; sudo wget -O mysqld.cnf https://raw.githubusercontent.com/gslin/mysql-template/master/mysql-5.7.cnf; sudo mkdir /srv/tmp; sudo chmod 1777 /srv/tmp

Percona Server 8.0版本的则是,可以参考mysql-8.0.cnf这边的设定档:

cd /etc/mysql/mysql.conf.d/; sudo mv mysqld.cnf mysqld.cnf.bak; sudo wget -O mysqld.cnf https://raw.githubusercontent.com/gslin/mysql-template/master/mysql-8.0.cnf; sudo mkdir /srv/tmp; sudo chmod 1777 /srv/tmp

其中最主要的值是innodb_buffer_pool_size,表示InnoDB在内存内占用的空间(这边设定值不包括overhead,所以实际使用的量通常会超过所设定的值)。当整台机器都是专门给Percona Server使用时,会设定整台服务器内存的60%到75%。如果不是专门使用时可以看资料量与特性决定:

innodb_buffer_pool_size = 64M

设完后就可以启动:

sudo service mysql start

快速安装

把上面提到的指令一次跑完:

sudo apt install -y gnupg2; cd /tmp; wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; sudo dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb; sudo apt update; sudo apt install -y libjemalloc1 percona-server-server-5.7; sudo service mysql stop; cd /etc/mysql/percona-server.conf.d/; sudo mv mysqld.cnf mysqld.cnf.bak; sudo wget -O mysqld.cnf https://raw.githubusercontent.com/gslin/mysql-template/master/mysql-5.7.cnf; sudo mkdir /srv/tmp; sudo chmod 1777 /srv/tmp; sudo service mysql start

Percona Server 8.0版本的则是:

sudo apt install -y gnupg2; cd /tmp; wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; sudo dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb; sudo percona-release setup ps80; sudo apt install -y libjemalloc1 percona-server-server; sudo service mysql stop; cd /etc/mysql/mysql.conf.d/; sudo mv mysqld.cnf mysqld.cnf.bak; sudo wget -O mysqld.cnf https://raw.githubusercontent.com/gslin/mysql-template/master/mysql-8.0.cnf; sudo mkdir /srv/tmp; sudo chmod 1777 /srv/tmp; sudo service mysql start

相关连结

参考资料

外部链接