查看mysql半杯_如何通过show slave status的输出使用change master to命令 | 半瓶
在MySQL的master-slave或dual master的架构中,要重新开始复制可以使用change master to命令,而参数的选择可以来自简单的show slave status命令,举例说明如下:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: 192.168.2.216
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: bin.000001
Read_Master_Log_Pos: 2218353
Relay_Log_File: relaylog.000003
Relay_Log_Pos: 4
Relay_Master_Log_File: bin.000001
Slave_IO_Running: Connecting
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,performance_schema,information_schema
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 2218353
Relay_Log_Space: 107
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 2003
Last_IO_Error: error connecting to master ‘repl@192.168.2.216:3306′ – retry-time: 60 retries: 86400
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
1 row in set (0.00 sec)mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: 192.168.2.216
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: bin.000001
Read_Master_Log_Pos: 2218353
Relay_Log_File: relaylog.000003
Relay_Log_Pos: 4
Relay_Master_Log_File: bin.000001
Slave_IO_Running: Connecting
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,performance_schema,information_schema
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 2218353
Relay_Log_Space: 107
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 2003
Last_IO_Error: error connecting to master ‘repl@192.168.2.216:3306′ – retry-time: 60 retries: 86400
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
1 row in set (0.00 sec)
我们看到这个库无法和Master数据库连接了,这时可以先停掉复制:mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
我们都知道目前MySQL的版本slave端是通过2个线程实现复制的,一个是I/O Thread负责连接到master接收binlog信息,在从服务器端这部分信息叫做relay log。另一个SQL Thread负责读取relay log并执行其中的event(在statement format的时候其实就是SQL语句)。这从以上输出的信息也能看出来,IO线程在连接但是连不上,而SQL线程正在执行:Slave_IO_Running: Connecting
Slave_SQL_Running: Yes
接下来我们再用change master to命令修改连接参数和复制起始点,其中重要的MASTER_LOG_FILE和MASTER_LOG_POS参数,这两个参数对应的是IO线程生成relay log的信息,因此和Relay_Master_Log_File和Exec_Master_Log_Pos是对应的,具体命令如下:mysql> CHANGE MASTER TO
-> MASTER_HOST=’192.168.0.35′,
-> MASTER_PORT = 3306,
-> MASTER_USER=’banping_repl’,
-> MASTER_PASSWORD=’slavepassword’,
-> MASTER_LOG_FILE=’bin.000001′,
-> MASTER_LOG_POS=2218353;
Query OK, 0 rows affected (0.00 sec)
然后再开始复制:mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
再查看slave的状态:mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.35
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: bin.000002
Read_Master_Log_Pos: 1819899
Relay_Log_File: relaylog.000003
Relay_Log_Pos: 76625
Relay_Master_Log_File: bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,performance_schema,information_schema
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 76485
Relay_Log_Space: 1820328
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 50236
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
1 row in set (0.00 sec)
可见已经恢复了复制。完整的命令如下:
CHANGE MASTER TO option [, option] ...
option:
MASTER_HOST = 'host_name'
| MASTER_USER = 'user_name'
| MASTER_PASSWORD = 'password'
| MASTER_PORT = port_num
| MASTER_CONNECT_RETRY = interval
| MASTER_HEARTBEAT_PERIOD = interval
| MASTER_LOG_FILE = 'master_log_name'
| MASTER_LOG_POS = master_log_pos
| RELAY_LOG_FILE = 'relay_log_name'
| RELAY_LOG_POS = relay_log_pos
| MASTER_SSL = {0|1}
| MASTER_SSL_CA = 'ca_file_name'
| MASTER_SSL_CAPATH = 'ca_directory_name'
| MASTER_SSL_CERT = 'cert_file_name'
| MASTER_SSL_KEY = 'key_file_name'
| MASTER_SSL_CIPHER = 'cipher_list'
| MASTER_SSL_VERIFY_SERVER_CERT = {0|1}
| IGNORE_SERVER_IDS = (server_id_list)
查看mysql半杯_如何通过show slave status的输出使用change master to命令 | 半瓶相关推荐
- php查看mysql连接数_查看mysql当前连接数
1.查看当前所有连接的详细资料: mysqladmin -uroot -proot processlist D:\MySQL\bin>mysqladmin -uroot -proot proce ...
- 怎么查看mysql密码_怎么查看mysql密码
MySQL数据库查看密码的方法如下: 以系统管理员身份运行cmd. 查看mysql是否已经启动,如果已经启动,就停止:net stop mysql. 切换到MySQL安装路径下:D:\WAMP\MyS ...
- idea查看mysql版本号_如何查看 mysql 的版本号
方式一:通过MySQL命令行 在命令行登录 mysql,即可看到 mysql 的版本号.如下:C:\Users\Administrator>mysql -u root -p Enter pass ...
- 怎么使用命令行查看mysql版本号_查看MySql版本号命令
查看MySql版本号命令 这里介绍四中不同的方法,它们分别运行在不同的环境中,最后对每种方法的优劣以及使用范围也做了总结. 1.直接在操作系统命令行下执行:MySQL –V C:>MySQL ...
- navicat 查看mysql版本_查看mysql的版本号
1.1 在命令行登录mysql,即可看到mysql的版本号 [root@heyong ~]# mysql -uroot -p Enter password: Welcome to the MySQL ...
- 阿里云查看mysql版本_查看mysql版本
{"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],&q ...
- centos 查看mysql 服务器配置_在CentOS上MySQL数据库服务器配置方法
http://www.jb51.net/article/23255.htm ======================== 1 . 无密码登录: mysql -u root 在已经有密码的情况下报错 ...
- 阿里云查看mysql版本_查看mysql版本的四种方法及常用命令
[shengting@login ~]$ mysql -V mysql Ver 14.7 Distrib 4.1.10a, for redhat-linux-gnu (i686) 2:在mysql中: ...
- 查看mysql 内核_如何查看和更新数据库内核小版本
{"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],&q ...
最新文章
- 关于学习Python的一点学习总结(12->字典相关操作)
- IP地址不够了,有办法吗?
- 用Spotlight on windows 实时监控Windows服务器性能
- 实例教程七:在SQLite中使用事务
- python 学习 我推荐这本书,适合特别没有程序基础或者编程思维较差的人,
- 【LeetCode之C#解法】 移动零、爬楼梯
- linux vfs open函数,Linux VFS中open系统调用实现原理
- ASP.NET企业开发框架IsLine FrameWork系列之十五--框架配置信息大全(下)
- 解封装(八):av_seek_frame改变播放进度函数
- python制作动态的微信个人名片
- 我也来开发2048之终极奥义
- Qt进行CSV文件操作
- 爬虫:爬取豆果网和美食网的菜单
- 什么是无线WIFI空口
- 宇宙飞机(space plane)
- 国税总局增值税发票查验平台验证码识别深度学习实战
- 2022新版海螺影视主题模板M3.1版本多功能苹果CMSv10后台自适应模板详解
- 【使用zookpeer】模拟 hadoop的 datenode与namenode 的master-slaves的 关系
- 解决32G或64G的SD卡无法使用NOOBS安装树莓派的问题
- css——三角形的实现
热门文章
- 让你提前认识软件开发(40):既要写好代码,又要写好文档
- 分享一个在线的HTML5元素在线测验 : HTML5 Element Quiz
- CCF NOI1011 正方形
- hann function
- 生活中的数学 —— 操场几何学
- C Tricks(八)—— 硬币和骰子的模拟
- vs2013 也能重构(refactor )变量名了
- matlab控制图像的边界(margin),subplot的间距(gap)
- WPS怎么统计相同名称的数据_群发邮件平台的数据统计怎么用
- python3.6.5安装步骤-Centos7 安装Python3.6.5