Innobackupex+mysql replication

   結合mysql replication那篇文章,只是把mydump備份使用了innobackupex工具替代,其他操作基本一樣。使用innobackupex不需要手動鎖表操作,鎖表時間更短,備份更加快。

master:192.168.1.1 slave:192.168.1.2

master上進行備份操作  

innobackupex --user=root --password=xxxxxx --host=127.0.0.1 --port=3306 --stream=tar

--defaults-file=/etc/my.cnf /tmp/| ssh [email protected] "mkdir /db; tar xfi - -C /db/"

innobackupex  以steam方式拷貝主服務器上的datadir目錄中的數據到到從服務器/db。

slave停止mysql服務

/etc/init.d/mysqld stop

#rm /var/lib/mysql/* -rf     #刪除原始數據

#innobackupex --host=127.0.0.1 --user=root --password=xxxxx --port=3306 --apply-log /db/

#innobackupex --host=127.0.0.1 --user=root --password=xxxxx --port=3306 --copy-back /db/


cat /db/xtrabackup_binlog_info  #查看二進制的日誌和pos

mysql-bin.000011      1234

mysql>CHANGE MASTER TO

MASTER_HOST='192.168.1.2',MASTER_USER='repl',MASTER_PASSWORD='xxxxx',MASTER_PORT=3306,

MASTER_LOG_FILE='mysql-bin.000011',MASTER_LOG_POS=1234;

mysql>start slave;

mysql>show slave status\G

*************************** 1. row ***************************

              Slave_IO_State: Waiting for master to send event

                 Master_Host: 192.168.1.2

                 Master_User: repl

                 Master_Port: 3306

               Connect_Retry: 60

             Master_Log_File: mysql-bin.000011

         Read_Master_Log_Pos: 1234

              Relay_Log_File: mysql-relay-bin.000002

               Relay_Log_Pos: 253

       Relay_Master_Log_File: mysql-bin.000011

            Slave_IO_Running: Yes

           Slave_SQL_Running: Yes

             Replicate_Do_DB:

         Replicate_Ignore_DB:

          Replicate_Do_Table:

      Replicate_Ignore_Table:

     Replicate_Wild_Do_Table:

 Replicate_Wild_Ignore_Table:

                  Last_Errno: 0

                  Last_Error:

                Skip_Counter: 0

         Exec_Master_Log_Pos: 1234

             Relay_Log_Space: 409

             Until_Condition: None

              Until_Log_File:

               Until_Log_Pos: 0

          Master_SSL_Allowed: No

          Master_SSL_CA_File:

          Master_SSL_CA_Path:

             Master_SSL_Cert:

           Master_SSL_Cipher:

              Master_SSL_Key:

       Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

               Last_IO_Errno: 0

               Last_IO_Error:

              Last_SQL_Errno: 0

              Last_SQL_Error:

 Replicate_Ignore_Server_Ids:

            Master_Server_Id: 1923306

1 row in set (0.00 sec)

查看Slave_IO_Running,Slave_SQL_Running如果都是yes,則replication perfect!



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