If you choose the endpoint connection method when creating a data source or a data migration task with Google Cloud as the cloud provider, you need to configure it first. This topic describes how to do so.
Prerequisites
You have created a database instance of the corresponding type and obtained its connection address within your VPC. For example, a MySQL instance typically has a single address pair in the format
address:port, while a Kafka instance may have multiple address pairs (broker_address1:broker_port1,broker_address2:broker_port2, etc.).If resources associated with the endpoint service, such as the load balancing service or virtual server, have security group configurations enabled, you need to add the private IP address of the OB Cloud data source to the corresponding security group. For details, see Private IP address range description.
Configure private network connections for Cloud SQL instances
GCP Cloud SQL for MySQL/PostgreSQL supports two private network connection methods: Private Service Connect (PSC) and Private Service Access (PSA). You can go to the Cloud SQL instance page in the Google Cloud console and check the Internal connection method of the target Cloud SQL instance to determine whether it uses PSC mode or PSA mode.
If you are using PSC mode, only the Endpoint connection type is supported when creating a new data migration task. After creating a Cloud SQL instance, obtain the service connection and fill it in the Google Cloud > Endpoint > Connection field on the data source or data migration task creation page. For more information, see Connect to an instance by using Private Service Connect.
In PSC mode, you also need to add an authorized project. To do so, perform the following steps. For official documentation, see Edit an instance with Private Service Connect enabled.
Log in to the OceanBase Cloud console.
On the Data Services > Create Data Source or Create Data Migration Task page, view and copy the Project ID displayed under the Google Cloud > Endpoint > Connection section.
In the Google Cloud command-line interface, run the following command to add an authorized project for the Cloud SQL instance in PSC mode.
gcloud sql instances patch <INSTANCE_NAME> \ --project=<PROJECT_ID> \ --allowed-psc-projects=ALLOWED_PROJECTSParameterDescriptionINSTANCE_NAME The name of the Cloud SQL instance that the Private Service Connect endpoint in the VPC network can connect to. PROJECT_ID The ID or number of the Google Cloud project that contains the instance to which the Private Service Connect endpoint in the VPC network can connect. ALLOWED_ProjectS The Project ID copied in Step 2. This project replaces the project already configured to use Private Service Connect. If the project is not in this list, you cannot use it to create an instance and enable Private Service Connect for it. For example,
omstest-mysql-pscis the name of the Cloud SQL instance,oms-dev-112233is your own project ID, andoms_project_idis the Project ID copied from the Data Services page.gcloud sql instances patch omstest-sit-cloudsql-psc \ Instance name --project=oms-dev-112233 --allowed-psc-projects='oms-dev','oms_project_id'
If you are using PSA mode, configure it according to the following steps. Note that when creating a Cloud SQL instance in PSA mode, you need to configure the corresponding dedicated IP and public IP information in the Custom Instance - Number of Connections section. You must select your own VPC network to associate with the dedicated IP.
Create a forwarding instance
The following example shows how to create a forwarding instance, an instance group, and a health check using GCP gcloud commands. It is for reference only. Replace the parameter values with your actual settings.
## Create an instance
gcloud compute instances create <instance_name> \
--project=<project_id> \
--zone=<zone_id> \
--machine-type=c2d-standard-2 \
--network-interface=network-tier=STANDARD,stack-type=IPV4_ONLY,subnet=<subnet_name> \
--maintenance-policy=MIGRATE \
--provisioning-model=STANDARD \
--tags=lb-health-check \
--scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/sqlservice.admin,https://www.googleapis.com/auth/trace.append \
--create-disk=auto-delete=yes,boot=yes,device-name=<instance_name>,image=projects/rocky-linux-cloud/global/images/rocky-linux-8-optimized-gcp-v20240717,mode=rw,size=20,type=pd-balanced \
--labels=use=rdtest,product=oms,env=devsit
# Create an instance group and add the previously created instance to it.
gcloud compute instance-groups unmanaged create <instance_group_name> \
--project=<project_id> \
--zone=<zone_id> \
&& \
gcloud compute instance-groups unmanaged add-instances <instance_group_name> \
--project=<project_id> \
--zone=<zone_id> \
--instances=<instance_name>
# Create a health check.
gcloud compute health-checks create tcp <health_check_name> \
--project=<project_id> \
--port=3306 \
--proxy-header=NONE \
--region=us-west1 \
--no-enable-logging \
--check-interval=5 \
--timeout=5 \
--unhealthy-threshold=2 \
--healthy-threshold=2
Parameter |
Description |
|---|---|
| instance_name | The name of the Google Cloud instance. |
| project_id | The Google Cloud project ID. |
| zone_id | The zone of an instance or instance group in Google Cloud. |
| subnet_name | Subnet name. The subnet specified here must belong to the network specified when creating the Cloud SQL instance. |
| instance_group_name | The name of the instance group in Google Cloud. |
| health_check_name | The name of the created health check in Google Cloud. |
Log in to the forwarding instance and install the cloud-sql-auth-plugin
The following example shows how to log in to the forwarding instance and install the cloud-sql-auth-plugin. Replace the parameter values with your actual settings.
After logging in to the instance, run the following command.
curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.11.3/cloud-sql-proxy.linux.amd64 chmod +x cloud-sql-proxyOn the gcloud console page, run the following command.
gcloud sql instances describe <mysql_instance_name> --format='value(connectionName)'For example, if the Cloud SQL instance name is
cloud_mysql_test, the command is as follows.gcloud sql instances describe cloud_mysql_test --format='value(connectionName)'The return result is as follows.
xxx@xxx: ~ (oms-dev) $ gcloud sql instances describe cloud_mysql_test --format='value (connectionName) ' oms-dev:us-west1:cloud_mysql_testAfter obtaining the return result, log in to the virtual machine instance and run the following command.
./cloud-sql-proxy --address 0.0.0.0 --port 3306 --private-ip oms-dev:us-west1:cloud_mysql_test > out.txt &Run the following command for verification.
sudo yum install -y telnet [xxx@xxx ~]$ telnet 127.0.0.1 3306 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Q 8.0.31-google+ lt7gQs+F#i]F&;W_,:mysql_native_password
Create a PSC service attachment
Create a load balancer
On the Load Balancing page, click + CREATE LOAD BALANCER.

