Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Zugriff auf Cloud SQL-Instanz konfigurieren
In diesem Dokument finden Sie eine detaillierte Anleitung zum Einrichten von Virtual Private Cloud-Peering, zum Installieren eines Cloud SQL-Proxys und zum Herstellen einer Verbindung zu einer internen Cloud SQL-IP-Adresse in verschiedenen Google Cloud Projekten.
Diese Konfiguration sorgt für eine sichere und effiziente Kommunikation zwischen Ihrer Cloud SQL-Instanz und den folgenden Connectors:
Um VPC-Peering einzurichten, müssen Sie VPC-Peering aus dem BigQuery Data Transfer Service-Connector-Projekt erstellen, VPC-Peering im Cloud SQL-Datenbankprojekt zum BigQuery Data Transfer Service-Projekt erstellen und die Routen und Firewallregeln konfigurieren.
VPC-Peering über das BigQuery Data Transfer Service-Connector-Projekt erstellen
Google Cloud Rufen Sie in der Console die Seite VPC-Netzwerk-Peering für Ihr BigQuery Data Transfer Service-Connector-Projekt auf.
Erstellen Sie Firewallregeln, um Traffic auf den erforderlichen Ports (z. B. Port 3306 für MySQL und Port 5432 für PostgreSQL) zwischen den Peering-Netzwerken zuzulassen.
Fügen Sie dem in der Cloud SQL-Datenbank gehosteten Projekt die benutzerdefinierten Firewallregeln hinzu, die vom BigQuery Data Transfer Service-Connector-Projekt benötigt werden.
Konfigurieren Sie Routen und Firewallregeln für Ihr Projekt mit der Cloud SQL-Instanz wie in den vorherigen Schritten.
Cloud SQL-Proxy einrichten
Stellen Sie über SSH eine Verbindung zu einer VM-Instanz im BigQuery Data Transfer Service-Connector-Projekt her.
Laden Sie den Cloud SQL-Proxy im Terminal herunter:
Aktualisieren Sie die Berechtigungen für die heruntergeladenen Dateien:
chmod+xcloud_sql_proxy
Führen Sie den Cloud SQL-Proxy aus:
./cloud_sql_proxy-instances=NAME=tcp:3306or5432&
Ersetzen Sie NAME durch den Namen der Cloud SQL-Instanzverbindung.
Verbindung zur internen Cloud SQL-IP-Adresse herstellen
Verwenden Sie die interne IP-Adresse der Cloud SQL-Instanz für Verbindungen.
Konfigurieren Sie Ihre Anwendung oder Ihr Tool so, dass eine Verbindung zur internen IP-Adresse hergestellt wird. Geben Sie dazu die entsprechenden Anmeldedaten und Datenbankdetails an.
Wenn Sie eine Verbindung von einem anderen Google Cloud -Projekt herstellen, verwenden Sie die interne IP-Adresse der Proxy-VM, die Sie zuvor bereitgestellt haben. Mit dieser Lösung werden Probleme mit transitivem Peering behoben.
Netzwerkanhang erstellen
So erstellen Sie die Netzwerkanhänge im BigQuery Data Transfer Service-Connector-Projekt:
Rufen Sie in der Google Cloud Console die Seite Netzwerkanhänge auf.
Geben Sie einen Namen für die Netzwerkverbindung ein.
Wählen Sie das entsprechende VPC-Netzwerk aus.
Geben Sie unter Region die Region an, in der sich der BigQuery Data Transfer Service-Connector befindet.
Wählen Sie für Subnetzwerk die Option aus, die zu Ihrer Konfiguration passt.
Klicken Sie auf Netzwerkanhang erstellen.
Verbindung testen
Prüfen Sie, ob die VM mit dem Cloud SQL-Proxy eine Verbindung zur Cloud SQL-Instanz herstellen kann:
mysql-uUSERNAME-p-hIP_ADDRESS
Ersetzen Sie Folgendes:
USERNAME: der Nutzername des Datenbanknutzers
IP_ADDRESS: die IP-Adresse der Cloud SQL-Instanz
Achten Sie darauf, dass Anwendungen im Connector-Projekt für BigQuery Data Transfer Service eine Verbindung über die interne IP-Adresse zur Cloud SQL-Instanz herstellen können.
Fehlerbehebung
Wenn Sie Probleme bei der Einrichtung Ihrer Netzwerkkonfiguration haben, gehen Sie so vor:
Prüfen Sie, ob das VPC-Peering eingerichtet ist und die Routen richtig konfiguriert sind.
Prüfen Sie, ob die Firewallregeln Traffic auf den erforderlichen Ports zulassen.
Prüfen Sie die Cloud SQL-Proxy-Logs auf Fehler und achten Sie darauf, dass der Proxy richtig ausgeführt wird.
Prüfen Sie, ob das Netzwerkgerät richtig konfiguriert und verbunden ist.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-17 (UTC)."],[[["\u003cp\u003eThis guide details how to configure secure access to a Cloud SQL instance from the BigQuery Data Transfer Service across separate Google Cloud projects using Virtual Private Cloud (VPC) peering.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves setting up VPC peering from both the BigQuery Data Transfer Service connector project and the Cloud SQL database project, ensuring proper route configuration, and creating firewall rules.\u003c/p\u003e\n"],["\u003cp\u003eSetting up the Cloud SQL proxy on a virtual machine (VM) within the BigQuery Data Transfer Service connector project is necessary for connecting to the internal Cloud SQL IP address.\u003c/p\u003e\n"],["\u003cp\u003eA network attachment needs to be created in the BigQuery Data Transfer Service connector project, specifying the appropriate VPC network, region, and subnetwork.\u003c/p\u003e\n"],["\u003cp\u003eAfter configuration, the guide emphasizes the importance of testing the connection to ensure that the VM hosting the Cloud SQL proxy can reach the Cloud SQL instance and that applications within the BigQuery Data Transfer Service project can connect using the internal IP.\u003c/p\u003e\n"]]],[],null,["# Configure Cloud SQL instance access\n===================================\n\nThis document provides detailed steps for setting up Virtual Private Cloud peering,\ninstalling a Cloud SQL proxy, and connecting to an internal\nCloud SQL IP address across different Google Cloud projects.\nThis setup ensures security-enhanced and efficient communication between your\nCloud SQL instance and the following connectors:\n\n- [The BigQuery Data Transfer Service MySQL connector](/bigquery/docs/mysql-transfer)\n- [The BigQuery Data Transfer Service PostgreSQL connector](/bigquery/docs/postgresql-transfer).\n\nThis document also covers the creation of a network attachment in the\nBigQuery Data Transfer Service connector project.\n\nBefore you begin\n----------------\n\nEnsure you have the following:\n\n- Access to a Google Cloud project with the BigQuery Data Transfer Service connector and another Google Cloud project with the Cloud SQL instance.\n- An existing MySQL or PostgreSQL database in a Google Cloud project.\n- The appropriate permissions to [create a VPC](/vpc/docs/create-modify-vpc-networks), [create firewall rules](/network-connectivity/docs/vpn/how-to/configuring-firewall-rules), and install software.\n- A [virtual machine (VM) instance](/compute/docs/instances/create-start-instance).\n\nSet up VPC peering\n------------------\n\nTo set up VPC peering, you must create VPC\npeering from the BigQuery Data Transfer Service connector\nproject, create VPC peering in the Cloud SQL database\nproject to the BigQuery Data Transfer Service project, and configure the routes and\nfirewall rules.\n\n### Create VPC peering from the BigQuery Data Transfer Service connector project\n\n1. In the Google Cloud console, go to the **VPC network peering** page for your\n BigQuery Data Transfer Service connector project.\n\n [Go to VPC Network Peering](https://console.cloud.google.com/networking/peering/list)\n2. Click add **Create peering connection**.\n\n3. In the **Name** field, enter a name for your peering configuration.\n\n4. For **Your VPC network**, select the VPC network that you want\n to peer in the BigQuery Data Transfer Service connector project.\n\n5. For **Peered VPC network** , select the **In another project** option.\n\n6. For **Project ID**, enter the project ID of the Cloud SQL\n project.\n\n7. For **VPC network name**, enter the name of the VPC network\n in the Cloud SQL project.\n\n8. Click **Create**.\n\n### Create VPC peering in the Cloud SQL database project\n\nTo create VPC peering in the Cloud SQL database project\nto the BigQuery Data Transfer Service project, do the following:\n\n1. In the Google Cloud console, go to the **VPC Network Peering** page for your\n BigQuery Data Transfer Service connector project.\n\n [Go to VPC Network Peering](https://console.cloud.google.com/networking/peering/list)\n2. Click add **Create peering connection**.\n\n3. In the **Name** field, enter a name for your peering configuration.\n\n4. Select the VPC network that you want to peer in the\n Cloud SQL database project.\n\n5. For **Peer project ID**, enter the project ID of the\n BigQuery Data Transfer Service project.\n\n6. For **Peered VPC network**, enter the name of the VPC network\n in the BigQuery Data Transfer Service connector project.\n\n7. Click **Create**.\n\n### Configure routes and firewall rules\n\nIf you didn't select import-export routes while configuring the peering\nconnections earlier, follow these steps to do so now:\n\n1. Go to the **Routes** page for your BigQuery Data Transfer Service\n connector project.\n\n [Go to Routes](https://console.cloud.google.com/networking/routes/list)\n2. Ensure the routes exist to allow traffic between the peered VPC\n environments.\n\n3. Go to the **Firewall policies** page.\n\n [Go to Firewall policies](https://console.cloud.google.com/networking/firewalls/list)\n4. Create firewall rules to allow for traffic on the necessary ports (for\n example, port 3306 for MySQL and port 5432 for PostgreSQL)\n between the peered networks.\n\n5. Add the custom firewall rules that are required from the BigQuery Data Transfer Service\n connector project to the Cloud SQL database-hosted\n project.\n\n6. Configure routes and firewall rules for your project with the\n Cloud SQL instance as you did in the previous steps.\n\nSet up the Cloud SQL proxy\n--------------------------\n\n1. Use SSH to connect to a virtual machine (VM) instance in the\n BigQuery Data Transfer Service connector project.\n\n2. In the terminal, download the Cloud SQL proxy:\n\n wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy\n\n3. Update the permissions for the downloaded files:\n\n chmod +x cloud_sql_proxy\n\n4. Run the Cloud SQL proxy:\n\n ./cloud_sql_proxy -instances=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nv\"\u003eNAME\u003c/span\u003e\u003c/var\u003e=tcp:3306 or 5432 &\n\n Replace \u003cvar translate=\"no\"\u003eNAME\u003c/var\u003e with the name of your\n Cloud SQL instance connection.\n\nConnect to the internal Cloud SQL IP address\n--------------------------------------------\n\n1. Use the internal IP address of the Cloud SQL instance for connections.\n2. Configure your application or tool to connect to the internal IP address, specifying the appropriate credentials and database details.\n\nWhen connecting from a different Google Cloud project, use the internal\nIP address of the proxy VM that you deployed earlier. This solution resolves\ntransitive peering issues.\n\nCreate the network attachment\n-----------------------------\n\nTo create the network attachment in the BigQuery Data Transfer Service connector\nproject, follow these steps:\n\n1. In the Google Cloud console, go to the **Network attachments** page.\n\n [Go to Network attachments](https://console.cloud.google.com/net-services/psc/list/networkAttachments)\n2. Click add **Create network attachment**.\n\n3. Provide a name for the network attachment.\n\n4. Select the appropriate VPC network.\n\n5. For **Region**, specify the region where your BigQuery Data Transfer Service connector is located.\n\n6. For **Subnetwork**, select the appropriate option that matches your setup.\n\n7. Click **Create network attachment**.\n\nTest the connection\n-------------------\n\n1. Verify that the VM with the Cloud SQL proxy can connect to the\n Cloud SQL instance:\n\n mysql -u \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e -p -h \u003cvar translate=\"no\"\u003eIP_ADDRESS\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: the username of the database user\n - \u003cvar translate=\"no\"\u003eIP_ADDRESS\u003c/var\u003e: the IP address of the Cloud SQL instance\n2. Ensure that applications in the BigQuery Data Transfer Service connector\n project can connect to the Cloud SQL instance using the internal IP.\n\nTroubleshoot\n------------\n\nIf you are having issues setting up your network configuration, do the following:\n\n- Ensure that VPC peering is established and that routes are correctly configured.\n- Verify that the firewall rules allow for traffic on the required ports.\n- Check the Cloud SQL proxy logs for errors and ensure it is running correctly.\n- Ensure that the network attachment is correctly configured and connected."]]