debian下mysql主從配置

1.確保master/slave只有一份/etc/mysql/my.cnf , 不要在其餘地方再有my.cnf (如/etc/my.cnf  /usr/local之類)mysql

2.master配置:sql

在[mysqld]節點下添加:rest

server-id=1server

 

slave配置:it

在[mysqld]節點下添加: table

server-id=2
relay-log = /home/mysql/logs/mysqld-relay-bin
relay-log-index = /home/mysql/logs/mysqld-relay-bin.index
replicate-ignore-db=mysql
replicate-ignore-db=testast

 

3.前後重啓master、slave的mysql: /etc/init.d/mysql restarttest

4.在master上用root登錄mysql: mysql -uroot -p配置

5.master上鎖表:top

mysql> flush tables with read lock;

6.show master status; 記錄binlog的名字和位置

7.slave是登錄mysql,而後:

mysql> slave stop;

mysql> CHANGE MASTER TO MASTER_HOST='X.X.X.X',MASTER_USER='slave',MASTER_PASSWORD='fai',MASTER_LOG_FILE='mysqld-bin.000015',MASTER_LOG_POS=106;

mysql> slave start;

mysql> show slave status\G;

 

8.master上解鎖:

mysql> unlock tables;

相關文章
相關標籤/搜索