复制不起作用

时间:2015-12-23 06:57:00

标签: mysql replication

我配置了主从复制,但工作正常但是5分钟左右就停止了工作!虽然slave状态显示复制很好,但是我在master中插入的内容不是在slave中复制

enter image description here

这是我跟随的tutorial

当我在slave

上运行命令服务mysqld restart时,事情才开始再次复制
# nano /etc/my.cnf

 server-id = 1
 binlog-do-db=db0
 binlog-do-db=db2
 binlog-do-db=db3
 relay-log = /var/lib/mysql/mysql-relay-bin
 relay-log-index = /var/lib/mysql/mysql-relay-bin.index
 log-error = /var/lib/mysql/mysql.err
 master-info-file = /var/lib/mysql/mysql-master.info
 relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
 log-bin = /var/lib/mysql/mysql-bin

# /etc/init.d/mysqld restart

# mysql -u root -pMorphie5

GRANT REPLICATION SLAVE ON *.* TO 'xgears'@'137.116.213.135' IDENTIFIED BY 'Morphie5';
 FLUSH PRIVILEGES;
 FLUSH TABLES WITH READ LOCK;
 SHOW MASTER STATUS;
mysql>exit;

#  mysqldump  -u root  --all-databases --master-data > /root/dbdump.db

mysql> UNLOCK TABLES;
mysql> quit;

scp /root/dbdump.db root@137.116.213.135:/root/

服务器端

# nano /etc/my.cnf

server-id = 2
replicate-do-db=db0
replicate-do-db=db2
replicate-do-db=db3
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
log-bin = /var/lib/mysql/mysql-bin

# mysql -u root  < /root/dbdump.db
# /etc/init.d/mysqld restart

# mysql -u root -p

slave stop;
 CHANGE MASTER TO MASTER_HOST='40.85.93.234', MASTER_USER='xgears', MASTER_PASSWORD='Morphie5', MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=342;
 slave start;
 show slave status \G

0 个答案:

没有答案