MySQL的replication熱備配置過程
(2013-03-16 22:55:37)
http://blog.csdn.net/lapiggy (MySQL效能及主備跳服務設定文檔)http://blog.sina.com.cn/s/articlelist_1755341331_1_1.html (DRBD(叢集)配置過程)
作業系統:中標LinuxMysql版本:mysql-server.i386 0:5.0.45-7.el5(註:安裝mysql是用的yum命令)Mysql1端 IP 192.168.2.122Mysql2端 IP 192.168.2.123資料庫:test1.Mysql1設定:1.1 設定Mysql Replication1.增加一用於資料庫同步的使用者rootmysql>GRANT REPLICATION SLAVE,REPLICATIONCLIENT,RELOAD,SUPER ON *.* TO 'root'@'192.168.2.123' IDENTIFIED BY'password';(授與從192.168.2.123主機上登入使用者root資料複製許可權)2.使許可權生效,這步可不做,因為過會要重啟mysqlmysql>flush privileges;3.退出mysql命令列介面mysql> exit4.停止mysql服務service mysqld stop5.更改Mysql設定檔/etc/my.cnf開啟mysql設定檔vi /etc/my.cnf在設定檔中添加以下內容[mysqld]#masterlog-binserver-id=1binlog-do-db= vtigercrm510 #slavemaster-host = 192.168.2.120master-user = rootmaster-password = passwordmaster-port = 3306master-connect-retry = 10replicate-do-db = test6.啟動Mysqlservice mysqld start2.Mysql2設定: 1.更改Mysql設定檔/etc/my.cnf開啟Mysql的設定檔vi /etc/my.cnf在設定檔中添加以下內容 [mysqld]#masterlog-binserver-id=2binlog-do-db= vtigercrm510 #slavemaster-host = 192.168.2.118master-user = rootmaster-password = passwordmaster-port = 3306master-connect-retry = 10replicate-do-db = vtigercrm510 2.重新啟動Mysql服務service mysqld restart3.Mysql1設定: 1.分別在mysql1和mysql2上啟動slavemysql> START SLAVE;2.查看slave狀態:mysql> show slave status\G;Slave_IO_Running: YesSlave_SQL_Running: Yes如果都是yes,代表已經在同步 3.查看mster狀態mysql> Show master status;Mysql設定完畢