Percona Server
跳至導覽
跳至搜尋
Percona Server是一套由Percona維護的資料庫軟體,源自MySQL。
安裝
MySQL系的資料庫在使用jemalloc時效能都會提昇不少,所以在不少衍生版本都有支援jemalloc。其中Percona Server在偵測到系統內有jemalloc時會自動啟用[1],減少了設定所需的手續。
在Ubuntu上先安裝gnupg2
,等下會用到:
sudo apt install -y gnupg2; sudo apt clean
首先安裝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; sudo apt clean
或是Percona Server 8.0:
sudo percona-release setup ps80; sudo apt install -y libjemalloc2 percona-server-server; sudo apt clean
另外可以加裝mycli:
sudo apt install -y mycli; sudo apt clean
設定
先停掉telemetry:
sudo systemctl disable --now percona-telemetry-agent
在第一次設定前先停掉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 mycli percona-server-server-5.7; sudo apt clean; sudo systemctl disable --now percona-telemetry-agent; 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 libjemalloc2 mycli percona-server-server; sudo apt clean; sudo systemctl disable --now percona-telemetry-agent; 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
相關連結
參考資料
- ↑ Enabling and Disabling Jemalloc on Percona Server. 2017-01-03 [2018-04-23].
外部連結
- 官方網站 (英文)