#
#
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
server-id = 1 #唯一
log-bin=mysql-bin 开启 binlog
sync-binlog=1
validate_password_policy=0
validate_password_length=1
修改完重启
systemctl restart mysqld
过滤MySQL初始密码
cat /var/log/mysqld.log | grep ‘password is generated‘
安全加固
mysql_secure_installation
mysql主库做授权配置
mysql –uroot-p
mysql>grant replication slave on . to ‘repl_user‘@‘192.168.60.%‘ identified by ‘密码‘;
查看主库状态
从库搭建mysql5.7
yum clean all && yum makecache && yum install epel* -y
rpm -Uvh http://repo.mysql.com/mysql57-community-release-el7.rpm
yum clean all && yum makecache
yum install gcc gcc-c++ openssl-devel mysql mys
systemctl start mysqld&&systemctl enable mysqld
修改 /etc/my.cnf
[root@slave ~]#vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
server-id = 2 和主库不一致即可
log-bin=mysql-bin
validate_password_policy=0
validate_password_length=6
修改完重启
systemctl restart mysqld
过滤MySQL初始密码
cat /var/log/mysqld.log | grep ‘password is generated‘
安全加固
mysql_secure_installation
从库登录mysql
mysql -uroot -p
mysql> set global read_only=1; 设置从库只读
mysql> change master to master_host=‘192.168.60.202‘,master_user=‘repl_user‘,master_password=‘密码‘,master_log_file=‘mysql-bin.000003‘,master_log_pos=154;
mysql>start slave;
从库 IO和SQL线程两个YES状态
原文:https://blog.51cto.com/13293070/2502606