이 페이지에서는 MySQL 데이터베이스를 호스팅하는 비공개 Cloud SQL 인스턴스에 비공개 Cloud Data Fusion 인스턴스를 연결하는 방법을 설명합니다. Postgres 및 SQL Server 인스턴스에 비슷한 설정이 사용됩니다. 플러그인 연결이 가능합니다.
권장: 보안상의 이유로 Cloud SQL 및 Cloud Data Fusion의 비공개 인스턴스를 사용합니다.
Cloud Data Fusion 및 Cloud SQL에서 비공개 인스턴스 만들기
비공개 Cloud Data Fusion 인스턴스에서 비공개 Cloud SQL 인스턴스에 연결하려면 프록시 Compute Engine VM을 사용합니다. Cloud SQL 네트워크가 Cloud Data Fusion 네트워크와 직접 피어링되지 않고 전환 피어가 서로 통신할 수 없기 때문에 프록시가 필요합니다(VPC Network Peering 개요 참조).
이 명령어는 VM이 Container Registry에 액세스하여 프록시 이미지를 가져올 수 있도록 내부 및 공개 IP 주소가 모두 포함된 VM을 만듭니다(--no-address가 샘플 VM 만들기 명령어에 지정되지 않음). 내부 IP를 사용할 수 있지만 또한 VM이 있는 서브넷에 대해 비공개 Google 액세스를 사용 설정해야 합니다.
다음 환경 변수를 내보냅니다.
exportPROJECT=CUSTOMER_PROJECTexportREGION=VM_REGIONexportZONE=`gcloudcomputezoneslist--filter="name=${REGION}"--limit1--uri--project=${PROJECT}|sed's/.*\///'`exportNETWORK=CUSTOMER_VPC_NETWORK_NAMEexportSUBNET=CUSTOMER_VPC_SUBNET_NAMEexportINSTANCE_NAME=COMPUTE_ENGINE_VM_NAMEexportSQL_CONN=SQL_INSTANCE_CONNECTION_NAMEexportCDF_IP_RANGE=CLOUD_DATA_FUSION_IP_RANGEexportVM_IMAGE=$(gcloudcomputeimageslist--project=$PROJECT--filter=family:cos-stable--format='value(selfLink.scope())'--limit=1)exportSQL_PORT=DB_PORT# MySQL 3306 # PostgreSQL 5432 # SQLServer 1433
다음을 바꿉니다.
CUSTOMER_PROJECT: 프로젝트 이름
VM_REGION: Compute Engine VM이 있는 리전
CUSTOMER_VPC_NETWORK_NAME: 네트워크 이름
CUSTOMER_VPC_SUBNET_NAME: 서브네트워크 이름
COMPUTE_ENGINE_VM_NAME: Compute Engine VM의 이름
SQL_INSTANCE_CONNECTION_NAME: 이전 단계의 연결 이름
CLOUD_DATA_FUSION_IP_RANGE: IP 주소 범위
DB_PORT: Cloud SQL 데이터베이스의 포트 번호
다음 gcloud CLI 명령어를 사용하여 Cloud Data Fusion 인그레스 트래픽을 허용하는 방화벽 규칙을 만듭니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-12(UTC)"],[[["\u003cp\u003eThis guide explains how to securely connect a private Cloud Data Fusion instance to a private Cloud SQL instance, such as MySQL, using a proxy Compute Engine VM.\u003c/p\u003e\n"],["\u003cp\u003eConnecting private instances of Cloud Data Fusion and Cloud SQL is highly recommended for enhanced security, and requires the use of VPC peering between the Cloud Data Fusion network and your project's VPC.\u003c/p\u003e\n"],["\u003cp\u003eA proxy Compute Engine VM is essential because the Cloud SQL network and Cloud Data Fusion network are not directly peered and cannot communicate transitively.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves creating private instances in both Cloud Data Fusion and Cloud SQL, setting up a proxy VM with a static internal IP, and configuring firewall rules to allow traffic from Cloud Data Fusion.\u003c/p\u003e\n"],["\u003cp\u003eWhile the document emphasizes private instance connections, it also briefly outlines other connection possibilities, such as using public instances, although these options are less secure.\u003c/p\u003e\n"]]],[],null,["# Connect to a Cloud SQL-MySQL source\n\nThis page describes how to connect a private Cloud Data Fusion instance to a\nprivate Cloud SQL instance that hosts a MySQL database. A similar setup\nworks for Postgres and SQL Server instances. [Public connections are possible](#other-connections).\n| **Note:** [VPC peering](/data-fusion/docs/how-to/create-private-ip#set-up-vpc-peering) is used to connect the Cloud Data Fusion network to your project's VPC. You can connect the Cloud SQL network to your project's VPC using VPC peering or VPN. \n| This page assumes that you're using VPC peering to connect the Cloud SQL network to your project's VPC. If you're using VPN, then don't perform the tasks described on this page. To establish the connection, you can use the internal IP address of the Cloud SQL instance in Cloud Data Fusion.\n\n**Recommended**: For security reasons, use\nprivate instances of Cloud SQL and Cloud Data Fusion.\n\nCreate private instances in Cloud Data Fusion and Cloud SQL\n-----------------------------------------------------------\n\nTo connect to a private Cloud SQL instance from a private\nCloud Data Fusion instance, you use a proxy Compute Engine VM. A proxy\nis required because the Cloud SQL network is not directly peered with\nthe Cloud Data Fusion network, and transitive peers cannot communicate with\neach other (see the [VPC Network Peering overview](/vpc/docs/vpc-peering)).\n\nTo create the private instances, follow these steps:\n\n1. If you don't already have one, [create a private Cloud Data Fusion\n instance](/data-fusion/docs/how-to/create-private-ip). This includes:\n\n 1. Setting up a VPC network\n 2. Allocating an IP range\n2. [Create a private Cloud SQL instance](/sql/docs/mysql/create-instance)\n in the same VPC network as your Cloud Data Fusion instance.\n\n3. After the instance is created, go to the Cloud SQL **Instances**\n page and expand the **Instance details** . In the **Connect to this\n instance** section, copy the IP and the connection name.\n\n [Go to Cloud SQL Instances](https://console.cloud.google.com/sql/instances)\n\nCreate a private Compute Engine VM\n----------------------------------\n\nTo create the VM, you can enter the following commands in\n[Cloud Shell](/shell) or another environment where the\n[Google Cloud SDK](/sdk/docs) is installed.\n\nThe commands create a VM with both internal and public IP addresses\n(`--no-address` isn't specified in the sample VM creation command) so that the\nVM can access the Container Registry to get the proxy image. You can use internal\nIPs, but you also must\n[enable Private Google Access](/vpc/docs/configure-private-google-access) for\nthe subnet where the VM is located.\n\n1. Export the following environmental variables:\n\n export PROJECT=\u003cvar translate=\"no\"\u003eCUSTOMER_PROJECT\u003c/var\u003e\n export REGION=\u003cvar translate=\"no\"\u003eVM_REGION\u003c/var\u003e\n export ZONE=`gcloud compute zones list --filter=\"name=${REGION}\" --limit 1 --uri --project=${PROJECT}| sed 's/.*\\///'`\n export NETWORK=\u003cvar translate=\"no\"\u003eCUSTOMER_VPC_NETWORK_NAME\u003c/var\u003e\n export SUBNET=\u003cvar translate=\"no\"\u003eCUSTOMER_VPC_SUBNET_NAME\u003c/var\u003e\n export INSTANCE_NAME=\u003cvar translate=\"no\"\u003eCOMPUTE_ENGINE_VM_NAME\u003c/var\u003e\n export SQL_CONN=\u003cvar translate=\"no\"\u003eSQL_INSTANCE_CONNECTION_NAME\u003c/var\u003e\n export CDF_IP_RANGE=\u003cvar translate=\"no\"\u003eCLOUD_DATA_FUSION_IP_RANGE\u003c/var\u003e\n export VM_IMAGE=$(gcloud compute images list --project=$PROJECT --filter=family:cos-stable --format='value(selfLink.scope())' --limit=1)\n export SQL_PORT=\u003cvar translate=\"no\"\u003eDB_PORT\u003c/var\u003e # MySQL 3306 # PostgreSQL 5432 # SQLServer 1433\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCUSTOMER_PROJECT\u003c/var\u003e: Your project's name\n - \u003cvar translate=\"no\"\u003eVM_REGION\u003c/var\u003e: The region where the Compute Engine VM is located\n - \u003cvar translate=\"no\"\u003eCUSTOMER_VPC_NETWORK_NAME\u003c/var\u003e: Your network's name\n - \u003cvar translate=\"no\"\u003eCUSTOMER_VPC_SUBNET_NAME\u003c/var\u003e: Your subnetwork's name\n - \u003cvar translate=\"no\"\u003eCOMPUTE_ENGINE_VM_NAME\u003c/var\u003e: The name of the Compute Engine VM\n - \u003cvar translate=\"no\"\u003eSQL_INSTANCE_CONNECTION_NAME\u003c/var\u003e: The connection name from the previous step\n - \u003cvar translate=\"no\"\u003eCLOUD_DATA_FUSION_IP_RANGE\u003c/var\u003e: The IP address range\n - \u003cvar translate=\"no\"\u003eDB_PORT\u003c/var\u003e: The port number of the Cloud SQL database\n2. Create a firewall rule to allow Cloud Data Fusion ingress traffic with\n the following gcloud CLI command:\n\n gcloud compute firewall-rules create allow-private-cdf \\\n --allow=tcp:22,tcp:${SQL_PORT} \\\n --source-ranges=$CDF_IP_RANGE --network=$NETWORK --project=$PROJECT\n\n3. Create the VM with the following gcloud CLI command:\n\n gcloud compute --project=${PROJECT} instances create ${INSTANCE_NAME} \\\n --zone=${ZONE} \\\n --machine-type=g1-small \\\n --subnet=${SUBNET} \\\n --metadata=startup-script=\"docker run -d -p 0.0.0.0:${SQL_PORT}:${SQL_PORT} gcr.io/cloudsql-docker/gce-proxy:latest /cloud_sql_proxy -instances=${SQL_CONN}=tcp:0.0.0.0:${SQL_PORT}\" \\\n --maintenance-policy=MIGRATE \\\n --scopes=https://www.googleapis.com/auth/cloud-platform \\\n --image=${VM_IMAGE} \\\n --image-project=cos-cloud\n\n4. Get the VM internal IP with the following gcloud CLI command:\n\n export IP=`gcloud compute \\\n --project=${PROJECT} instances describe ${INSTANCE_NAME} \\\n --zone ${ZONE} | grep \"networkIP\" | awk '{print $2}'`\n\n5. Promote the VM internal IP to a static IP with the following\n gcloud CLI command:\n\n gcloud compute --project=${PROJECT} addresses create mysql-proxy \\\n --addresses ${IP} --region ${REGION} --subnet ${SUBNET}\n\n6. Get the IP to be used in Cloud Data Fusion MySQL JDBC connection string\n when you set up the connection:\n\n echo ${IP}\n\nAfter the VM is created with a static IP, use the IP as the host or enter it in\nthe JDBC connection string to access the MySQL database from\nCloud Data Fusion.\n\nAccess MySQL from within Cloud Data Fusion\n------------------------------------------\n\nBefore you can connect to the MySQL instance from the Cloud Data Fusion\ninstance, install the MySQL JDBC driver from the Cloud Data Fusion Hub (or\ndirectly from\n[MySQL community downloads](https://dev.mysql.com/downloads/file/?id=462850)).\n| **Note:** In this case, use the general MySQL driver instead of Cloud SQL-MySQL driver.\n\nEnter the connection details for your MySQL database in\nCloud Data Fusion. You can enter the details and test the connection on\nthe **Wrangler** page.\n\n### Optional: Other ways to connect to MySQL\n\nYou can access MySQL in the following ways in Cloud Data Fusion:\n\n- On the **Studio** page, click the MySQL source plugin and enter the connection details.\n- On the **Studio** page, instead use the Database source plugin, which has\n similar properties (**Connection string** , **Username** , **Password** , and\n **Connection Arguments**).\n\n | **Note:** Unlike the MySQL plugins, the Database plugin isn't designed specifically for MySQL connections. You must understand the JDBC string format to add the connection details.\n\nOther connections\n-----------------\n\nAlthough connecting private instances is recommended, the following connections\nare possible:\n\n- A public Cloud Data Fusion instance to a public Cloud SQL instance (by using a public Cloud SQL proxy or allowlisting the `0.0.0.0/0` range in an authorized network). See the [public IP connection option](https://cloud.google.com/sql/docs/mysql/connect-overview#public_ip) for Cloud SQL.\n- A private Cloud Data Fusion instance and public Cloud SQL instance (by using a public Cloud SQL proxy in an authorized network).\n- A public Cloud Data Fusion instance and a private Cloud SQL\n instance."]]