percona-xtrabackup工具实现mysql5.6.34的主从同步复制
percona-xtrabackup工具实现mysql5.6.34的主从同步复制

下载并安装percona-xtrabackup工具
# wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.7/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.7-1.el6.x86_64.rpm # yum localinstall -y percona-xtrabackup--2.4.-.el6.x86_64.rpm
1.备份,将mysql数据库整个备份到/opt/目录下
# innobackupex --defaults-file="/etc/my.cnf" --user=root -proot --socket=/tmp/mysql.sock /opt
2.预处理,进行事物检查(也可以拷贝到从库后再进行检查)
# innobackupex --defaults-file="/etc/my.cnf" --user=root -proot --socket=/tmp/mysql.sock --apply-log --use-memory=1G /opt/--18_00--/
3.scp到从库
[root@centossz008 ~]# scp -r /opt/--18_01--/ 192.168.3.13:/opt
4.关闭从库,清理从库数据,恢复数据到从库
/etc/init.d/mysqld stop
删除从库的数据和日志信息
[root@node5 ~]# rm -rf /data/mydata/*
[root@node5 ~]# rm -rf /data/binlogs/*
[root@node5 ~]# rm -rf /data/relaylogs/*
在从库上执行(将数据恢复到数据库中)
[root@node5 ~]# innobackupex --defaults-file="/etc/my.cnf" --user=root --socket=/tmp/mysql.sock --move-back /opt/--18_01--/
5.修改权限,启动从库
[root@node5 mydata]# chown -R mysql.mysql /data
[root@node5 mydata]# /etc/init.d/mysqld start
查看主库中master位置
[root@node5 mydata]# cat /opt/--18_01--/xtrabackup_binlog_info
master-bin. 4c6237f8-a7da-11e6--000c29f333f8:-
6.主库中创建建salve同步用户
mysql> grant replication slave,reload,super on *.* to repluser@192.168.3.13 identified by 'replpass';
mysql> FLUSH PRIVILEGES;
7.从库执行同步
mysql> change master to master_host='192.168.3.12',master_user='repluser',master_password='replpass',master_log_file='master-bin.000002',master_log_pos=;
mysql> start slave; mysql> show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.3.12
Master_User: repluser
Master_Port:
Connect_Retry:
Master_Log_File: master-bin.
Read_Master_Log_Pos:
Relay_Log_File: relay-bin.
Relay_Log_Pos:
Relay_Master_Log_File: master-bin.
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:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 4c6237f8-a7da-11e6--000c29f333f8
Master_Info_File: /data/mydata/master.info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 4c6237f8-a7da-11e6--000c29f333f8:-
Executed_Gtid_Set: 4c6237f8-a7da-11e6--000c29f333f8:-
Auto_Position:
row in set (0.00 sec)
延迟复制:
启用方法:
mysql> stop slave;
mysql> change master to master_delay=;
mysql> start slave;
应用场景:
1.误删除恢复
2.延迟测试(当有延迟时业务是否会受影响)
3.历史查询
***************************
mysql master 配置
[root@centossz008 ~]# cat /etc/my.cnf
[client]
port =
socket = /tmp/mysql.sock
default-character-set = utf8mb4 [mysqld]
port =
innodb_file_per_table =
binlog-format=ROW
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=file
relay-log-info-repository=file
sync-master-info=
slave-parallel-workers=
binlog-checksum=CRC32
master-verify-checksum=
slave-sql-verify-checksum=
binlog-rows-query-log_events=
server-id=
report-port=
log-bin=/data/binlogs/master-bin
max_binlog_size = 200M
datadir=/data/mydata
socket=/tmp/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4 skip-name-resolve
skip-external-locking back_log =
max_connections =
max_connect_errors =
open_files_limit =
table_open_cache =
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size =
query_cache_type =
query_cache_size = 16M
query_cache_limit = 2M
ft_min_word_len =
expire_logs_days =
performance_schema =
explicit_defaults_for_timestamp default_storage_engine = InnoDB
innodb_open_files =
innodb_buffer_pool_size = 64M
innodb_write_io_threads =
innodb_read_io_threads =
innodb_thread_concurrency =
innodb_purge_threads =
innodb_flush_log_at_trx_commit =
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group =
innodb_max_dirty_pages_pct =
innodb_lock_wait_timeout = bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 512M
myisam_repair_threads = interactive_timeout =
wait_timeout = [mysqldump]
quick
max_allowed_packet = 16M [myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
******************
mysql slave 配置
[root@node5 src]# cat /etc/my.cnf
[client]
port =
socket = /tmp/mysql.sock
default-character-set = utf8mb4 [mysqld] port =
innodb_file_per_table =
binlog-format=ROW
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=file
relay-log-info-repository=file
sync-master-info=
slave-parallel-workers=
binlog-checksum=CRC32
master-verify-checksum=
slave-sql-verify-checksum=
binlog-rows-query-log_events=
server-id=
report-port=
log-bin=/data/binlogs/master-bin
relay-log=/data/relaylogs/relay-bin
max_binlog_size = 200M
datadir=/data/mydata
socket=/tmp/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4 skip-name-resolve
skip-external-locking back_log =
max_connections =
max_connect_errors =
open_files_limit =
table_open_cache =
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size =
query_cache_type =
query_cache_size = 16M
query_cache_limit = 2M
ft_min_word_len =
expire_logs_days =
performance_schema =
explicit_defaults_for_timestamp default_storage_engine = InnoDB
innodb_open_files =
innodb_buffer_pool_size = 64M
innodb_write_io_threads =
innodb_read_io_threads =
innodb_thread_concurrency =
innodb_purge_threads =
innodb_flush_log_at_trx_commit =
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group =
innodb_max_dirty_pages_pct =
innodb_lock_wait_timeout = bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 512M
myisam_repair_threads = interactive_timeout =
wait_timeout = [mysqldump]
quick
max_allowed_packet = 16M [myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
*********************
cenos6上启动mysql服务报错:
070517 23:08:52 mysqld_safe Starting mysqld daemon with databases from /data/mydata
2107-05-17 23:08:56 0 [ERROR] This MySQL server doesn't support dates later then 2038
2107-05-17 23:08:56 0 [ERROR] Aborting
将时间修改为1年前,即可启动,启动完成后改回时间即可
percona-xtrabackup工具实现mysql5.6.34的主从同步复制的更多相关文章
- 烂泥:mysql5.5主从同步复制配置
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 在上篇文章<烂泥:学习mysql数据库主从同步复制原理>中,我们介绍了有关mysql主从复制的基本原理.在这篇文章中,我们来实际测试下mys ...
- mysql5.5主从同步复制配置
在上篇文章<烂泥:学习mysql数据库主从同步复制原理>中,我们介绍了有关mysql主从复制的基本原理.在这篇文章中,我们来实际测试下mysql5.5的主从同步复制功能. 注意mysql5 ...
- centos6.6手动安装mysql5.5并配置主从同步
0.实验环境 主机IP(Master) 192.168.61.150 centos6.6 从机IP(Slave) 192.168.61.157 centos6.6 1.查看centos系统版本 [ ...
- 配置mysql5.5主从复制、半同步复制、主主复制
mysql主服务器 192.168.8.40 mysql从服务器 192.168.8.41 全新配置过程(主和从数据库都没有数据): 主从复制主服务器设置: 1.改server-id 2.启 ...
- Percona XtraBackup 关于 MySQL备份还原的详细测试
一. Percona XtraBackup 的优点. (1)无需停止数据库进行InnoDB热备: (2)增量备份MySQL: (3)流压缩传输到其它服务器: (4)在线移动表: (5)能够比较容易地创 ...
- mysql 开发进阶篇系列 44 物理备份与恢复( 热备份xtrabackup 工具介绍)
一.概述 物理备份和恢复又分为冷备份和热备份.与逻辑备份相比,它最大优点是备份和恢复的速度更快.因为物理备份的原理都是基于文件的cp. 1.1 冷备份 冷备份就是停掉数据库服务.这种物理备份一般很少使 ...
- (转)CentOS 7 下 MySQL 5.7 配置 Percona Xtrabackup
CentOS 7 下 MySQL 5.7 配置 Percona Xtrabackup 原文:http://qizhanming.com/blog/2017/05/10/install-percona- ...
- Centos7.5部署MySQL5.7基于GTID主从复制+并行复制+半同步复制+读写分离(ProxySQL) 环境- 运维笔记 (完整版)
之前已经详细介绍了Mysql基于GTID主从复制的概念,原理和配置,下面整体记录下MySQL5.7基于GTID主从复制+并行复制+增强半同步复制+读写分离环境的实现过程,以便加深对mysql新特性GT ...
- Percona Xtrabackup 备份工具
生成备份 $ xtrabackup --backup --target-dir=/data/backups/ 注:--target-dir可以放在my.cnf配置文件中.如果指定的目录不存在,xtra ...
随机推荐
- 原生JavaScript运动功能系列(一):运动功能剖析与匀速运动实现
在我们日常生活中运动就是必不可少的部分,走路.跑步.打篮球等.在网页交互设计上运动也是必不可少的部分,创建的网站交互设计运动模块有轮播图,下拉菜单,还有各种炫酷的游戏效果都跟运动密切相关.所以很重要, ...
- Django聚合与分组查询中value与annotate的顺序问题
在学习Django聚合与分组查询中,发现value与annotate的顺序不同时,查询结果大相径庭,经过一下午的研究,终于弄明白了,现在分享给大家,先上结论: 结论 value在annotate前面时 ...
- 开源框架.netCore DncZeus学习(三)增加一个菜单
框架运行起来了,先尝试增加一个菜单. 本节增加一个菜单名字:公司管理,需要注意一点,所有的name都要保持一致,注意圈中部分.为了防止手敲代码出错,建议复制已有的代代码进行修改(比如这里用的Role页 ...
- CoreText实现图文混排
CoreText的介绍 Core Text 是基于 iOS 3.2+ 和 OSX 10.5+ 的一种能够对文本格式和文本布局进行精细控制的文本引擎.它良好的结合了 UIKit 和 Core Graph ...
- java设计模式之单例模式以及实现的几种方法
java设计模式以及实现的几种方法,看到比较好的博客文章,收藏起来供以后再次阅读.. 参见:http://www.cnblogs.com/garryfu/p/7976546.html
- Java EE之Struts2异常[No mapping found for dependency [type=java.lang.String, name='actionPackages'#java.lang.RuntimeException]【摘抄】
本博文摘自:http://www.blogjava.net/nkjava/archive/2009/03/29/262705.html 出现这个问题,可能是添加了struts2-codebehind包 ...
- Chrome实用技巧集锦
1. 截取整个网页内容: 步骤:(F12 或 Ctrl Shift I 进入开发者模式) ——> Ctrl Shift P 弹出输入框 ——> 输入框中输入:Captrue ful ...
- sublime text 3 3103 注册码
—– BEGIN LICENSE —– Ryan Clark Single User License EA7E-812479 2158A7DE B690A7A3 8EC04710 006A5EEB 3 ...
- 深刻了解jQuery对象和普通DOM对象的区别
深刻了解jQuery对象和普通DOM对象的区别.互相转化见Q1 Q1,js的写法:document.getElementById('save').disabled=true; 在jquery中我是这样 ...
- STL之partition学习
顺便存一下numeric函数的使用方法吧,感觉用处不大. https://blog.csdn.net/baishuo8/article/details/84073565 partition函数,将元素 ...