외부 접속 허용을 위해, postgresql.conf 파일과 pg_hba.conf 파일을 수정 필요 


OS : Rocky Linux 8.9 Version
DB : PostgreSQL 16.2 Version

 

 

기본 환경 (.bash_profile)

export PG_HOME : /u01/app/postgreSQL
export LD_LIBRARY_PATH:$PG_HOME/pgsql/bin
export PATH=$PATH:$PG_HOME/pgsql/bin
export PG_DATA=$PG_HOME/bin/data

 

 

cd $PG_DATA

vi postgresql.conf

## listener 주소 localhost에서 '*' or 'all'로 변경
## 주석 처리되어있는 # 제거 해야 활성화 됨
listener_addresses = '*'
port = 5432


:wq






vi pg_hba.conf

# 0.0.0.0/0은 모든 대역을 open하는 행위여서 보안에 취약하다는 점 참고
# 127.0.0.1/32에서 0.0.0.0/0 으로 변경
# 특정 ip설정일 경우 xxx.xxx.xxx.xxx/32
# 대역 ip설정일 경우 xxx.xxx.xxx.0/24
#IPv4 local connections :
host	all		all			0.0.0.0/0		trust






## 설치되어있는 데이터파일 경로 지정 필요
pg_ctl status [-D DATADIR] 



## 설치되어있는 데이터파일 경로 지정 필수
## $PG_DATA는 bash_profile에 설정되어 있음



pg_ctl status -D $PG_DATA
pg_ctl: server is running (PID: 143841)
/u01/app/postgreSQL/pgsql/bin/postgres "-D" "/u01/app/postgreSQL/pgsql/da

ta"

# 변경 후 DB restart 하지않으면 적용되지 않음
pg_ctl restart -D $PG_DATA

.... 중략 
restart 완료

 

 

DBeaver 접속 확인 완료

 

 

보안 설정에 따라서 IP주소는 대역대로 오픈하는 것도 좋지만, 어차피 방화벽에서 통제하고, 서버 방화벽도 통제하니 DB에서 설정할 필요는 없어보입니다.

 

 

 

참조 : https://tbmaster.tistory.com/89

+ Recent posts