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년 전1064회 조회
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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