简介

Percona Server由领先的MySQL咨询公司Percona发布。Percona Server是一款独立的数据库产品,其可以完全与MySQL兼容,可以在不更改代码的情况了下将存储引擎更换成XtraDB 。

Percona团队的最终声明是“Percona Server是由Oracle发布的最接近官方MySQL Enterprise发行版的版本”,因此与其他更改了大量基本核心MySQL代码的分支有所区别。Percona Server的一个缺点是他们自己管理代码,不接受外部开发人员的贡献,以这种方式确保他们对产品中所包含功能的控制。

官网地址:http://www.percona.com/

CentOS系统

环境配置

  • 规格:4C8G,100G数据盘
  • 系统:CentOS Linux release 7.9.2009 (Core)
  • MySQL版本:Percona Server 5.7.35-38

安装流程

  1. 下载地址:

  2. Linux基础配置

1
2
3
4
5
6
7
8
9
# 关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config
setenforce 0

# 安装Percona Server依赖的软件包
yum install -y perl libaio openssl-devel

# 卸载Percona Server冲突的软件包
yum remove -y mariadb-libs
  1. 安装Percona Server
1
2
3
4
5
6
7
8
9
10
# 解压安装包
tar xvf Percona-Server-5.7.35-38-r3692a61-el7-x86_64-bundle.tar

# rpm包安装
rpm -ivh \
Percona-Server-client-57-5.7.35-38.1.el7.x86_64.rpm \
Percona-Server-server-57-5.7.35-38.1.el7.x86_64.rpm \
Percona-Server-shared-57-5.7.35-38.1.el7.x86_64.rpm \
Percona-Server-shared-compat-57-5.7.35-38.1.el7.x86_64.rpm \
Percona-Server-devel-57-5.7.35-38.1.el7.x86_64.rpm
  1. 配置Percona Server,MySQL配置文件目录:/etc/percona-server.conf.d/mysqld.cnf,文件内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Percona Server template configuration

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

# Database files location
datadir=/var/lib/mysql
log-error=/var/log/mysqld.log
socket=/var/lib/mysql/mysql.sock
pid-file=/var/run/mysqld/mysqld.pid

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Innodb Storage Engine
innodb_buffer_pool_size=3G
innodb_change_buffer_max_size=50
innodb_undo_log_truncate=ON
innodb_open_files=20000
innodb_io_capacity=12000
innodb_io_capacity_max=24000
innodb_doublewrite=ON
innodb_file_per_table=1
innodb_log_files_in_group=2
innodb_log_file_size=512M
innodb_log_buffer_size=64M
innodb_sort_buffer_size=16M
innodb_sync_spin_loops=180
innodb_spin_wait_delay=2

# Buffer
join_buffer_size=32M
key_buffer_size=16M
preload_buffer_size=1M
read_buffer_size=1M
read_rnd_buffer_size=16M
sort_buffer_size=16M
binlog_cache_size=1M
bulk_insert_buffer_size=16M
thread_cache_size=64
table_open_cache_instances=64

# Connections
max_connections=2000
max_user_connections=1800
max_connect_errors=2000
open_files_limit=20000
table_open_cache=20000
table_definition_cache=20000

# Plugins
plugin-load-add=validate_password.so

# System Variables
performance_schema=OFF
validate_password_policy=0
skip_name_resolve
  1. 启动数据库
1
systemctl start mysqld
  1. 修改root密码
1
2
3
4
5
6
# 查看初始化密码
[root@localhost log]# cat /var/log/mysqld.log | grep 'temporary password'
2021-07-27T07:56:26.750789Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: t-:33aMYyaC+

# 更改root密码
[root@localhost log]# mysqladmin -uroot -p't-:33aMYyaC+' password Inspur@123
  1. 放通root远程登录
1
2
3
4
5
6
7
8
9
10
# 允许用户远程登录(mysql 8.x)
UPDATE mysql.user SET host = '%' WHERE user = 'root';
# PS:需退出重连
ALTER USER 'root'@'%' IDENTIFIED BY 'inspur@123' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'inspur@123';

# 允许用户远程登录(mysql 5.7)
grant all privileges on *.* to 'root'@'%' identified by 'Inspur@123';
update mysql.user set Grant_priv='Y' where User='root' and Host='%'; # Percona赋予所有权限不包含Grant权限
flush privileges;

登录数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@mysql-5 ~]# mysql -uroot -pInspur@123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 205
Server version: 5.7.35-38 Percona Server (GPL), Release 38, Revision 3692a61

Copyright (c) 2009-2021 Percona LLC and/or its affiliates
Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Ubuntu系统

环境配置

  • 规格:4C8G,100G数据盘
  • 系统:Ubuntu 16.04.7 LTS
  • MySQL版本:Percona Server 5.7.35-38

安装流程

  1. Install GnuPG, the GNU Privacy Guard:

    1
    $ sudo apt install gnupg2
  2. Fetch the repository packages from Percona web:

    1
    $ wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb
  3. Install the downloaded package with dpkg. To do that, run the following commands as root or with sudo:

    1
    $ sudo dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb
  4. Remember to update the local cache:

    1
    $ sudo apt update

    Once you install this package the Percona repositories should be added. You can check the repository setup in the /etc/apt/sources.list.d/percona-release.list file.

  5. After that you can install the server package:

    1
    $ sudo apt install percona-server-server-5.7

Note

Percona Server for MySQL 5.7 comes with the TokuDB storage engine and MyRocks storage engine. These storage engines are installed as plugin.

For information on how to install and configure TokuDB, refer to the TokuDB Installation guide.

For information on how to install and configure MyRocks, refer to the Percona MyRocks Installation Guide guide.

The Percona Server for MySQL distribution contains several useful User Defined Functions (UDF) from Percona Toolkit. After the installation completes, run the following commands to create these functions:

1
2
3
mysql -e "CREATE FUNCTION fnvla_64 RETURNS INTEGER SONAME 'libfnvla_udf.so'"
mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'"
mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'"

For more details on the UDFs, see Percona Toolkit UDFS.

参考文档