MySQL主从复制问题解决一例
这是mysql关于主从复制的主库的配置相关内容:server-id = 1
log-bin=/mysql_log/binlog/bin-log
slave-skip-errors=1062,1205
max_binlog_size = 500M
binlog_cache_size = 128K
relay-log =/mysql_log/relaylog/relaylog
log-slave-updates 之前搭建的MySQL主从复制出现问题,不能正常同步,查看日志,发下有以下错误:
120726 13:20:36 Could not use /mysql_log/relaylog/relaylog for logging (error 2). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
120726 13:20:36 Failed in open_log() called from init_relay_log_info()
120726 13:20:36 Failed to initialize the master info structure
120726 13:20:36 Could not use /mysql_log/binlog/bin-log for logging (error 2). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
120801 17:53:00 Failed to open the relay log '/mysql_log/relaylog/relaylog.036' (relay_log_pos 4)
120801 17:53:00 Could not find target log during relay log initialization
120801 17:53:00 Failed to initialize the master info structure
1、关闭mysql
# mysqladmin -p shutdown
Enter password:
# tail -f /home/mysql/data/111_ddb.err
120801 17:56:57 /usr/local/mysql/libexec/mysqld: Normal shutdown
120801 17:56:58InnoDB: Starting shutdown...
120801 17:57:30InnoDB: Shutdown completed
120801 17:57:30 /usr/local/mysql/libexec/mysqld: Shutdown Complete
120801 17:57:30mysqld ended 2、删除主库上关于binlog日志的记录文件,msater.info 和 relay-log.info
# cd /home/mysql/data/
# ls
111_ddb.err111_ddb-slow.logddb ibdata1 ib_logfile1master.infomysql_dd slow.logtest
111_ddb.pidadb ib_arch_log_0000000000ib_logfile0ib_logfile2mysql relay-log.infotdb
# ls *info
master.inforelay-log.info
# ls
111_ddb.err111_ddb-slow.logddb ibdata1 ib_logfile1master.infomysql_dd slow.logtest
111_ddb.pidadb ib_arch_log_0000000000ib_logfile0ib_logfile2mysql relay-log.infotdb
# rm -f master.info relay-log.info
# cd /mysql_log/binlog/
# ls
bin-log.001bin-log.index
# rm -f *
# cd ../relaylog/
# ls
relaylog.001relaylog.index
# rm -f *
# cd ../binlog/ 3、开启mysql
# /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/innodb.cnf --datadir=/home/mysql/data --user=mysql &
# tail -f /home/mysql/data/111_ddb.err
120801 17:58:21mysqld started
120801 17:58:23InnoDB: Started
/usr/local/mysql/libexec/mysqld: ready for connections.
Version: '4.0.26-log'socket: '/tmp/mysql.sock'port: 3306Source distribution
# ll
total 13080
-rw-rw---- 1 mysql mysql 13365795 Aug1 17:59 bin-log.001
-rw-rw---- 1 mysql mysql 30 Aug1 17:58 bin-log.index
# ll
total 13828
-rw-rw---- 1 mysql mysql 14132046 Aug1 17:59 bin-log.001
-rw-rw---- 1 mysql mysql 30 Aug1 17:58 bin-log.index
# ll
total 15020
-rw-rw---- 1 mysql mysql 15355877 Aug1 17:59 bin-log.001
-rw-rw---- 1 mysql mysql 30 Aug1 17:58 bin-log.index 通过日志和查看binlog文件,说明主库的配置恢复正常
页:
[1]