使用Percona源安装Percona Server MySQL和TokuDB数据库引擎

  1. 添加Percona官方源,详情参照官方安装文档
yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
percona-release setup ps80
yum install percona-server-server

2.运行和测试percona mysql

service mysql start
service mysql status
service mysql restart
service mysql stop

3.获取随机root密码,如无法出现可以重启数据库

 grep "A temporary password" /var/log/mysqld.log

4.初始化数据库,修改默认密码,注意8.0默认有强制密码强度要求。

mysql_secure_installation
mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
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) :

 ... skipping.
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!

5. 解决phpMyadmin因加密认证不一样导致无法连接的问题

mysql -p
Enter password:
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '你的密码';
Query OK, 0 rows affected (0.26 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

6.编辑/etc/my.cnf配置文件,修改mysql默认编码

vim /etc/my.cnf

末尾加上

[mysqld] 
character_set_server=utf8

7.安装jemalloc,记下/usr/lib64/libjemalloc.so.1路径

yum install jemalloc 
rpm -qa |grep jemalloc 
jemalloc-3.6.0-3.el7.x86_64
jemalloc-devel-3.6.0-3.el7.x86_64
rpm -ql jemalloc-3.6.0-3.el7.x86_64
/usr/bin/jemalloc.sh
/usr/lib64/libjemalloc.so.1
/usr/share/doc/jemalloc-3.6.0
/usr/share/doc/jemalloc-3.6.0/COPYING
/usr/share/doc/jemalloc-3.6.0/README
/usr/share/doc/jemalloc-3.6.0/VERSION
/usr/share/doc/jemalloc-3.6.0/jemalloc.html

8.emalloc依赖文件,编辑/etc/my.cnf,末尾加入以下:

[mysqld_safe] 
malloc-lib=/usr/lib64/libjemalloc.so.1

10.检查Transparent huge pages,安装ToukuDB引擎

echo never > /sys/kernel/mm/transparent_hugepage/enabled 
echo never > /sys/kernel/mm/transparent_hugepage/defrag
yum install percona-server-tokudb
service mysql restart

11.修改selinux状态为permissive,编辑编辑/etc/selinux/config修改以下内容:

selinux=permissive

生效

setenforce 0

12.初始设置tokudb

ps-admin --enable-tokudb -uroot -p
service mysql restart

13.检查确认是否启用tokudb

mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19-10 Percona Server (GPL), Release 10, Revision f446c04

Copyright (c) 2009-2020 Percona LLC and/or its affiliates
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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> show engines;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                                    | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| TokuDB             | YES     | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology             | YES          | YES  | YES        |
| FEDERATED          | NO      | Federated MySQL storage engine                                             | NULL         | NULL | NULL       |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                                         | NO           | NO   | NO         |
| TokuDB             | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables                  | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                                      | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                                      | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears)             | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                                         | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                                     | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)

mysql> 

看到TokuDB | YES 字样即为成功安装。

14.设置默认引擎为TokuDB,修改/etc/my.cnf文件[mysqld] 下面加入以下,并重启mysql服务器

default-storage-engine=TOKUDB
service mysql restart

至此,我们完成了Percona Mysql的按照,并设置完成TOKUDB为默认数据库引擎。下一步我们进行phpmyadmin的安装

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注