On the Create a load balancer page, select the following configurations in sequence.
Select Network Load Balancer for Type of load balancer and click Next.
Select Passthrough load balancer for Proxy or passthrough and click Next.
Select Internal for Public facing or internal and click Next.
After selection, click CONFIGURE.
On the Create Internal passthrough Network Load Balancer page, configure the parameters.

Click CREATE.
Create a Publish Service
On the PUBLISH SERVICES page, click + PUBLISH SERVICE.

On the Publish Service page, configure the parameters.
Select Internal passthrough Network Load Balancer for Load Balancer Type.
From the Internal load balancer drop-down list, select the created load balancer.
Enter a custom name in the Service name text box.
Select an existing subnet from the Subnets drop-down list and click OK. To create a new one, click RESERVE NEW SUBNET.
Note
Ensure the Publish Service Subnet can access your backend service.
In the Accepted projects section, click + ADD ACCEPTED PROJECT and enter the name of the authorized project.
For the project name, copy the one displayed under the Connection section on the Data Services > Create Data Source or Create Data Migration Task page.

After configuration, click ADD SERVICE.
Obtain Service Attachment
After creating a Publish Service, you need to copy its Service attachment and fill it in the Google Cloud > Endpoint > Connection fields on the Create Data Source or Create Data Migration Task page. For details on creating a data source, see Create a data source. For details on creating a data migration task, see the corresponding documentation in the Migrate data from a MySQL database to the MySQL-compatible mode of OceanBase Database module.

To copy the Service Attachment, follow these steps:
On the Published services page, click the target Service name.

On the Private Service Connect service details page, click the copy icon next to Service attachment to obtain the service connection.

