我们有一个监控脚本. 很简单类似如下
import pymysql
import time
for i in range(2000):
conn=pymysql.connect(host='192.168.3.xxx',port=16042,user='user',password='pass',db='mysql',charset='utf8',connect_timeout=30)
print(1)
conn.close()
time.sleep(1)
监控连通性
但是最近升级了proxysql2.0后发现总是报错
告警通知
告警标题:192.168.3.xxx:16042 : 访问异常
告警状态:故障中
下发时间:2019-03-15 21:05:52
告警时间:2019-03-15 21:05:51
告警来源:DB
告警级别:普通告警
告警内容:
ping : OK
telnet : OK
connection : fail
select : OK
product :
project :
group_name :
role :
dbname :
dbname_alias:
发送时间:2019-03-15 21:05:52
connection : fail
查看日志,说没权限,这不是扯淡么
Traceback (most recent call last):
File "check_mysql.py", line 161, in check_select
scnn = connection(ip, port, 'user', 'pass', 'mysql', 'utf8')
File "check_mysql.py", line 17, in connection
conn=pymysql.connect(host=h,port=p,user=u,passwd=ps,db=d,charset=c,connect_timeout=5)
File "/usr/local/python3.6.3/lib/python3.6/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/usr/local/python3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 327, in __init__
self.connect()
File "/usr/local/python3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 598, in connect
self._request_authentication()
File "/usr/local/python3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 862, in _request_authentication
auth_packet = self._process_auth(plugin_name, auth_packet)
File "/usr/local/python3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 933, in _process_auth
pkt = self._read_packet()
File "/usr/local/python3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 683, in _read_packet
packet.check_error()
File "/usr/local/python3.6.3/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "/usr/local/python3.6.3/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "ProxySQL Error: Access denied for user 'user'@'192.168.2.xx' (using password: YES)")
2019-03-07 16:20:30 ERROR (1045, "ProxySQL Error: Access denied for user 'user'@'192.168.2.xx' (using password: YES)")
后来搜issue. 发现这个
https://github.com/sysown/proxysql/issues/1934
看了下我们用的正是0.9.2. 升级pymysql到0.9.3后, 告警消失了