python show slave status
#!/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 show slave status的更多相关文章
- Python执行show slave status输出的两个格式
1.元组的方式 输出格式如下: ('Waiting for master to send event', '10.75.19.79', 'mysqlsync', 5580L, 60L, 'mysql- ...
- python slave status 2
#!/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 ...
随机推荐
- easyUI 下拉组件转义
<labelclass="label"for="belongWidget">归属组件:</label> <inputid=&quo ...
- 河工大第十届ACM省赛随笔
比赛成果达到了预期目标,不过还是很遗憾没有更进一步,刚到河工大的时候就想吐槽,拥挤的机房,难受的键盘鼠标,还有规定食堂的,饭票.一切都和河大比赛是给我的感觉不一样,再加上热身赛的那天我背着一大包东西, ...
- AMAZON数据集
http://snap.stanford.edu/data/amazon/productGraph/categoryFiles/
- 微信小程序--扫描二维码
场景---在微信中扫描朋友发来的二维码后进入小程序,其实那个地址是带有参数的,那么如何接收那个参数呢,其实就是进入小程序页面的onLoad生命周期行数的options参数里面.
- 【leetcode】344. Reverse String
problem 344. Reverse String solution: class Solution { public: void reverseString(vector<char> ...
- Python之路PythonNet,第一篇,网络1
pythonnet 网络1 ARPAnet(互联网雏形)---> 民用 ISO(国际标准化组织)--->网络体系结构标准 OSI模型 OSI : 网络信息传输比较复杂需要很多功能协同 ...
- 【转&改进】Linux MPI 单机配置
MPI的全称是Message Passing Interface即标准消息传递界面,可以用于并行计算.MPI有多种实现版本,如MPICH, CHIMP以及OPENMPI.这里我们采用MPICH版本. ...
- SQLI DUMB SERIES-1
less-1 (1) 可以看到提示输入ID,而且less-1题目也有提到GET,因此试试以下操作: http: 结果: http: 结果: 现在可知,“ ' ”并没有被过滤,因此可以进行以下操作: h ...
- 2017年秋软工-PSP总结报告
一.回顾1 回顾本学期第一次作业[https://edu.cnblogs.com/campus/nenu/SWE2017FALL/homework/876]. ==>本学期我的第一次作业博客[h ...
- 小白python 安装
小白python 安装: https://blog.csdn.net/qq_36667170/article/details/79275605 https://blog.csdn.net/nmjuzi ...