準備兩台 mysql server , 用 vmware ESX server , clone 了兩台出來 , 也順便把 dbs 的 aggregator 弄了一套在上面
- 加個 master 端的 repl 帳號 , 只允許 REPLICATION SLAVE 權限
GRANT REPLICATION SLAVE ON *.* TO ‘repl’@’%’ IDENTIFIED BY ‘xxxxxx’;
— 小心 % 要改一下! - Setting the Replication Master Configuration 改 master 的 /etc/my.cnf 檔
[mysqld] log-bin=mysql-bin server-id=1
- Setting the Replication Slave Configuration 改 slave 的 /etc/my.cnf 檔 , 主要是設 server-id , 把那個 log-bin=mysql-bin 註解掉
- 把 master 要 replication 的 database 搬一份到 slave
in master server:cd /var/lib/mysql
tar cf – db_item/ | ssh [email protected] ‘cd /var/lib/mysql/ ; tar xf –’
( 172.30.0.183 是此例的 slave )
- Setting Up Replication with New Master and Slaves
- unlock master
in master:unlock tables;
- startup slave ,
execute change master to command:change master to master_host=’172.30.0.182′ , master_user=’repl’ , master_password=’xxxxx’ , master_log_file=’mysql-bin.000005′, master_log_pos=791;
- in slave:
start slave; - done!