java.net.ConnectException: Connection refused: connect.

Volc·2023년 7월 18일
0

Error

목록 보기
51/62

Error

Could not open connection to jdbc:hive2://10.250.xxx.xx:10000/test_db: java.net.ConnectException: Connection refused: connect.
  • 서버에 hive 0.13 ver과 hadoop 2.7.0 ver을 설치 후 외부에서 datagrip으로 연결을 시도했으나 위와 같은 에러가 발생하였다.

해결 방법

  • 우선 서버가 켜져있는지 확인하였다.

    • 서버가 켜져 있지 않다면 다음 명령어를 실행한다.
      hive --service hiveserver2
  • 서버에서 beeline으로 접속을 해본다.

    • beeline 접속은 다음과 같다.
      beeline -u jdbc:hive2://localhost:10000
  • IP로 접속을 해본다.

    • localhost 대신 ip로 변경하여 접속해본다.
      beeline -u jdbc:hive2://10.250.xxx.xx:10000
  • 필자는 ip로 접속할 때 같은 에러가 발생하였다.

  • 이럴 경우 hive의 hive-site.xml의 hive.server2.thrift.bind.host의 value를 다음과 같이 고친다.

    <property>
      <name>hive.server2.thrift.bind.host</name>
      <value>hadoop-master</value>
      <description>Bind host on which to run the HiveServer2 Thrift interface.
      Can be overridden by setting $HIVE_SERVER2_THRIFT_BIND_HOST</description>
    </property>

    /etc/hosts 파일에 내 ip가 hadoop-master로 mapping 되어 있어야 한다.

    /etc/hosts 파일을 고치기 귀찮으면 hadoop-master 대신 ip를 넣으면 된다.

profile
미래를 생각하는 개발자

1개의 댓글

comment-user-thumbnail
2023년 7월 18일

유익한 글 잘 봤습니다, 감사합니다.

답글 달기