mysql手动同步_MySql数据库主从手动同步
记录一次主从数据不同步,手动同步;
主库:
[jumpserver@SX-Test-Oracle ~]$ /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ;or\g.
Your MySQL connection idis 35007Server version:5.5.37-log Source distribution
Copyright (c)2000, 2014, Oracle and/orits affiliates. All rights reserved.
Oracleis a registered trademark of Oracle Corporation and/orits
affiliates. Other names may be trademarks of their respective
owners.
Type'help;' or '\h' for help. Type '\c'to clear the current input statement.
mysql>
从库:
[jumpserver@SX-Test-Nginx ~]$ /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ;or\g.
Your MySQL connection idis 14562Server version:5.5.37-log Source distribution
Copyright (c)2000, 2014, Oracle and/orits affiliates. All rights reserved.
Oracleis a registered trademark of Oracle Corporation and/orits
affiliates. Other names may be trademarks of their respective
owners.
Type'help;' or '\h' for help. Type '\c'to clear the current input statement.
mysql>
开始手动同步:
1、在主库上执行,锁定数据库(当前状态可查询,不可插入),查看同步状态
mysql>flush tables with read lock;
Query OK, 0 rows affected (0.01sec)
mysql>show master status;+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000491 | 84843181 | sc,dev | mysql |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
2、在主库服务器上执行,导出当前数据库备份,并拷贝到备库服务器上。
[jumpserver@SX-Test-Oracle ~]$ sudo /usr/local/mysql/bin/mysqldump -uroot -p sc >/tmp/sc.20180801Enter password:
3、在从库上执行,停止从库的同步状态。
mysql>stop slave;
Query OK, 0 rows affected (0.00 sec)
4、在从库上执行,导入主库的备份文件
mysql> source /tmp/sc.20180801Query OK, 0 rows affected (0.00sec)
Query OK, 0 rows affected (0.00sec)
Query OK, 0 rows affected (0.00 sec)
5、在从库上执行,查看从库的状态,并设置从库的同步节点。
从第1步中的主库show master status信息里的| File| Position两项取值
mysql>show slave status;+----------------+---------------+-------------+-------------+---------------+------------------+---------------------+--------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+
| Slave_IO_State | Master_Host | Master_User | Master_Port | Connect_Retry | Master_Log_File | Read_Master_Log_Pos | Relay_Log_File | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | 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 | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | 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 | Last_IO_Errno | Last_IO_Error | Last_SQL_Errno | Last_SQL_Error | Replicate_Ignore_Server_Ids | Master_Server_Id |
+----------------+---------------+-------------+-------------+---------------+------------------+---------------------+--------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+
| | 172.17.23.203 | root | 3306 | 60 | mysql-bin.000491 | 84843181 | SX-Test-Nginx-relay-bin.000002 | 7813930 | mysql-bin.000491 | No | No | sc,dev | | | | | | 0 | | 0 | 84843181 | 7814094 | None | | 0 | No | | | | | | NULL | No | 0 | | 0 | | | 1 |
+----------------+---------------+-------------+-------------+---------------+------------------+---------------------+--------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+
1 row in set (0.00sec)
mysql> change master to master_host ='172.17.23.203',master_user ='root',master_port=3306,master_password='XXXXX',master_log_file ='mysql-bin.000491',master_log_pos=84843181;
Query OK, 0 rows affected (0.05 sec)
6,在从库上执行,开启从库同步
mysql>start slave;
Query OK, 0 rows affected (0.00 sec)
7、在主库上执行,主库解除锁定
mysql>unlock tables;
Query OK, 0 rows affected (0.00 sec)
至此完成了。
mysql手动同步_MySql数据库主从手动同步相关推荐
- mysql数据库主从不同步_mysql数据库主从不同步的解决方法
故障描述: 进入从数据库 mysql> show slave status\G; 结果如下: ... Slave_IO_Running: Yes Slave_SQL_Running: No La ...
- mysql数据没有同步更新_MySQL数据库主从没有同步的两种解决方案
MySQL数据库主从没有同步的两种解决方案 发布时间:2020-05-13 13:54:57 来源:亿速云 阅读:190 作者:三月 栏目:数据库 下文主要给大家带来MySQL数据库主从没有同步的两种 ...
- mysql case默认_MySQL数据库架构和同步复制流程
在分布式系统里面,往往制约整个系统发展的瓶颈点就是数据库,所以数据库的架构和高可用以及数据库的切分都是我们值得花大力气去学习的. 首先我们来说说数据库的架构. 1.mysql主从架构,如图: 这种架构 ...
- mysql 从库_mysql数据库主从配置
在一篇文章<离线安装mysql数据库>,讲解了离线安装mysql数据库的过程,本文将讲解mysql数据库的主从配置方法.mysql数据库进行主从配置后,可以实现数据库的备份.同时应用也可以 ...
- 数据库主从不同步_数据从不说什么
数据库主从不同步 I'm bothered by statements like "Clearly, the data says-" or "It is obvious ...
- mysql设置数据库同步_MySQL数据库配置主从同步
1.环境说明:DB master: 172.16.1.55 DB slave:172.16.1.56 2.Server-id 配置(/etc/my.cnf): 主库配置server-id要比从库的ID ...
- mysql数据库主从同步的原理_mysql数据库主从同步复制原理
MySQL的Replication(英文为复制)是一个多MySQL数据库做主从同步的方案,特点是异步复制,广泛用在各种对MySQL有更高性能.更高可靠性要求的场合.与之对应的是另一个同步技术是MySQ ...
- mysql数据库主从不同步_MySQL数据库之mysql主从数据库不同步的2种解决方法
本文主要向大家介绍了MySQL数据库之mysql主从数据库不同步的2种解决方法 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. 今天发现Mysql的主从数据库没有同步 先上Mas ...
- mysql负载均衡与同步_MySql数据库从同步负载均衡实时备份
如果你对MySql数据库主从同步负载均衡实时的备份,的实际操作步骤感到很是很郁闷时.你就可以浏览下面的文章了,供大家分享. 最近将四台MySQL数据库服务器配置成主从模式以实现一定的负载均衡,好象还可 ...
最新文章
- ViewPager 实现界面加载不同的数据
- cannot import name 'get_all_providers'
- 微信平台开发者:桥梁上的运动员
- boost::test模块类属性工具的单元测试
- 数据挖掘方法案例介绍
- tomcat中关于websocket的性能优化配置
- PrimeFaces Mobile入门
- 用EnumProcesses()枚举进程
- php发送邮件时间间隔,在使用phpmailer群发邮件时如何设置发送的时间间隔?
- postgresql使用pg_rman备份恢复
- x64驱动遍历 DPC 定时器
- 进销存php带bom,进销存erp软件的绝对核心是BOM
- html的个人简历边框,怎样制作简历模板边框
- 全网首发国内联邦学习框架研究
- 微信小程序入门与实战笔记
- python最强脚本工具_python脚本工具最百里自瞄
- 巧用 Linux 定时任务
- 从零带你学Linux
- aav-php,脑洞大开:新型 AAV 帮您实现一步跨越血脑屏障
- 【物联网硬件安全】二、固件分析-固件提取
热门文章
- NETCONF YANG语言文件语法格式
- About 3GPP
- python logging日志分割_python logging日志模块以及多进程日志
- 华为修改优先级命令_华为配置命令大全
- 工信部高级软件工程师证书有用吗_考bim工程师证书有用吗
- Springboot细节挖掘(对web的支持之数据校验)
- nohttp网络框架
- php通过ip地址查询位置,PHP通过IP获取地理位置
- 交换机端口mtu值最大_交换机 MTU
- 代码 纪录 软件_「软件资料」-「资讯动态」-软件开发类项目关键文档内容要求...