AWS 계정에 Redshift 클러스터가 있습니다. 나는 파이썬에 연결할 수 그리고 난 로컬 스크립트를 실행할 때, 그것은 완벽하게 정상적으로 실행됩니다Amazon EC2 인스턴스에서 Amazon redshift 클러스터에 연결하는 방법
import psycopg2
con = psycopg2.connect(dbname='some_dbname', host='hostname.us-east-2.redshift.amazonaws.com', port='port#', user='username', password='password')
cursor=con.cursor()
query = "select * from table;"
cursor.execute(query)
data = np.array(cursor.fetchall())
cursor.close()
con.commit()
con.close()
하지만, 내 EC2 인스턴스 (아마존 리눅스 AMI)에 위의 스크립트를 복사 할 때, 다음 시도
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection timed out
Is the server running on host "hostname.us-east-2.redshift.amazonaws.com" and accepting
TCP/IP connections on port port#?
아무도 내 EC2 인스턴스에서 내 적색 편이 클러스터에 연결하는 방법에 나를 도울 수 : 그것을 실행, 나는 다음과 같은 오류가 발생합니다? 감사!
EC2 인스턴스의 연결을 허용하도록 Redshift 클러스터에 할당 된 보안 그룹에서 포트를여셨습니까? –
@ MarkB 아니, 어떻게해야합니까? – Rajiv
로컬 컴퓨터에서 액세스 할 수 있도록 보안 그룹을 어떻게여셨습니까? 그것은 같은 과정입니다. –