正文
本文介绍percona-server-5.7.25-28版本二进制安装,操作系统基于Centos7,其他版本安装类似,可参考此文章
先决条件
yum 依赖项
# yum -y install libtool* numactl perl-DBD-MySQL libaio perl-Time-HiRes bc libatomic
openssl可以实现:秘钥证书管理、对称加密和非对称加密,主要包含三个组件
- openssl:多用途的命令行工具
- libcrypto:加密算法库
- libssl:加密模块应用库,实现了ssl及tls
# cd /usr/local/src
# wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
# tar -zxvf openssl-1.1.1c.tar.gz
# cd openssl-1.1.1c
# ./config --prefix=/usr/local/openssl
# make && make install
# echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf
# ldconfig -v
- 编译mysql的编译器libstdc++.so.6需要的版本为libstdc++.so.6.0.22,而centos7机器中版本为libstdc++.so.6.0.19,需要升级。文件从172.16.8.35机器拷贝
- 连接mysql需要libreadline.so.7
# cd /usr/local/src
# scp shanshan@172.16.8.31:/usr/local/src/libstdc++.so.6.0.22 /tmp
# cp libstdc++.so.6.0.22 /lib64
# cd /lib64
# rm -rf libstdc++.so.6
# ln -s libstdc++.so.6.0.22 libstdc++.so.6
# ln -s /usr/lib64/libreadline.so.6.2 /usr/lib64/libreadline.so.7
安装准备
创建用户并授权
# useradd -u 8000 -s /sbin/nologin -M mysql
# mkdir -p /data/mysql/3306
# mkdir -p /data1/binlog/3306
# chown -R mysql:mysql /data/mysql/3306 /data1/binlog/3306
数据库初始化
# cd /usr/local/src
# wget https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.25-28/binary/tarball/Percona-Server-5.7.25-28-Linux.x86_64.ssl102.tar.gz
# tar -zxvf Percona-Server-5.7.25-28-Linux.x86_64.ssl102.tar.gz
# mv Percona-Server-5.7.25-28-Linux.x86_64.ssl102 /usr/local/mysql
# chown -R mysql:mysql /usr/local/mysql
# echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
# source /etc/profile
# cd /usr/local/mysql/bin/
# ./mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize-insecure
服务配置
centos7下的MySQL服务路径为/lib/systemd/system/mysqld.service
mysqld.service内容
[Unit]
Description=mysql - high performance mysql server
Documentation=http://dev.mysql.net/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/sbin/mysqld_start
ExecStop=/usr/local/mysql/bin/mysqladmin -S /data/mysql/3306/mysql3306.sock shutdown -uroot -pxxxxxxx
PrivateTmp=true
mysqld_start内容
#!/bin/bash/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
启动服务、初始化常用用户
# systemctl start mysqld
# mysql -uroot -p --socket=/data/mysql/3306/mysql3306.sock --port=3306 -e " grant replication slave,replication client on *.* to 'rep'@'%' identified by 'rep_xxxx'"
# mysql -uroot -p --socket=/data/mysql/3306/mysql3306.sock --port=3306 -e " GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'zabbix'@'%' identified by 'zabbix_xxxx'"
# mysql -uroot -p --socket=/data/mysql/3306/mysql3306.sock --port=3306 -e " create user 'dbaadmin'@'%' IDENTIFIED by 'dba_xxx'"
# mysql -uroot -p --socket=/data/mysql/3306/mysql3306.sock --port=3306 -e " GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'dbaadmin'@'%'"
# mysql -uroot -p --socket=/data/mysql/3306/mysql3306.sock --port=3306 -e "alter user root@'localhost' IDENTIFIED by 'xxxxxxx'"