如何使用xtrabackup工具创建从节点
xtrabackup的安装和备份方法可以参考我的另一篇博客http: //blog.itpub.net/20893244/viewspace-2133530/
环境:
master ip: 192.168.3.171
slave ip: 192.168.3.173
mysql版本:
(root@localhost) [gldb]> 选择版本();
+-- ----------+
| 版本() |
+--- -------------+
| 5.7.17-log |
+----------------+
1 row in set (0.00 sec)
使用xtrabackup工具创建从节点需要七个步骤,我们一步一步来
1、主节点数据完整备份
innobackupex --defaults -file=/etc/my.cnf --host=oracle11gtest --用户=xtrabk --并行=4--password=onlybackupgl --extra-lsndir=/alidata1/mysqlbackup/mysql_full --stream=tar /tmp | gzip > /alidata1/mysqlbackup/mysql_full/xtra_fullbak_2017-02-20.tar.gz
2.复制并准备备份集
1.将备份集复制到从端
scp -r /alidata1/mysqlbackup/mysql_fullroot@192.168.3.173:/alidata1/mysqldata/mysqlbackup
2.解压从端备份集
tar -xzvf xtra_fullbak_2017-02-20.tar
3.准备数据并使用--apply-log参数执行innobackupex命令
innobackupex --apply-log /alidata1/mysqldata/mysqlbackup/mysql_full
3.创建复制环境专用账户并授予权限
创建用户repl@'192.168.3.173';
授予*.* 上的复制从站到由“replmysql”标识的 repl;
4.配置从节点初始化参数
从master端复制到slave端,仍然使用scp命令;
修改slave端的初始化文件,将server_id改为非0值
启动数据库
mysqld_safe --defaults -file=/etc/my.cnf &
5.配置从节点复制环境
查看xtrabackup_binlog_info文件中的数据
[root@mysqltest mysql_full]# more xtrabackup_binlog_info< br/>
mysql-bin.000016 1884
执行change masger命令
将master更改为
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;
执行启动slave命令
mysql >启动slave;
6.检查
(root@localhost) [(none)]>显示从状态\G;
** *************************** 1. 行 ****************** *********
Slave_IO_State:等待主机发送事件
Master_Host:192.168.3.171
p>
Master_User:repl
Master_User : p; 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:是
Slave_SQL_Running:是
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Ignore_Table:
代表licate_Wild_Ignore_Table:
Last_Errno:0
Last_Error:
p>
Skip_Counter:0
nbsp; Relay_Log_Space:2278
Until_Condition:无
Until_Log_File:
Until_Log_Pos:0
p>
Master_ssl_allowed:否
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:否
Last_IO_Errno:0
Last_IO_Error:
Last_SQL_Errno:0
Last_SQL_Error :
Replicate_Ignore_Server_I ds:
Master_Server_Id:2
Master_UUID:659e33c7-f1ef-11e6-8e3e- 00163e3225da
Master_Info_File: /alidata1/mysqldata/3306/data/master.info
>
Slave_SQL_Running_State:Slave已读取所有中继日志;等待更多更新
Master_Retry_Count:86400
Master_Bind:
p>
Last_IO_Error_Timestamp:
p>
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position:0
Replicate_Rewrite_DB:
Channel_Name:< br/>
Master_TLS_Version:
组中 1 行(0.00 秒)
7.测试
在master端创建表
(root@localhost) [( none)]> use gldb
p>
数据库已更改
(root@localhost) [gldb]> create table gl (abcd varchar(20));
查询OK,0行受影响(0.51秒)
slave端查询是否传递成功
(root@localhost) [(无)]>use gldb;
数据库已更改
(root@localhost) [gldb]> show create table gl;
|表|创建表 |
+--------------------+-------------------- --------- ---------------------------------------------------- --------- -----------------+
| GL |创建表 `gl` (
`abcd` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+--- ----+------------------------------------ -------------- ------------------------------------ --------------+
集合中1行(0.00秒)
同步成功~~~
以上就是《如何使用xtrabackup工具创建从节点》本文的全部内容,感谢您的阅读!相信大家都有了一定的了解,希望分享的内容会对大家有所帮助,如果你想了解更多知识可以owledge,请关注行业资讯频道!
2. 本站积分货币获取途径以及用途的解读,想在本站混的好,请务必认真阅读!
3. 本站强烈打击盗版/破解等有损他人权益和违法作为,请各位会员支持正版!
4. 编程技术 > 如何使用xtrabackup工具创建从节点