标签:color stat user scheduler char ica sch file ble
Slave服务器的版本要等于或者高于master服务器
现在的实例是在mysql 5.7上的主从配置
a) master服务器的my.cnf配置,server_id 推荐用IP的后两位数字
[mysqld] federated port=50000 basedir = /usr/local/mysql datadir = /usr/local/mysql/data server_id = 43209 log-bin=mysql-bin expire_logs_days=3 binlog-do-db=dbname binlog-ignore-db=mysql,information_schema max_allowed_packet=500M event_scheduler=1 max_connections=2000 character_set_server=utf8 init_connect=‘SET NAMES utf8‘ sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [client]
b) master服务器授权一个可以数据同步的用户(这里的用户是slave,密码123456)
grant replication slave on *.* to ‘repl‘@‘%‘ identified by ‘123456‘;
c) master 服务器重启mysql
service mysqld restart
d) slave服务器的my.cnf配置
[mysqld]
federated
port=50000
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
server_id = 43210
log-bin=mysql-bin
expire_logs_days=3
binlog-do-db=dbname
binlog-ignore-db = mysql,information_schema
max_allowed_packet=500M
max_connections=2000
character_set_server=utf8
init_connect=‘SET NAMES utf8‘
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
default-character-set=utf8
e) salve 服务器测试连接master的同步用户(slave)
mysql -hX.X.X.X -uslave -p123456
f) slave服务器重启
service mysqld restart
*****************************************************************************************************************************
1:在master服务器跑
mysqldump --master-data=2 --single-transaction -uroot -p dbname > /root/mysqldump.sql
2:把主服务器产生的mysqldump.sql 做gzip 压缩,上传到从服务器
gzip -9 /root/mysqldump.sql
scp /root/mysqldump.sql.gz root@X.X.X.X:/root/
3:在从服务器上source /root/mysqldump.sql
4:查看 mysqldump.sql中的MASTER_LOG_FILE和MASTER_LOG_POS信息
5:在从服务器运行stop slave,CHANGE MASTER TO master_host=‘192.X.X.X‘, MASTER_LOG_FILE=‘mysql-bin.000028‘, MASTER_LOG_POS=654560631, master_user=‘slave‘, master_password=‘123456‘, master_port=50000;
6:在从服务器运行 start slave;
7:在从服务器运行show slave status; 查看Slave_IO_Running和Slave_SQL_Running 两列是否都为YES,如果都是YES就正常了
标签:color stat user scheduler char ica sch file ble
原文地址:https://www.cnblogs.com/faberbeta/p/mysql-master-slave.html