mysql主從配置記錄

1.環境

兩臺服務器編譯安裝mysql5.5

master:192.168.1.2

slave:192.168.1.3


2.配置

master配置:

vi /etc/my.cnf         # [mysqld]下添加,開啓binlog
log-bin = master-bin
log-bin-index = master-bin.index
server-id = 1

binlog_ignore_db=mysql    #表示忽略同步mysql

#server-id=1中的1可以任定義,只要是唯一的就行。
#binlog-do-db=wordpress是表示只同步 wordpress。如果存在多個就複寫多條.
#不加binlog-do-db和binlog_ignore_db,那就表示同步全部數據庫。

slave配置:

vi /etc/my.cnf

server-id = 2
relay-log-index = slave-relay-bin.index
relay-log = slave-relay-bin


3.初始化
#master
GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%' IDENTIFIED BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'replication'@'192.168.1.3' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
SHOW MASTER STATUS;

#slave
CHANGE MASTER TO master_host='192.168.1.2',master_port=3306, master_user='replication', master_password='password', master_log_file='mysql-bin.000003', master_log_pos=2037;
START SLAVE;
SHOW SLAVE STATUS\G

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章