您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“怎么用xtrabackup工具創(chuàng)建slave節(jié)點”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學習一下“怎么用xtrabackup工具創(chuàng)建slave節(jié)點”這篇文章吧。
xtrabackup安裝和備份方法等請先參考我的另一篇博客 http://blog.itpub.net/20893244/viewspace-2133530/
環(huán)境:
master ip:192.168.3.171
slave ip: 192.168.3.173
mysql版本:
(root@localhost) [gldb]> select version();
+------------+
| version() |
+------------+
| 5.7.17-log |
+------------+
1 row in set (0.00 sec)
用xtrabackup工具創(chuàng)建slave節(jié)點需要七步驟,我們一步一步操作
一.在master節(jié)點完整備份數(shù)據(jù)
innobackupex --defaults-file=/etc/my.cnf --host=oracle11gtest --user=xtrabk --parallel=4 --password=onlybackupgl --extra-lsndir=/alidata1/mysqlbackup/mysql_full --stream=tar /tmp | gzip > /alidata1/mysqlbackup/mysql_full/xtra_fullbak_2017-02-20.tar.gz
二.復制和準備備份集
1.把備份集拷貝到slave端
scp -r /alidata1/mysqlbackup/mysql_full root@192.168.3.173:/alidata1/mysqldata/mysqlbackup
2.在slave端解壓備份集
tar -xzvf xtra_fullbak_2017-02-20.tar
3.準備數(shù)據(jù),執(zhí)行innobackupex命令附加--apply-log參數(shù)
innobackupex --apply-log /alidata1/mysqldata/mysqlbackup/mysql_full
三.創(chuàng)建復制環(huán)境專用賬戶并賦予權(quán)限
create user repl@'192.168.3.173';
grant replication slave on *.* to repl identified by 'replmysql';
四.配置slave節(jié)點的初始化參數(shù)
從master端拷貝到slave端,還是用scp命令;
在slave端修改初始化文件,把server_id修改為一個非0的值
啟動數(shù)據(jù)庫
mysqld_safe --defaults-file=/etc/my.cnf &
五.配置slave節(jié)點復制環(huán)境
查看xtrabackup_binlog_info文件里的數(shù)據(jù)
[root@mysqltest mysql_full]# more xtrabackup_binlog_info
mysql-bin.000016 1884
執(zhí)行change masger命令
change master to
master_host='192.168.3.171',
master_port=3306,
master_user='repl',
master_password='replmysql',
master_log_file='mysql-bin.000016',
master_log_pos=1884;
執(zhí)行start slave命令
mysql > start slave;
六.檢查
(root@localhost) [(none)]> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.3.171
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000016
Read_Master_Log_Pos: 3631
Relay_Log_File: mysqltest-relay-bin.000002
Relay_Log_Pos: 2067
Relay_Master_Log_File: mysql-bin.000016
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: 3631
Relay_Log_Space: 2278
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: 2
Master_UUID: 659e33c7-f1ef-11e6-8e3e-00163e3225da
Master_Info_File: /alidata1/mysqldata/3306/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
七.測試
在master端創(chuàng)建一個表
(root@localhost) [(none)]> use gldb
Database changed
(root@localhost) [gldb]> create table gl (abcd varchar(20));
Query OK, 0 rows affected (0.51 sec)
在slave端查詢是否通過成功
(root@localhost) [(none)]> use gldb;
Database changed
(root@localhost) [gldb]> show create table gl;
+-------+--------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------------+
| gl | CREATE TABLE `gl` (
`abcd` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+--------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
同步成功~~~
以上是“怎么用xtrabackup工具創(chuàng)建slave節(jié)點”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。