Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Problem

User when connecting a Private CDF instance to a Private PostgreSQL, you see connection.

Connection to :5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Solution(s)

  1. Assuming the private CDF instance is create as per instructions here and also the private Cloud SQL or PostgreSQL is created as required.

  2. Now that both the instances are setup, create a private GCE VM (with only internal IP) using the following gcloud command:

export PROJECT=<customer-project>
export REGION=<vm-region>
export ZONE=`gcloud compute zones list --filter="name=${REGION}" \
                --limit 1 --uri --project=${PROJECT}| sed 's/.*\///'`
export SUBNET=<customer-vpc-subnet-name>
export NAME=<gce-vm-name>
export MYSQL_CONN=<mysql-instance-connection-name>

# Create the VM
gcloud beta compute --project=${PROJECT} instances create ${NAME} \
   --zone=${ZONE} --machine-type=g1-small --subnet=${SUBNET} \
   --no-address --metadata=startup-script="docker run -d \
   -p 0.0.0.0:3306:3306 gcr.io/cloudsql-docker/gce-proxy:1.16 /cloud_sql_proxy \
   -instances=${MYSQL_CONN}=tcp:0.0.0.0:3306" \
   --maintenance-policy=MIGRATE --scopes=https://www.googleapis.com/auth/cloud-platform \
   --image=cos-69-10895-385-0 --image-project=cos-cloud

# Get the VM internal IP
export IP=`gcloud compute instances describe ${NAME} \
    --zone ${ZONE} | grep "networkIP" | awk '{print $2}'`

# Promote the VM internal IP to static IP
gcloud compute addresses create proxy --addresses ${IP} \
    --region ${REGION} --subnet ${SUBNET}

# Note down the IP to be used in CDF MySQL or PostGreSQL JDBC 
# connection string
echo ${IP}

Once the VM is created with a static IP, now use this as the host for the mysql or postgresql database to be accessed from Cloud Data Fusion.

  • No labels