SageMaker notebook instance in VPC failed to connect to local database

0

hi there,

I am setting up a jupyter notebook in SageMaker within the VPC and using the jdbc jars to connect to the local database. But it shows the following error messages.
": com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host xxx.xxx.xxx.xxx, port 21000 has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."."

I used the exactly the same VPC, subnet, security group as what i used in a glue job to extract the data from the local db. While the glue job works but the SageMaker notebook failed. I am sure the firewalls are opened.
Could anyone tell me how to solve it?
I also came across the following articles, but i am not sure if it is the root cause.
https://aws.amazon.com/blogs/machine-learning/understanding-amazon-sagemaker-notebook-instance-networking-configurations-and-advanced-routing-options/

axchoi
質問済み 5年前1063ビュー
1回答
0
承認された回答

Hi,
The principle here is that there much be network connectivity between the Notebook Instance and the DB Instance, and the security groups on the DB Instance should allow in-bound traffic from the Notebook Instance

One example of such as setup is

  1. RDS DB Instance is VPC vpc-a and Subnet subnet-b.

  2. SageMaker Notebook is launched in VPC vpc-a, Subnet subnet-b, with Security Group sg-c with DirectIntenetAccess "Disabled"

  3. In the RDS DB Instance's Security Group rules, you can add an Inbound Rule to allow inbound traffic from the SageMaker Notebook security group "sg-c"
    -- Type - Protocol - Port Range - Source
    -- MYSQL/Aurora - TCP - 3306 - sg-c


Sample Code:

! pip install mysql-connector

import mysql.connector
mydb = mysql.connector.connect(
host="$RDS_ENDPOINT",
user="$RDS_USERNAME",
passwd="$RDS_PASSWORD"
)
cursor = mydb.cursor()
cursor.execute("SHOW DATABASES") 

Thanks for using Amazon SageMaker and let us know if there's anything else we can help with!

Edited by: JaipreetS-AWS on May 6, 2019 3:04 PM

回答済み 5年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