版权声明:本文为博主原创文章,未经博主允许不得转载。
http://blog.csdn.net/tanliqing2010/article/details/78758878
0 前言
percona是mysql的一个分支,基本功能月mysql相同.但是percona是完全开源的,mysql被甲骨文收购了.
1 percona的安装
我是在centos7中 arm64位操作系统
1. 查找percona安装包
[root@localhost ~]# yum search percona
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* epel: mirrors.ustc.edu.cn
594 packages excluded due to repository priority protections
==================================================================== N/S matched: percona ====================================================================
Percona-Server-56-debuginfo.aarch64 : Debug information for package Percona-Server-56
Percona-Server-57-debuginfo.aarch64 : Debug information for package Percona-Server-57
Percona-Server-client-56.aarch64 : Percona Server - Client
Percona-Server-client-57.aarch64 : Percona Server - Client
Percona-Server-devel-56.aarch64 : Percona Server - Development header files and libraries
Percona-Server-devel-57.aarch64 : Percona Server - Development header files and libraries
Percona-Server-selinux-56.noarch : Percona Server - Selinux policy module
Percona-Server-server-56.aarch64 : Percona Server: a very fast and reliable SQL database server
Percona-Server-server-57.aarch64 : Percona Server: a very fast and reliable SQL database server
Percona-Server-shared-56.aarch64 : Percona Server - Shared libraries
Percona-Server-shared-57.aarch64 : Percona Server - Shared libraries
Percona-Server-shared-compat-57.aarch64 : Shared compat libraries for Percona Server 5.6.35--81.0 database client applications
Percona-Server-test-56.aarch64 : Percona Server - Test suite
Percona-Server-test-57.aarch64 : Test suite for the Percona Server
percona-toolkit-debuginfo.aarch64 : Debug information for package percona-toolkit
percona-xtrabackup.aarch64 : Online backup for InnoDB/XtraDB in MySQL, Percona Server and MariaDB
percona-xtrabackup-test.aarch64 : Test suite for Percona Xtrabackup
holland-xtrabackup.noarch : Holland plugin for Percona XtraBackup
percona-toolkit.aarch64 : Advanced MySQL and system command-line tools
Name and summary matches only, use "search all" for everything.
[root@localhost ~]#
2. 在centos7中直接使用yum源安装
yum install -y Percona-Server-server-56
3. 查看安装的位置
[root@localhost ~]# rpm -ql Percona-Server-server-56
/etc/logrotate.d/mysql
/usr/bin/innochecksum
/usr/bin/my_print_defaults
/usr/bin/myisam_ftdump
/usr/bin/myisamchk
/usr/bin/myisamlog
/usr/bin/myisampack
/usr/bin/mysql-systemd
/usr/bin/mysql_convert_table_format
/usr/bin/mysql_fix_extensions
/usr/bin/mysql_install_db
/usr/bin/mysql_plugin
/usr/bin/mysql_secure_installation
/usr/bin/mysql_setpermission
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysql_upgrade
/usr/bin/mysql_zap
/usr/bin/mysqlbug
/usr/bin/mysqld_multi
/usr/bin/mysqld_safe
/usr/bin/mysqldumpslow
/usr/bin/mysqlhotcopy
/usr/bin/mysqltest
/usr/bin/perror
/usr/bin/replace
/usr/bin/resolve_stack_dump
/usr/bin/resolveip
/usr/lib/systemd/system/mysqld.service
/usr/lib/tmpfiles.d/mysql.conf
/usr/lib64/mysql/plugin/adt_null.so
/usr/lib64/mysql/plugin/audit_log.so
....
/response_time.so
/usr/lib64/mysql/plugin/debug/scalability_metrics.so
/usr/lib64/mysql/plugin/debug/semisync_master.so
/usr/lib64/mysql/plugin/debug/semisync_slave.so
/usr/lib64/mysql/plugin/debug/test_udf_services.so
/usr/lib64/mysql/plugin/debug/validate_password.so
/usr/lib64/mysql/plugin/dialog.so
/usr/lib64/mysql/plugin/handlersocket.so
/usr/lib64/mysql/plugin/innodb_engine.so
/usr/lib64/mysql/plugin/libdaemon_example.so
/usr/lib64/mysql/plugin/libfnv1a_udf.so
/usr/lib64/mysql/plugin/libfnv_udf.so
/usr/lib64/mysql/plugin/libmemcached.so
/usr/lib64/mysql/plugin/libmurmur_udf.so
/usr/lib64/mysql/plugin/mypluglib.so
/usr/lib64/mysql/plugin/mysql_no_login.so
/usr/lib64/mysql/plugin/qa_auth_client.so
/usr/lib64/mysql/plugin/qa_auth_interface.so
/usr/lib64/mysql/plugin/qa_auth_server.so
/usr/lib64/mysql/plugin/query_response_time.so
/usr/lib64/mysql/plugin/scalability_metrics.so
/usr/lib64/mysql/plugin/semisync_master.so
/usr/lib64/mysql/plugin/semisync_slave.so
/usr/lib64/mysql/plugin/test_udf_services.so
/usr/lib64/mysql/plugin/validate_password.so
/usr/sbin/mysqld
/usr/sbin/mysqld-debug
/usr/sbin/rcmysql
/usr/share/doc/Percona-Server-server-56-5.6.35
/usr/share/doc/Percona-Server-server-56-5.6.35/COPYING
/usr/share/doc/Percona-Server-server-56-5.6.35/INFO_BIN
/usr/share/doc/Percona-Server-server-56-5.6.35/INFO_SRC
/usr/share/doc/Percona-Server-server-56-5.6.35/README
/usr/share/doc/Percona-Server-server-56-5.6.35/my-default.cnf
/usr/share/info/mysql.info.gz
/usr/share/man/man1/innochecksum.1.gz
...
/usr/share/man/man1/mysqlman.1.gz
/usr/share/man/man1/mysqltest.1.gz
/usr/share/man/man1/perror.1.gz
/usr/share/man/man1/replace.1.gz
/usr/share/man/man1/resolve_stack_dump.1.gz
/usr/share/man/man1/resolveip.1.gz
/usr/share/man/man8/mysqld.8.gz
/usr/share/percona-server/SELinux
/usr/share/percona-server/SELinux/RHEL4
/usr/share/percona-server/SELinux/RHEL4/mysql.fc
/usr/share/percona-server/SELinux/RHEL4/mysql.te
/usr/share/percona-server/binary-configure
/usr/share/percona-server/bulgarian
/usr/share/percona-server/bulgarian/errmsg.sys
/usr/share/percona-server/charsets
/usr/share/percona-server/charsets/Index.xml
/usr/share/percona-server/charsets/README
/usr/share/percona-server/charsets/armscii8.xml
/usr/share/percona-server/charsets/ascii.xml
/usr/share/percona-server/charsets/cp1250.xml
/usr/share/percona-server/charsets/cp1251.xml
/usr/share/percona-server/charsets/cp1256.xml
/usr/share/percona-server/charsets/cp1257.xml
/usr/share/percona-server/charsets/cp850.xml
/usr/share/percona-server/charsets/cp852.xml
/usr/share/percona-server/charsets/cp866.xml
/usr/share/percona-server/charsets/dec8.xml
/usr/share/percona-server/charsets/geostd8.xml
/usr/share/percona-server/charsets/greek.xml
/usr/share/percona-server/charsets/hebrew.xml
/usr/share/percona-server/charsets/hp8.xml
...
/usr/share/percona-server/french/errmsg.sys
/usr/share/percona-server/german
/usr/share/percona-server/german/errmsg.sys
/usr/share/percona-server/greek
/usr/share/percona-server/greek/errmsg.sys
/usr/share/percona-server/hungarian
/usr/share/percona-server/hungarian/errmsg.sys
/usr/share/percona-server/innodb_memcached_config.sql
/usr/share/percona-server/italian
/usr/share/percona-server/italian/errmsg.sys
/usr/share/percona-server/japanese
/usr/share/percona-server/japanese/errmsg.sys
/usr/share/percona-server/korean
/usr/share/percona-server/korean/errmsg.sys
/usr/share/percona-server/magic
/usr/share/percona-server/my-default.cnf
/usr/share/percona-server/mysql-log-rotate
/usr/share/percona-server/mysql.server
/usr/share/percona-server/mysql_security_commands.sql
/usr/share/percona-server/mysql_system_tables.sql
/usr/share/percona-server/mysql_system_tables_data.sql
/usr/share/percona-server/mysql_test_data_timezone.sql
/usr/share/percona-server/mysqld_multi.server
/usr/share/percona-server/norwegian
...
/usr/share/percona-server/swedish/errmsg.sys
/usr/share/percona-server/ukrainian
/usr/share/percona-server/ukrainian/errmsg.sys
/var/lib/mysql-files
[root@localhost ~]#
2. 查看几个很重要的信息
1. 会自动创建一个`mysql`的用户
2. 在`/var/lib/mysql`目录下创建如下系统文件
[root@localhost ~]# ll /var/lib/mysql
total 110608
-rw-rw----. 1 mysql mysql 12582912 12月 9 15:17 ibdata1
-rw-rw----. 1 mysql mysql 50331648 12月 9 15:17 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 12月 9 15:17 ib_logfile1
drwx------. 2 mysql mysql 4096 12月 9 15:17 mysql
drwx------. 2 mysql mysql 4096 12月 9 15:17 performance_schema
-rw-r--r--. 1 root root 138 12月 9 15:17 RPM_UPGRADE_HISTORY
-rw-r--r--. 1 mysql mysql 138 12月 9 15:17 RPM_UPGRADE_MARKER-LAST
drwx------. 2 mysql mysql 6 12月 9 15:17 test
2 默认方式启动停止percona
1. 启动percona
[root@localhost ~]# systemctl start mysqld.service
[root@localhost ~]# systemctl status mysqld
● mysqld.service - MySQL Percona Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2017-12-09 13:38:43 CST; 47s ago
Process: 55110 ExecStartPost=/usr/bin/mysql-systemd post (code=exited, status=0/SUCCESS)
Process: 55080 ExecStartPre=/usr/bin/mysql-systemd pre (code=exited, status=0/SUCCESS)
Main PID: 55109 (mysqld_safe)
Memory: 539.4M
CGroup: /system.slice/mysqld.service
├─55109 /bin/sh /usr/bin/mysqld_safe
└─55266 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.l...
12月 09 13:38:41 localhost.localdomain systemd[1]: Starting MySQL Percona Server...
12月 09 13:38:42 localhost.localdomain mysqld_safe[55109]: 171209 13:38:42 mysqld_safe Adding '/usr/lib64/libjemalloc.so.1' to LD_PRELOAD for mysqld
12月 09 13:38:42 localhost.localdomain mysqld_safe[55109]: 171209 13:38:42 mysqld_safe Logging to '/var/log/mysqld.log'.
12月 09 13:38:42 localhost.localdomain mysqld_safe[55109]: 171209 13:38:42 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
12月 09 13:38:43 localhost.localdomain systemd[1]: Started MySQL Percona Server.
[root@localhost ~]#
2. 运行percona客户端连接到percona服务端
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.35-81.0 Percona Server (GPL), Release 81.0, Revision c96c427
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| alterdb |
| employees |
| my1 |
| mysql |
| performance_schema |
+--------------------+
6 rows in set (0.00 sec)
mysql> exit
3. 停止perocona服务
[root@localhost ~]# systemctl stop mysqld.service
[root@localhost ~]# systemctl status mysqld
● mysqld.service - MySQL Percona Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead) since 六 2017-12-09 13:44:00 CST; 12s ago
Process: 55110 ExecStartPost=/usr/bin/mysql-systemd post (code=exited, status=0/SUCCESS)
Process: 55109 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
Process: 55080 ExecStartPre=/usr/bin/mysql-systemd pre (code=exited, status=0/SUCCESS)
Main PID: 55109 (code=exited, status=0/SUCCESS)
12月 09 13:38:41 localhost.localdomain systemd[1]: Starting MySQL Percona Server...
12月 09 13:38:42 localhost.localdomain mysqld_safe[55109]: 171209 13:38:42 mysqld_safe Adding '/usr/lib64/libjemalloc.so.1' to LD_PRELOAD for mysqld
12月 09 13:38:42 localhost.localdomain mysqld_safe[55109]: 171209 13:38:42 mysqld_safe Logging to '/var/log/mysqld.log'.
12月 09 13:38:42 localhost.localdomain mysqld_safe[55109]: 171209 13:38:42 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
12月 09 13:38:43 localhost.localdomain systemd[1]: Started MySQL Percona Server.
12月 09 13:43:58 localhost.localdomain systemd[1]: Stopping MySQL Percona Server...
12月 09 13:44:00 localhost.localdomain mysqld_safe[55109]: 171209 13:44:00 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
12月 09 13:44:00 localhost.localdomain systemd[1]: Stopped MySQL Percona Server.
[root@localhost ~]#
3 使用mysqld_safe启动percona
0. 我们来看看默认的配置文件
1. 默认mysql的数据目录是`/var/lib/mysql`.如果该目录不存在,那么需要自己去创建
2. 权限全部都是mysql:mysql.这是特别重要的一点
[root@localhost ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@localhost ~]#
1.初始化数据目录
rm -rf /var/lib/mysql
mysql_install_db --defaults-file=/etc/my.cnf
[root@localhost percona]# mysql_install_db --defaults-file=/etc/my.cnf
Installing MySQL system tables...2017-12-09 14:29:34 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-12-09 14:29:34 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-12-09 14:29:34 0 [Note] /usr/sbin/mysqld (mysqld 5.6.35-81.0) starting as process 55987 ...
2017-12-09 14:29:34 55987 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-09 14:29:34 55987 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-09 14:29:34 55987 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-09 14:29:34 55987 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-12-09 14:29:34 55987 [Note] InnoDB: Compressed tables use zlib 1.2.7
2017-12-09 14:29:34 55987 [Note] InnoDB: Using Linux native AIO
2017-12-09 14:29:34 55987 [Note] InnoDB: Not using CPU crc32 instructions
2017-12-09 14:29:34 55987 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-12-09 14:29:34 55987 [Note] InnoDB: Completed initialization of buffer pool
2017-12-09 14:29:34 55987 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-09 14:29:34 55987 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-09 14:29:34 55987 [Note] InnoDB: Waiting for purge to start
2017-12-09 14:29:34 55987 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.35-81.0 started; log sequence number 1606610
2017-12-09 14:29:34 55987 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2017-12-09 14:29:34 55987 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2017-12-09 14:29:34 55987 [Note] Binlog end
2017-12-09 14:29:34 55987 [Note] InnoDB: FTS optimize thread exiting.
2017-12-09 14:29:34 55987 [Note] InnoDB: Starting shutdown...
2017-12-09 14:29:35 55987 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2017-12-09 14:29:37 55987 [Note] InnoDB: Shutdown completed; log sequence number 1631274
OK
Filling help tables...2017-12-09 14:29:37 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-12-09 14:29:37 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-12-09 14:29:37 0 [Note] /usr/sbin/mysqld (mysqld 5.6.35-81.0) starting as process 56012 ...
2017-12-09 14:29:37 56012 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-09 14:29:37 56012 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-09 14:29:37 56012 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-09 14:29:37 56012 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-12-09 14:29:37 56012 [Note] InnoDB: Compressed tables use zlib 1.2.7
2017-12-09 14:29:37 56012 [Note] InnoDB: Using Linux native AIO
2017-12-09 14:29:37 56012 [Note] InnoDB: Not using CPU crc32 instructions
2017-12-09 14:29:37 56012 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-12-09 14:29:37 56012 [Note] InnoDB: Completed initialization of buffer pool
2017-12-09 14:29:37 56012 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-09 14:29:37 56012 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-09 14:29:37 56012 [Note] InnoDB: Waiting for purge to start
2017-12-09 14:29:37 56012 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.35-81.0 started; log sequence number 1631274
2017-12-09 14:29:37 56012 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2017-12-09 14:29:37 56012 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2017-12-09 14:29:37 56012 [Note] Binlog end
2017-12-09 14:29:37 56012 [Note] InnoDB: FTS optimize thread exiting.
2017-12-09 14:29:37 56012 [Note] InnoDB: Starting shutdown...
2017-12-09 14:29:38 56012 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2017-12-09 14:29:39 56012 [Note] InnoDB: Shutdown completed; log sequence number 1631284
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at
https://bugs.launchpad.net/percona-server/+filebug
The latest information about Percona Server is available on the web at
http://www.percona.com/software/percona-server
Support Percona by buying support at
http://www.percona.com/products/mysql-support
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
2. 启动percona服务
### 这里也咩有使用`--defaults-file=/etc/my.cnf`,是因为默认使用该配置文件
[root@localhost ~]# mysqld_safe --user=mysql &
[1] 8623
[root@localhost ~]# 171209 15:33:20 mysqld_safe Adding '/usr/lib64/libjemalloc.so.1' to LD_PRELOAD for mysqld
171209 15:33:20 mysqld_safe Logging to '/var/log/mysqld.log'.
171209 15:33:20 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@localhost ~]# ps -ef | grep mys
root 8623 6024 0 15:33 pts/4 00:00:00 /bin/sh /usr/bin/mysqld_safe --user=mysql
mysql 8774 8623 4 15:33 pts/4 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 8799 6024 0 15:33 pts/4 00:00:00 grep --color=auto mys
[root@localhost ~]#
3. 停止percona服务
###注意这里没有使用`--defaults-file=/etc/my.cnf`,是因为这个默认使用该配置文件
###默认使用`socket=/var/lib/mysql/mysql.sock` 套接字通信
[root@localhost ~]# mysqladmin shutdown --sock=[/path.sock]
[root@localhost ~]# mysqladmin shutdown
171209 15:34:10 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[1]+ Done mysqld_safe --user=mysql
[root@localhost ~]# ps -ef | grep mys
root 8806 6024 0 15:34 pts/4 00:00:00 grep --color=auto mys
[root@localhost ~]#
3 自定义mysqld.server
1. 查看默认的mysqld.server
[root@localhost ~]# systemctl cat mysqld.service
# /usr/lib/systemd/system/mysqld.service
#
# Systemd service file for Percona Server
#
# # This service file is to start PS just with mysqld_safe
#
[Unit]
Description=MySQL Percona Server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
# 这里定义了一个别名
Alias=mysql.service
[Service]
# Needed to create system tables etc.
# 这里是执行了一个 `mysql_install_db`操作
ExecStartPre=/usr/bin/mysql-systemd pre
# Start main service
# 这里就是关键的启动操作了
ExecStart=/usr/bin/mysqld_safe
# Don't signal startup success before a ping works
# 这里执行了一个`mysqladmin ping`操作
ExecStartPost=/usr/bin/mysql-systemd post
# Give up if ping don't get an answer
TimeoutSec=600
Restart=always
PrivateTmp=false
[root@localhost ~]#
2. 写一个自己的mysqld3307.server
1. 定义自己的`my.cnf`配置文件
[root@localhost ~]# cat my.cnf
# Percona Server template configuration
[mysql]
# 这里可以把用户密码写在这里
port=3306
socket=/percona/3307/data/mysql.sock
[mysqld]
datadir=/percona/3307/data
socket=/percona/3307/data/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
port=3307
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log_bin=my-bin
[mysqld_safe]
log-error=/percona/3307/log/mysqld.log
pid-file=/percona/3307/run/mysqld.pid
[mysqladmin]
socket=/percona/3307/data/mysql.sock
[root@localhost ~]#
2. 定义一个`mysqld3307.service`文件
[root@localhost ~]# cat /usr/lib/systemd/system/mysqld3307.service
#
# Systemd service file for Percona Server
#
# # This service file is to start PS just with mysqld_safe
#
[Unit]
Description=MySQL Percona Server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=mysql.service
[Service]
# Needed to create system tables etc.
ExecStartPre=/usr/bin/mysql_install_db --defaults-file=/root/my.cnf --user=mysql
# Start main service
ExecStart=/usr/bin/mysqld_safe --defaults-file=/root/my.cnf --user=mysql
# Don't signal startup success before a ping works
ExecStartPost=/usr/bin/mysqladmin --defaults-file=/root/my.cnf
# Give up if ping don't get an answer
TimeoutSec=600
Restart=always
PrivateTmp=false
[root@localhost ~]#
3. 我们需要创建这些文件夹和文件
[root@localhost ~]# mkdir -p /percona/3307/{data,log,run}
[root@localhost ~]# touch /percona/3307/log/mysqld.log
[root@localhost ~]# chown -R mysql:mysql /percona/3307
[root@localhost ~]#
4. 使用systemctl
启动percona服务