简体   繁体   English

无法连接到MariaDB

[英]Can't connect to MariaDB

So I have two AWS servers in question, one is running MariaDB and the other is my API server (python based). 因此,我有两台有问题的AWS服务器,一台正在运行MariaDB,另一台是我的API服务器(基于python)。 I can connect just fine locally on the MariaDB server as well as my dev computer. 我可以在MariaDB服务器和我的开发计算机上本地正常连接。 I cannot connect from the API server nor a third AWS server. 我无法通过API服务器或第三个AWS服务器进行连接。

netstat output netstat输出

Proto Recv-Q Send-Q Local Address           Foreign Address         State        PID/Program name
tcp        0      0 *:mysql                 *:*                     LISTEN      1363/mysqld 

ngrep on API server shows API服务器上的ngrep显示

interface: eth0 (10.[api ip]/255.255.255.0)
filter: (ip or ip6) and ( port 3306 )
##########

ngrep on Maria Server Maria Server上的ngrep

interface: eth0 ([maria ip]/255.255.255.0)
filter: (ip or ip6) and ( port 3306 )
####
T [maria ip]:3306 -> [dev ip]:2392 [AP]
[redacted]                                                                                           
##
T [dev ip]:2392 -> [maria ip]:3306 [AP]
[redacted]
##
T [maria ip]:3306 -> [dev ip]:2392 [AP]
[redacted]                                                                                                
#######################

Eventually I get this error 最终我得到这个错误

ERROR 2003 (HY000): Can't connect to MySQL server on '[maria ip]' (110 "Connection timed out")

or from my python script 或者从我的python脚本

Exception happened during processing of request from ('127.0.0.1', 50110)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__
self.finish()
  File "/usr/lib/python2.7/SocketServer.py", line 710, in finish
self.wfile.close()
  File "/usr/lib/python2.7/socket.py", line 279, in close
self.flush()
  File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
----------------------------------------

Before somebody mentions it, my IP tables are set correctly and AWS SecGrps are not the issue either. 在有人提到它之前,我的IP表已正确设置,并且AWS SecGrps也不是问题。

This is not a duplicate of Trying to connect to remote MySQL host (error 2003) as (1) there are no (logical) devices between the server, (2) I can connect from my Dev station on the other side of the country, and (3) none of the "fixes" worked. 这与尝试连接到远程MySQL主机(错误2003)不是重复的,因为(1)服务器之间没有(逻辑)设备,(2)我可以从该国另一侧的Dev站进行连接, (3)这些“修复”均无效。

Also I can connect from API script to Redis Server running on my maria server. 另外,我可以从API脚本连接到在我的maria服务器上运行的Redis Server。

I think you have to follow these steps as below: 我认为您必须按照以下步骤操作:

  1. Allow remote connect on MariaDB AWS server on 3306 port (depend on your config) 允许在3306端口上的MariaDB AWS服务器上进行远程连接(取决于您的配置)
  2. Check the Firewall (Security Group --> Inbound setting) on your Maria AWS server, this server have to allow access via 3306 port from IP address of API Server. 检查您的Maria AWS服务器上的防火墙(安全组->入站设置),该服务器必须允许通过API服务器IP地址的3306端口进行访问。
  3. Check the Firewall (Security Group --> Oubound setting. By default AWS server allow all ports) on your API AWS server. 检查API AWS服务器上的防火墙(安全组-> Oubound设置。默认情况下,AWS服务器允许所有端口)。

Reference @ http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html 参考@ http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM