时间:2021-07-01 10:21:17 帮助过:6人阅读
C.slave用户必须有SUPER权限
D.master复制用户必须具备RELOAD和SUPER权限
E.LOAD数据时,将在master上将使用全局读锁
F.建议数据比较少或者master允许长时间读锁时才使用
4:双机互备则是两个mysql同时配置为master及slave
5:为了防止binlog日志撑爆服务器,建议配置binlog过期自动删除
使用命令配置
mysql>set global expire_logs_days=8;
使用配置文件my.cnf
expire_logs_days=8
查看配置结果
mysql>show variables like ‘expire_logs_days‘;
=============================================================================================
主服务器上的相关命令:
mysql>show master status\G
mysql>show master status;
mysql>show slave hosts;
mysql>show logs;
mysql>show binlog events;
mysql>show binary logs;
mysql>purge logs to ‘log_name‘;
mysql>purge logs before ‘date‘;
mysql>reset master; //老版本为 flush master
mysql>set sql_log_bin=/xxx;
从服务器上的相关命令:
mysql>slave start;
mysql>slave stop;
mysql>SLAVE STOP IO_THREAD; //此线程把master段的日志写到本地
mysql>SLAVE start IO_THREAD;
mysql>SLAVE STOP SQL_THREAD; //此线程把写到本地的日志应用于数据库
mysql>SLAVE start SQL_THREAD;
mysql>reset slave;
mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER;
mysql>load data from master;
mysql>show slave status; //SUPER,REPLICATION CLIENT
mysql>CHANGE MASTER TO MASTER_HOST=127.0.0.1, MASTER_PORT=3306,MASTER_USER=user, MASTER_PASSWORD=pwd; //动态改变master信息
mysql>PURGE MASTER [before ‘date‘]; 删除master端已同步过的日志
mysql>purge binary logs to ‘ablelee.000003‘; //删除ablelee.000003之前的binlog,不包含ablelee.000003
mysql>PURGE MASTER LOGS TO ‘mysql-bin.010‘;
mysql>PURGE MASTER LOGS BEFORE ‘2008-06-22 13:00:00‘;
PURGE命令语法
PURGE {MASTER | BINARY} LOGS TO ‘log_name‘
PURGE {MASTER | BINARY} LOGS BEFORE ‘date‘
mysql主从同步注意事项
标签:data lis pass 上启 change cli ast 完成 before