Configure private network connection for Kafka instance
Obtain the Kafka node list
Run the following command in the Google Cloud command-line interface to obtain the Kafka cluster information.
gcloud managed-kafka clusters describe <cluster name> --location us-west1In the execution result,
bootstrapAddressindicates the Bootstrap connection address, andsubnetindicates the subnet where the cluster is located.Create an instance that can connect to Kafka. The subnet must be the same as the GCP subnet.
## Create an instance gcloud compute instances create <instance_name> \ --project=<project_id> \ --zone=<zone_id> \ --machine-type=c2d-standard-2 \ --network-interface=network-tier=STANDARD,stack-type=IPV4_ONLY,subnet=<subnet_name> \ --maintenance-policy=MIGRATE \ --provisioning-model=STANDARD \ --tags=lb-health-check \ --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/sqlservice.admin,https://www.googleapis.com/auth/trace.append \ --create-disk=auto-delete=yes,boot=yes,device-name=<instance_name>,image=projects/rocky-linux-cloud/global/images/rocky-linux-8-optimized-gcp-v20240717,mode=rw,size=20,type=pd-balanced \ --labels=use=rdtest,product=oms,env=devsit # Create an instance group and add the instance created above to the instance group. gcloud compute instance-groups unmanaged create <instance_group_name> \ --project=<project_id> \ --zone=<zone_id> \ && \ gcloud compute instance-groups unmanaged add-instances <instance_group_name> \ --project=<project_id> \ --zone=<zone_id> \ --instances=<instance_name>Log in to the instance and run the following command.
sudo -i yum install -y wget java-1.8.0-openjdk wget -O kafka_2.13-3.7.2.tgz https://downloads.apache.org/kafka/3.7.2/kafka_2.13-3.7.2.tgz tar xfz kafka_2.13-3.7.2.tgz export KAFKA_HOME=$(pwd)/kafka_2.13-3.7.2 export PATH=$PATH:$KAFKA_HOME/binAuthorize the retrieval of SASL authentication information and save the authentication file as
client.propertieson the instance.Log in to the IAM page in the Google Cloud console and find a target service account (service_account, used when generating the SASL password).
Obtain the key JSON configuration of the target service account (download and save it when generating the key).
Generate an SASL password.
Taking the key JSON configuration file named
my_service_account.jsonas an example, run the following command in the instance to obtain a base64-encoded password, which will be generated intopassword.txt.base64 -w 0 < my_service_account.json > password.txtRun the following command in the instance to grant the target service account permission to access the Kafka service on GCP.
gcloud projects add-iam-policy-binding $PROJECT_ID \ --member serviceAccount: $SERVICE_ACCOUNT_EMAIL \ --role roles/managedkafka.clientEnter the data source in the data source service via
SASL_PLAINto test the connection. Save this file asclient.properties.security.protocol=SASL_SSL sasl.mechanism=PLAIN sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \ username="oms-xxxx.iam.gserviceaccount.com" \ password="ewogICxxxxFwaXMuY29tIgp9Cg==";
Run the following command to obtain the addresses of the broker nodes.
# --bootstrap-server The Bootstrap connection address obtained from the previous query. kafka-configs.sh --bootstrap-server bootstrap.xxxx-test-oms.us-west1.managedkafka.oms-dev-41xxxx02.cloud.goog:9092 --describe --all --entity-type brokers --command-config client.properties | grep advertised.listeners | awk -F'EXTERNAL://|,' '{print $2}'For example,
broker-0_bootstrap.xxxx-test-oms.us-west1.managedkafka.oms-dev-41xxxx02.cloud.goog:9092.
Configure Nginx
Configure Nginx based on the obtained broker node list.
# If Nginx fails to start, you need to set this.
sudo setenforce 0
load_module '/usr/lib64/nginx/modules/ngx_stream_module.so';
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
stream {
# Each Server corresponds to a Kafka Bootstrap Server connection address.
# The number after listen is the Nginx port, which can be different from the port in proxy_pass.
server {
listen 19092;
proxy_pass bootstrap.<region_id>.managedkafka.<project_id>.cloud.goog:9092;
proxy_timeout 60s;
}
server {
listen 19093;
proxy_pass broker-0.<region_id>.managedkafka.<project_id>.cloud.goog:9092;
proxy_timeout 60s;
}
server {
listen 19094;
proxy_pass broker-1.<region_id>.managedkafka.<project_id>.cloud.goog:9092;
proxy_timeout 60s;
}
server {
listen 19095;
proxy_pass broker-2.<region_id>.managedkafka.<project_id>.cloud.goog:9092;
proxy_timeout 60s;
}
}
Notice
Nginx must support the
ngx_stream_module.We recommend that you set the
proxy_timeoutparameter to 60 seconds or more for Nginx.
Create a health check
gcloud compute health-checks create tcp <health_check_name> \
--project=<project_id> \
--port=<any Nginx forwarding port> \
--proxy-header=NONE \
--region=<region_id> \
--no-enable-logging \
--check-interval=5 \
--timeout=5 \
--unhealthy-threshold=2 \
--healthy-threshold=2
Create a PSC service attachment
Create a load balancer
On the Load Balancing page, click + CREATE LOAD BALANCER.

On the Create a load balancer page, select the following configurations in sequence.
Select Network Load Balancer for Type of load balancer and click Next.
Select Passthrough load balancer for Proxy or passthrough and click Next.
Select Internal for Public facing or internal and click Next.
After the selection is complete, click CONFIGURE.
On the Create Internal passthrough Network Load Balancer page, configure the parameters.

Click CREATE.
Create a publish service
On the PUBLISH SERVICES page, click + PUBLISH SERVICE.

On the Publish Service page, configure the parameters.
Select Internal passthrough Network Load Balancer for Load Balancer Type.
From the Internal load balancer drop-down list, select the created load balancer.
Enter a custom name in the Service name text box.
From the Subnets drop-down list, select the created subnet and click OK. If you need to create a new one, click RESERVE NEW SUBNET.
Note
Ensure the Publish Service Subnet can access your backend services.
In the Accepted projects section, click + ADD ACCEPTED PROJECT and enter the name of the authorized project.
The project name here should be copied from the name displayed below the Connection section on the Data Services > Create Data Source or Create Data Migration Task page.

After the configuration is complete, click ADD SERVICE.
Obtain Service Attachment
After creating a Publish Service, you need to copy the Service attachment and fill it in the Google Cloud > Endpoint > Connection fields on the page for creating a data source or a data migration task. For details on creating the task, see Migrate data from a MySQL database to the MySQL-compatible mode of OceanBase Database.

To copy the Service attachment, perform the following steps:
On the Published services page, click the name of the target Service.

On the Private Service Connect service details page, click the copy icon next to Service attachment to obtain the service connection.

