mysqldump 的方式来搭建master-->slave 的复制架构
1、master 上要满足的最小条件:
1、server_id 已经设置成了一个非0值
2、log_bin 配置好binlog
2、slave 上要满足的最小条件
1、server_id 已经设置成了一个非0值,而且这个上值还不能与master 上的值一样
3、在master 上执行flush tables with read lock;
mysql> flush tables with read lock;
Query OK, rows affected (0.04 sec) mysql> show master status ;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin. | | | | |
+------------------+----------+--------------+------------------+-------------------+
4、用mysqldump 备份整个实例:
mysqldump -h127.0.0. -uroot --all-database --master-data --single-transaction --routines --events -->/tmp/dbdump.sql
5、备份完成后执行unlock tables;
mysql> flush tables with read lock;
Query OK, 0 rows affected (0.04 sec) mysql> show master status ;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 | 120 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec) mysql> unlock tables;
Query OK, 0 rows affected (0.00 sec) mysql>
6、传输备份文件(/tmp/dbdump.sql)到slave 所在的主机
scp /tmp/dbdump.sql 192.168.80.129:/tmp/dbdump.sql
7、在salve 实例上应用备份文件
mysql </tmp/dbump.sql
8、执行change master to('repl'@%' 是一个在master 已经创建的用户grant replication slave ,replication client on *.* to repl@'%' identified by 'replication')
change master to
master_host='192.168.80.128',
master_port=3306,
master_log_file='mysql-bin.000002',
master_log_pos=120,
master_user='repl',
master_password='replication'; start slave;
9、查看复制的状态是否正常:
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.80.128
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 120
Relay_Log_File: standby-relay-bin.000005
Relay_Log_Pos: 283
Relay_Master_Log_File: mysql-bin.000004
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
mysqldump 的方式来搭建master-->slave 的复制架构的更多相关文章
- mysql (master/slave)复制原理及配置
1 复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台主机的数据复制到其它主机(slaves)上,并重 ...
- Redis的master/slave复制
摘自:Redis的master/slave复制 Redis的master/slave数据复制方式可以是一主一从或者是一主多从的方式,Redis在master是非阻塞模式,也就是说在slave执行数据同 ...
- Windows下搭建MySQL Master Slave
一.背景 服务器上放了很多MySQL数据库,为了安全,现在需要做Master/Slave方案,因为操作系统是Window的,所以没有办法使用keepalived这个HA工具,但是我们可以接受人工进行切 ...
- Windows下搭建MySQL Master Slave[转]
Windows下搭建MySQL Master Slave 一.背景 服务器上放了很多MySQL数据库,为了安全,现在需要做Master/Slave方案,因为操作系统是Window的,所以没有办法使用k ...
- MySQL-Cluster 和主从(Master,Slave)搭建总结
双主互备,主从 什么是双主 MultiSource 多源复制 原理及流程图 主要步骤 1,在 Master Server 上开启 bin log 日志 和 设置 server-id :(在my.cn ...
- 【摘录】JDBC Master Slave(JDBC方式的JMS集群)
JDBC Master Slave First supported in ActiveMQ version 4.1 If you are using pure JDBC and not using t ...
- MySQL master/slave 模式
1 .复制 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台主机的 数据复制到其它主机(slaves)上,并重 ...
- ActiveMQ集群支持Master/Slave模式
现在ActiveMQ, 在Failover方面有两种解决方案:Pure Master Slave和Shared File System Master Slave. 先看Pure Master ...
- Redis master/slave,sentinel,Cluster简单总结
现在互联网项目中大量使用了redis,本文著主要分析下redis 单点,master/slave,sentinel模式.cluster的一些特点. 一.单节点模式 单节点实例还是比较简单的,平时做个测 ...
随机推荐
- [POJ] 2785 4 Values whose Sum is 0(双向搜索)
题目地址:http://poj.org/problem?id=2785 #include<cstdio> #include<iostream> #include<stri ...
- Java BufferedWriter与BufferedReader操作文本文件
/** * 采用字符流读取写入文本文件 */ public class FileUtil { /** * 写文件 * @param fileName * @param content */ publi ...
- 10个经典的Android开源项目(附源码包)
最近在抽空学习Android系统开发,对Android学习也比较感兴趣,刚开始学就试着在网上找几个项目源码研究看下,以下就将找到的Android项目源码列出,希望对正在或准备学习Android系统开发 ...
- LeetCode_Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...
- JavaScrip常规函数
JavaScrip常规函数包括以下8个:alert函数:显示一个警告对话框,包括一个"OK"按钮.confirm函数:显示一个确认对话框,包括一个"OK".&q ...
- ActionBar Fragment运用最佳实践
ActionBar Fragment运用最佳实践
- wikioi1191 数轴染色
题目描述 Description 在一条数轴上有N个点,分别是1-N.一开始所有的点都被染成黑色.接着 我们进行M次操作,第i次操作将[Li,Ri]这些点染成白色.请输出每个操作执行后 剩余黑色点的个 ...
- unix c 01
gcc编译器(代码的 预处理/汇编/编译/连接) C程序员一般写程序会定义 .c和.h两种文件 .c文件(源文件)中一般放代码的实现,.h文件(头文件)中放 各种声明和定义. gcc -E __. ...
- 关于UIButton中的ContentEdgeInsets的深入研究
UIButton的contentEdgeInsets属性的深入研究 由于用UIButton这个属性做过一些东西,但是对它的规律始终不太了解,虽然苹果官方文档的解释大体上可以理解为,这个属性设置的是内边 ...
- OpenStackCLI调试及术语识记
1,Project are organizational units in the cloud,and are also known as tenants or accounts.Each user ...