当源数据库位于 Google Cloud 外部且具有外部可访问的 IPv4 地址和 TCP 端口时,最适合使用公共 IP 连接。 Google Cloud如果源数据库托管在 Google Cloud中的其他 VPC 中,则将源数据库与 Cloud SQL 实例连接的最简单方法是使用 VPC 对等互连。
如果源数据库位于 Google Cloud外部,则将目标数据库的出站 IP 地址(和端口 5432)添加为来源网络上的入站防火墙规则。一般来说(您的特定网络设置可能不同),请执行以下操作:
打开源数据库机器的网络防火墙规则。
创建入站规则。
将规则类型设置为 PostgreSQL。
将协议设置为 TCP。
将端口范围设置为 5432。
将来源 IP 地址设置为目标数据库的出站 IP 地址。例如 12.20.36.126/32。(CIDR 表示法中的 /32 指定会将地址范围限制为仅包含一个地址,即所提供的地址。它会将子网掩码设置为 255.255.255.255)。如果您创建的 Cloud SQL 实例是高可用性实例,请添加主实例和次要实例的传出 IP 地址。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-04-17。"],[[["Public IP connectivity is suitable for source databases external to Google Cloud with an accessible IPv4 address and TCP port."],["For source databases in another Google Cloud VPC, VPC Peering is the recommended method to connect to the Cloud SQL instance."],["When the source database is external, an inbound firewall rule must be created on the source network, allowing the destination database's outgoing IP address and port 5432."],["The outgoing IP address for a Cloud SQL instance can be found on the SQL Instances page in the Google Cloud Console."],["It's highly recommended to use SSL/TLS for the source connection profile to ensure secure data transmission."]]],[]]