MYSQL Master-Slave Check
1. 用putty或者secureCRT登录主库,切换用户成root :
mysql -uroot -pxxxxxx
|
2. 查看主库同步状态:
show master status
|
如下图内容,
日志文件为:updatelog.000028
3. 用putty或者secureCRT登录备库,切换用户成root
mysql -uroot -pxxxxxx
|
4. 查看备库同步状态:
show slave status\G
|
根据如下参数判断是否为同步:
a. Relay_Master_Log_File: 文件是否与主库中相同
b. Slave_IO_Running: Yes
c. Slave_SQL_Running: Yes
d. Seconds_Behind_Master: 0
5. Seconds_Behind_Master参数值为NULL,处理如下:
slave stop
change master to master_host='IP地址', master_user='root', master_password='xxxxxx', master_port=3306, master_log_file='日志文件', master_log_pos=日志位置;
slave start
|
6. 查看备库同步状态:
show slave status\G
|
7. 如果报错,处理如下:
slave stop
set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
slave start
|
8.如果仍旧报错,而且报错编号相同,例如:1062.处理如下:
a. 修改配置文件/etc/my.cnf,在[mysqld]下添加
slave-skip-errors = 1062
|
b. 停mysql服务:
ps -ef|grep mysql
kill -9 相关进程
|
c. 启动mysql服务:
./usr/local/mysql/bin/mysqld_safe &
|
Comments
Post a Comment