Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Configurare l'accesso alle istanze Cloud SQL
Questo documento fornisce i passaggi dettagliati per configurare il peering Virtual Private Cloud, installare un proxy Cloud SQL e connettersi a un indirizzo IP Cloud SQL interno in diversi progetti. Google Cloud
Questa configurazione garantisce una comunicazione efficiente e con una maggiore sicurezza tra l'istanza Cloud SQL e i seguenti connettori:
Per configurare il peering VPC, devi creare il peering VPC dal progetto del connettore BigQuery Data Transfer Service, creare il peering VPC nel progetto del database Cloud SQL con il progetto BigQuery Data Transfer Service e configurare le route e le regole firewall.
Crea il peering VPC dal progetto del connettore BigQuery Data Transfer Service
Nella Google Cloud console, vai alla pagina Peering della rete VPC per il progetto del connettore BigQuery Data Transfer Service.
Nel campo Nome, inserisci un nome per la configurazione del peering.
Seleziona la rete VPC con cui vuoi creare il peering nel progetto del database Cloud SQL.
In ID progetto peer, inserisci l'ID progetto del progetto
BigQuery Data Transfer Service.
In Rete VPC in peering, inserisci il nome della rete VPC nel progetto del connettore BigQuery Data Transfer Service.
Fai clic su Crea.
Configurare route e regole firewall
Se non hai selezionato le route di importazione ed esportazione durante la configurazione delle connessioni in peering, segui questi passaggi per farlo ora:
Vai alla pagina Route per il progetto del connettore BigQuery Data Transfer Service.
Crea regole firewall per consentire il traffico sulle porte necessarie (ad esempio la porta 3306 per MySQL e la porta 5432 per PostgreSQL) tra le reti connesse in peering.
Aggiungi le regole del firewall personalizzate richieste dal progetto del connettore BigQuery Data Transfer Service al progetto ospitato nel database Cloud SQL.
Configura le route e le regole firewall per il tuo progetto con l'istanza Cloud SQL come hai fatto nei passaggi precedenti.
Configura il proxy Cloud SQL
Utilizza SSH per connetterti a un'istanza di una macchina virtuale (VM) nel progetto del connettore BigQuery Data Transfer Service.
Sostituisci NAME con il nome della connessione all'istanza Cloud SQL.
Connettiti all'indirizzo IP interno di Cloud SQL
Utilizza l'indirizzo IP interno dell'istanza Cloud SQL per le connessioni.
Configura l'applicazione o lo strumento in modo che si connetta all'indirizzo IP interno,
specificando le credenziali e i dettagli del database appropriati.
Quando ti connetti da un altro progetto Google Cloud , utilizza l'indirizzo IP interno della VM proxy di cui hai eseguito il deployment in precedenza. Questa soluzione risolve i problemi di peering transitivo.
Crea il collegamento di rete
Per creare l'attacco di rete nel progetto del connettore BigQuery Data Transfer Service:
Nella Google Cloud console, vai alla pagina Esecuzioni di rete.
In Regione, specifica la regione in cui si trova il connettore BigQuery Data Transfer Service.
In Subnet, seleziona l'opzione appropriata per la tua configurazione.
Fai clic su Crea collegamento di rete.
Prova la connessione
Verifica che la VM con il proxy Cloud SQL possa connettersi all'istanza Cloud SQL:
mysql-uUSERNAME-p-hIP_ADDRESS
Sostituisci quanto segue:
USERNAME: il nome utente dell'utente del database
IP_ADDRESS: l'indirizzo IP dell'istanza Cloud SQL
Assicurati che le applicazioni nel progetto del connettore BigQuery Data Transfer Service possano connettersi all'istanza Cloud SQL utilizzando l'IP interno.
Risoluzione dei problemi
Se hai problemi a configurare la rete, procedi nel seguente modo:
Assicurati che il peering VPC sia stabilito e che le route siano configurate correttamente.
Verifica che le regole del firewall consentano il traffico sulle porte richieste.
Controlla i log del proxy Cloud SQL per verificare la presenza di errori e assicurati che funzioni correttamente.
Assicurati che il collegamento di rete sia configurato e connesso correttamente.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 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."]]