简体   繁体   English

Google Cloud - 无法使用内部 IP 从 GKE 连接到 MySQL 云 sql 实例

[英]Google Cloud - Cant connect to MySQL cloud sql instance from GKE using internal IP

I am trying to migrate to use private IP:s for all our Cloud SQL instances.我正在尝试迁移以将私有 IP:s 用于我们所有的 Cloud SQL 实例。 I have gotten it working for postgres, and am now trying to get access for our wordpress instances using MySQL.我已经让它为 postgres 工作了,现在我正在尝试使用 MySQL 访问我们的 wordpress 实例。

The problem is I cant get the connection working from the running pods in our GKE cluster.问题是我无法通过 GKE 集群中正在运行的 pod 建立连接。

root@******:/var/www/app# mysql --host=10.**.**.* -u *_se -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '10.*.*.*' (110 "Connection timed out") 

I have activated the private IP on the Cloud SQL instance, and added a private service connection to the VPC-network that is the same network that our cluster uses, but still cant connect in the same way as I did with postgres.我已经激活了 Cloud SQL 实例上的私有 IP,并在 VPC 网络中添加了一个私有服务连接,该网络与我们的集群使用的网络相同,但仍然无法像使用 postgres 那样连接。

Does anyone know anything I could try to get this working?有谁知道我可以尝试让这个工作吗?

  • There are specific network requirements Cloud SQL instances must adhere to when communicating via a private connection.通过专用连接进行通信时,Cloud SQL 实例必须遵守特定的网络要求。 One of which is that your Cloud SQL and GKE instances are located in the same region and VPC network.其中之一是您的 Cloud SQL 和 GKE 实例位于同一区域和 VPC 网络中。 Check this to configure private IP for MySQL.选中此项为 MySQL 配置私有 IP。
  • The GKE cluster must be VPC-native and peered with the same VPC network as the Cloud SQL instance. GKE 集群必须是 VPC 原生的,并且与 Cloud SQL 实例具有相同的 VPC 网络。 To connect MySQL from GKE, refer to this Google documentation .要从 GKE 连接 MySQL,请参阅此 Google 文档

Note : If you are using shared VPC networks, you cannot assign a private IP address in a shared VPC network to an existing Cloud SQL instance.注意:如果您使用共享 VPC 网络,则无法将共享 VPC 网络中的私有 IP 地址分配给现有 Cloud SQL 实例。 Also, VPC Network Peering uses private services access.此外,VPC 网络对等互连使用私有服务访问。 However, you do not create the VPC Network Peering explicitly, because the peering is internal to Google Cloud.但是,您没有明确创建 VPC 网络对等互连,因为对等互连是 GCP 内部的。

  • Some possible causes of mentioned error are as follows:上述错误的一些可能原因如下:
  1. Network failure especially if MySQL database server is running on a remote host.网络故障,尤其是当 MySQL 数据库服务器在远程主机上运行时。
  2. No MYSQL server is running on the mentioned host.上述主机上没有运行 MYSQL 服务器。
  3. Firewall blocking TCP-IP connection or other related reasons.防火墙阻止 TCP-IP 连接或其他相关原因。

I would suggest you check the firewall setting and check if your MySQL server is listening on default port 3306. Also try to connect MySQL server on IP for which MySQL server is bound in 'my.cnf'.我建议您检查防火墙设置并检查您的 MySQL 服务器是否正在侦听默认端口 3306。同时尝试在 MySQL 服务器绑定在“my.cnf”中的 IP 上连接 MySQL 服务器。 If it not so, run the following command to bind address if you are using Ubuntu:如果不是这样,如果您使用的是 Ubuntu,请运行以下命令来绑定地址:

               1. Run the command  vim /etc/mysql/my.cnf or vim /etc/mysql/mysqld.conf/mysqld.cnf
               2. Comment bind-address = <Server IP> using the # symbol
               3. Restart your MYSQL server once.

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

相关问题 如何使用 Python 和私有 IP 从 GKE 连接到 Cloud SQL - How to connect from GKE to Cloud SQL using Python and Private IP 无法使用 Spring-Boot 应用程序从 GKE 连接到 Cloud SQL (MySQL) - Not able to connect to Cloud SQL (MySQL) from GKE using a Spring-Boot application 从 GKE pod 查询 Node.js 中的 Google 云 SQL 实例,云 sql 代理作为边车运行 - Query a Google cloud SQL instance in Node.js from a GKE pod with cloud sql proxy running as sidecar 使用IP连接到Cloud SQL - Connect to Cloud SQL using IP MySQL 连接到谷歌云 SQL 实例语法错误 - MySQL connect to Google Cloud SQL instance syntax error 无法将MySQL Workbench连接到Google Cloud SQL实例 - Unable to connect MySQL Workbench to Google Cloud SQL instance 我无法使用内部 IP 从另一个实例连接到在 Google Compute 引擎上运行的 mysql 服务器 - I am not able to connect to mysql server running on Google Compute engine from another instance using internal IP 无法使用客户端mysql CL工具连接到Google Cloud SQL实例 - Unable to connect to Google Cloud SQL instance using a client mysql CL tool 从本地运行的 NodeJS / TypeORM 连接到 Google Cloud MySQL 实例 - Connect to Google Cloud MySQL instance from local running NodeJS / TypeORM Google App Engine-使用mysqli用php连接到SQL Cloud实例 - Google App Engine - Connect to SQL Cloud Instance with php using mysqli
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM