分享更有价值
被信任是一种快乐

MySQL 5.5如何使用Xtrabackup在线搭建复制环境

文章页正文上

这篇文章给大家分享的是有关MySQL 5.5如何使用Xtrabackup在线搭建复制环境的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

–编辑Master的配置文件
[root@localhost install]# vim /etc/my.cnf
# Log
server-id = 100
log-bin = /log/binlog/mysql-bin

–在Slave安装好MySQL软件,安装流程可以参考源码安装文章
http://blog.itpub.net/26506993/viewspace-2072859/

–在Master节点,使用Xtrabackup创建完整备份
关于Xtrabackup,可参考
http://blog.itpub.net/26506993/viewspace-2087734/
http://blog.itpub.net/26506993/viewspace-2088737/

[root@localhost backup]# /install/percona/percona-xtrabackup-2.4.2-Linux-x86_64/bin/innobackupex –defaults-file=/etc/my.cnf –stream=tar /tmp –user system –password ‘Mysql#2015’ | gzip ->
/backup/xtra/xtra_fullbackup_20160501.tar.gz

–拷贝备份到Slave节点
[root@localhost backup]# scp /backup/xtra/xtra_fullbackup_20160501.tar.gz root@192.168.78.137:/backup/20160501

解压备份到数据文件目录
[root@localhost 5505]# tar xivfz xtra_fullbackup_20160501.tar.gz -C /mysql_data/5505

在Slave节点上面需要安装Xtraback
–使用Xtrabackup准备数据、应用日志,使数据文件达到一致性的状态
[root@localhost bin]# ./innobackupex –defaults-file=/mysql_data/cnf/my.cnf –apply-log /mysql_data/5505
…..
InnoDB: Doing recovery: scanned up to log sequence number 68405269 (0%)
InnoDB: Doing recovery: scanned up to log sequence number 68405269 (0%)
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: xtrabackup: Last MySQL binlog file position 414, file name /log/binlog/mysql-bin.000012
InnoDB: Removed temporary tablespace data file: “ibtmp1”
InnoDB: Creati免费主机域名ng shared tablespace for temporary tables
InnoDB: Setting file ‘./ibtmp1’ size to 12 MB. Physically writing the file full; Please wait …
InnoDB: File ‘./ibtmp1’ size is now 12 MB.
InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
InnoDB: 32 non-redo rollback segment(s) are active.
InnoDB: 5.7.11 started; log sequence number 68405269
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown…
InnoDB: Shutdown completed; log sequence number 68405621
160430 23:51:25 completed OK!

–在Master数据库上面创建复制专用账户
mysql> grant replication slave on *.* to ‘repl’@’192.168.78.%’ identified by ‘Mysql#2015’;
Query OK, 0 rows affected (0.04 sec)

–配置Slave的配置文件
[root@localhost 5505]# vim /mysql_data/cnf/my.cnf
# Log
server-id = 200
log-bin = /mysql_log/binlog/mysql-bin
relay-log = /mysql_log/binlog/product-relay-bin
relay-log-index = /mysql_log/binlog/product-relay-index
binlog_cache_size = 32M
max_binlog_cache_size = 512M
max_binlog_size = 512M
binlog_format = MIXED
relay_log_recovery = 1

–启动Slave节点的Mysql服务
[root@loca免费主机域名lhost bin]# /data/bin/mysqld_safe –defaults-file=/mysql_data/cnf/my.cnf &

–配置Slave节点复制环境
查询Slave节点连接Master节点的二进制文件和位置
使用Xtrabackup备份时,在xtrabackup_binlog_info文件中会保存这部分信息
[root@localhost 5505]# more xtrabackup_binlog_info
mysql-bin.000012 414

–在Slave节点执行CHANGE MASTER语句
mysql> change master to
-> master_host=’192.168.78.139′,
-> master_port=3306,
-> master_user=’repl’,
-> master_password=’Mysql#2015′,
-> master_log_file=’mysql-bin.000012′,
-> master_log_pos=414;
Query OK, 0 rows affected (0.13 sec)

–启动应用线程
mysql> start slave;
–查看同步状态
mysql> show slave statusG
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.78.141
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000013
Read_Master_Log_Pos: 341
Relay_Log_File: product-relay-bin.000003
Relay_Log_Pos: 487
Relay_Master_Log_File: mysql-bin.000013
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
感谢各位的阅读!关于“MySQL 5.5如何使用Xtrabackup在线搭建复制环境”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

相关推荐: 怎么用perl访问mysql数据库

小编给大家分享一下怎么用perl访问mysql数据库,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!一. 安装DBI模块步骤1:从TOOLS栏目中下载DBI.zip,下载完后用winz…

文章页内容下
赞(0) 打赏
版权声明:本站采用知识共享、学习交流,不允许用于商业用途;文章由发布者自行承担一切责任,与本站无关。
文章页正文下
文章页评论上

云服务器、web空间可免费试用

宝塔面板主机、支持php,mysql等,SSL部署;安全高速企业专供99.999%稳定,另有高防主机、不限制内容等类型,具体可咨询QQ:360163164,Tel同微信:18905205712

主机选购导航云服务器试用

登录

找回密码

注册