《Mysql必讀step by step配置mysql復制的具體方法》要點:
本文介紹了Mysql必讀step by step配置mysql復制的具體方法,希望對您有用。如果有疑問,可以聯系我們。
MYSQL應用采用全庫復制的方案,方便管理mysql 5.5 + rhel5.8
10.4.11.12 master
10.4.11.13 slave
---Master端設置
1,??? 創建復制帳號,需要復制和slave權限
mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.*? TO repl@'10.4.11.12 IDENTIFIED BY 'mysql;
Query OK, 0 rows affected (0.00 sec)
2,??? 修改參數,并重啟生效
#skip-networking
server-id?????? = 12
# Uncomment the following if you want to log updates
log-bin=mysql-bin
重啟mysql
service mysql restart
---slave端的設置
3,slave庫的參數設置,同樣需要重啟生效
vi /etc/my.cnf
#skip-networking
server-id?????? = 13
# Uncomment the following if you want to log updates
log-bin=mysql-relay-bin
4,master導出數據到slave庫
如果數據庫使用的是MyISAM表類型的話,可按如下方式操作:
shell> mysqldump --all-databases --master-data=1 > data.sql
如果數據庫使用的是InnoDB表類型的話,則應該使用single-transcation:
shell> mysqldump --all-databases --single-transaction --master-data=1 > data.sql
slave端導入數據
mysql < data.sql
?
5,查看master的配置
mysql> show master status;
+------------------+----------+--------------+------------------+
| File???????????? | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |????? 107 |????????????? |????????????????? |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
6,啟動復制,slave端運行如下命令
MYSQL應用mysql> show slave status\G
*************************** 1. row ***************************
?????????????? Slave_IO_State: Waiting for master to send event
????????????????? Master_Host: 172.16.251.11
????????????????? Master_User: repl
????????????????? Master_Port: 3306
??????????????? Connect_Retry: 60
????????????? Master_Log_File: mysql-bin.000001
????????? Read_Master_Log_Pos: 1278
?????????????? Relay_Log_File: linux2-relay-bin.000002
??????????????? Relay_Log_Pos: 503
??????? Relay_Master_Log_File: mysql-bin.000001
???????????? Slave_IO_Running: Yes
??????????? Slave_SQL_Running: Yes
????????????? Replicate_Do_DB:
……..
8,測試復制情況
Master端新建一個表
Slave查看是否復制完成
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/3577.html