python slave status 2
#!/usr/bin/env python
import MySQLdb
import contextlib
@contextlib.contextmanager
def mysql(Host,Port,User,Password,Database):
conn = MySQLdb.connect(host=Host, port=Port, user=User, passwd=Password, db=Database)
#cursor = conn.cursor()
cursor = conn.cursor(MySQLdb.cursors.DictCursor);
try:
yield cursor;
finally:
conn.commit();
cursor.close();
conn.close();
def execSql(excelSql):
hosts = {0:{"host":"192.168.1.140","port":3306,"user":"root","Password":"123456","database":"test"},
1:{"host":"192.168.1.141","port":3306,"user":"root","Password":"123456","database":"test"}}
for idx in hosts:
#print(hosts[idx]["host"])
ip = hosts[idx]["host"]
port = hosts[idx]["port"]
user = hosts[idx]["user"]
password = hosts[idx]["Password"]
database = hosts[idx]["database"]
with mysql(ip,port,user,password,database) as cursor:
sql = excelSql
cursor.execute(sql)
rows = cursor.fetchall()
if len(rows)>0:
Master_Host = rows[0]["Master_Host"]
SQL_THREAD = rows[0]["Slave_SQL_Running"]
IO_THREAD = rows[0]["Slave_IO_Running"]
LAST_ERROR= rows[0]["Last_Error"]
Slave_SQL_RunStatus= rows[0]["Slave_SQL_Running_State"]
Master_InforStatus = rows[0]["Master_Info_File"]
print("-------DataServer:%s------" % ip)
print("relp Master Host: %s" % Master_Host)
print("repl SQL Thread: %s" % SQL_THREAD)
print("repl IO Thread: %s" % IO_THREAD)
print("Mrepl Last error: %s" % LAST_ERROR)
print("Slave SQLRunStatus: %s" % Slave_SQL_RunStatus)
print("Master_InfoStatus: %s" % Master_InforStatus)
print("\n")
if __name__ == "__main__":
sql = "show slave status"
execSql(sql)
python slave status 2的更多相关文章
- Python执行show slave status输出的两个格式
1.元组的方式 输出格式如下: ('Waiting for master to send event', '10.75.19.79', 'mysqlsync', 5580L, 60L, 'mysql- ...
- python show slave status
#!/usr/bin/env python import MySQLdbimport contextlib @contextlib.contextmanagerdef mysql(Host,Port, ...
- show master/slave status求根溯源
show master/slave status分别是查看主数据库以及副数据库的状态,是一种能查看主从复制运行情况的方式. 这里仅仅讨论linux下的nysql5.7.13版本的执行情况 一.show ...
- 两主机搭建MySQL主从复制后,show slave status显示:Last_IO_Error: error connecting to master ……
两台主机A.B搭建mysql主从复制关系(A为master,B为slave)后,在slave上执行show slave status,结果中显示Last_IO_Error: error connect ...
- 从show slave status 中判断mysql同步状态
slave status 中检查同步状态: 1.sql线程和io线程显示yes Slave_IO_Running: Yes Slave_SQL_Running: Yes 2. Master_Log_F ...
- show slave status中的log_file / log_pos
在MySQL的master-slave或dual master的架构中,我们经常使用show slave status命令来查看复制状态. 这里涉及几个重要的日志文件和位置: Master_Log_F ...
- mysql----show slave status \G 说明
show slave status \G 可以用来查看mysql 的复制状态,有些列名所表达的意思不太明确,现整理如下: 1. Slave_IO_State:ID线程的状态,如果master 的所有变 ...
- [置顶] 两主机搭建MySQL主从复制后,show slave status显示:Last_IO_Error: error connecting to master ……
两台主机A.B搭建mysql主从复制关系(A为master,B为slave)后,在slave上执行show slave status,结果中显示Last_IO_Error: error connect ...
- MySQL show master / slave status 命令参数
一.show master status 二.show slave status Slave_IO_State SHOW PROCESSLIST输出的State字段的拷贝.SHOW PROCESSLI ...
随机推荐
- 微软Power BI 每月功能更新系列——3月Power BI 新功能学习
本月对Power BI Desktop 来讲是非常令人兴奋的一个月!!!以下是3月份最新的功能,下面马上带领大家看看本月的更新内容. 报表功能 报告页面工具提示(预览) 通过报告页面工具提示功能,可 ...
- go服务运行框架go-svc
go-svc:https://github.com/judwhite/go-svc/svc go-svc支持linux和windows,应用只需实现Service接口即可. 官方例子 package ...
- Unity 项目中委托Delegate用法案例
Unity中Delegate的用法场景 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar - ...
- HihoCoder - 1807:好的数字串 (KMP DP)
Sample Input 6 1212 Sample Output 298 给定一个数字字符串S,如果一个数字字符串(只包含0-9,可以有前导0)中出现且只出现1次S,我们就称这个字符串是好的. 例如 ...
- day01计算机组成与操作系统
1.什么是编程语言编程语言是程序员与计算机之间的沟通介质 2.什么是编程编程的过程就是程序员通过某种语言将命令给到计算机并让计算机表达出来 修改后:编程就是程序员按照某种语法规则将自己想让计算机做的事 ...
- Ubuntu下安装JDK图文教程详解 jdk-java6-30 .bin 的处理方法
Ubuntu下安装JDK图文教程详解 jdk-java6-30 .bin 的处理方法: https://blog.csdn.net/mingjie1212/article/details/485250 ...
- linux系统lnmp环境包搬家教程
打包搬家apt-get install zip unzip -yyum install zip unzip -y# debian ubuntu 用apt-get,centos用yumcd /home/ ...
- 每天进步一点点- 资源与URI(吐血精华总结)
1.资源(Resources) 每一个URI代表一种资源这句话的理解 ***************************************************************** ...
- jvm系列(1):JVM问答
一:JVM基础知识 1)Java 是如何实现跨平台的? 注意:跨平台的是 Java 程序,而不是 JVM.JVM 是用 C/C++ 开发的,是编译后的机器码,不能跨平台,不同平台下需要安装不同版本的 ...
- hasura graphql-engine v1.0.0-alpha30 版本新功能介绍
hasura graphql-engine v1.0.0-alpha30 发布了,以下为一些变动的简单说明 破坏性的变动 order_by 中的desc 从 desc nulls last 修改为 d ...