일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- PostgreSQL 아키텍처
- Database 생성 삭제 조회 변경
- psql 복구
- PostgreSQL Install
- PostgreSQL Backup and Recovery
- 아카이브로그 삭제
- pg_basebackup
- sql문 짤릴 때
- pg_dumpall
- PostgreSQL 테이블스페이스 관리
- PostgreSQL 외부 접속 방법
- table lock 조치 방법
- pgcrypto
- oracle
- Linux
- pg_hba.conf
- multitenant
- sql문 전체 출력 방법
- PostgreSQL Vacuum
- oracle error
- PostgreSQL Parameter
- PostgreSQL 기동 정지
- 19c tde
- db upgrade
- PostgreSQL 테이블스페이스 생성 삭제
- PostgreSQL SQL 처리 과정
- PostgreSQL Admin
- PostgreSQL Database 관리
- PostgreSQL 스키마 관리
- PostgreSQL Parameter 설정 방법
- Today
- Total
인성장
[PostgreSQL] 원격 접속 허용 방법 (외부 접근 제어, 접속 인증 설정) 본문
PostgreSQL 원격 접속 허용 방법
PostgreSQL를 처음 설치하고, 초기 설정값으로 설정된 데이터베이스를 외부에서 접속 시 아래와 같은 에러가 나타나며 접속이 되지 않습니다.
이는 PostgreSQL DB에 접속하는 클라이언트에 대한 접근제어 및 인증 등을 설정하는 파일인 pg_hba.conf 때문인데요.
초기 pg_hba.conf 설정은 아래와 같습니다. (pg_hba.conf 파일은 $PGDATA 경로안에 존재)
외부에서 PostgreSQL로 접근이 가능하게 하려면 다음과 같이 설정하면 됩니다.
pg_hba.conf 설정이 끝났으면, 데이터베이스에 pg_hba.conf 변경내용을 적용하기 위해 reload 합니다.
$ /postgres/app/postgres/pgsql15/bin/pg_ctl reload -D /postgres/app/postgres/pgsql15/data
만약, pg_hba.conf 파일내용만 수정하고 외부에서 접속테스트를 시도하시면 아래와 같이 Connection refused: connect 에러가 나오면서 접속이 되지 않으실겁니다.
한가지를 더 추가로 작업해주셔야 외부원격접속이 가능한데, 바로 postgresql.conf 파일 내용 중 listen_addresses 파라미터 내용을 아래와 같이 수정해주시면 됩니다. (postgresql.conf 파일은 $PGDATA 경로안에 존재)
listen_addresses 변경 전
$ vi postgresql.conf
...(생략)...
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
...(생략)...
listen_addresses 변경 후
$ vi postgresql.conf
...(생략)...
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
...(생략)...
해당 파라미터는 재기동을 해야 적용이 되므로 DB restart를 진행해줍니다.
$ /postgres/app/postgres/pgsql15/bin/pg_ctl restart -D /postgres/app/postgres/pgsql15/data
이제 외부에서 접속이 잘 될겁니다!
'PostgreSQL > Admin' 카테고리의 다른 글
[PostgreSQL] Parameter 설정 방법 (0) | 2024.02.02 |
---|---|
[PostgreSQL] 데이터베이스 관리(생성, 삭제, 조회, 변경 등) (0) | 2023.12.12 |
[PostgreSQL] pg_hba.conf (1) | 2023.11.30 |
[PostgreSQL] 기동 정지 방법 (2) | 2023.11.30 |
[PostgreSQL] 수동 Fail-over, Fail-back 방법 (0) | 2023.11.24 |