安装mysql分支percona及其配置

安装percona

安装rpm

$ yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm

安装percona

$ yum list | grep percona
$ yum install Percona-Server-server-57

启动服务

$ systemctl restart mysql.service

开机自启

$ chkconfig mysqld on

初始化mysql

注意:Percona 5.7安装完默认会产生个随机的密码,存在日志中。这个问题找了一下午,MMP 😂 😂 😂

查看密码

cat /var/log/mysqld.log  | grep "A temporary password" | awk -F " " '{print$11}'

注意,一定要先启动mysql服务才能初始化

$ mysql_secure_installation
Securing the MySQL server deployment.

Enter password for user root:
Error: Access denied for user 'root'@'localhost' (using password: YES)
[root@iZm5eftzomp390c3clkathZ ~]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password:
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

修改配置文件

  • mysql 配置文件目录 /etc/my.cnf
  • percona 的配置文件目录 /etc/percona-server.conf.d/

这里我们需要把/etc/my.cnf修改为,这里只需要引入进来即可

!includedir /etc/my.cnf.d/
!includedir /etc/percona-server.conf.d/

新建mysql用户或者www运行mysqld,不建议用root运行

mkdir -p /var/log/mysqld
chown mysql.mysql /var/log/mysqld -R

慢日志

安装xtrabackup