공개하기부끄러운블로그
공개하기부끄러운블로그
공개하기부끄러운블로그
전체 방문자
오늘
어제
  • 🥇Home (100)
    • 👨🏻‍💻Infra (73)
      • 🌐Network (4)
      • 🐧Linux (27)
      • 🌎Cloud (9)
      • ⚫️Virtualization (2)
      • 🐳Docker & Kubernetes (1)
      • 🟦WEB & WAS (18)
      • 🟩IaC (0)
      • 🟨CI & CD (0)
      • ⚙️Application (6)
      • 💻Monitoring (2)
      • 📡HA (4)
    • 👨🏻‍💻Development (3)
      • 💻Frontend (2)
      • 💾Backend (0)
      • 🐍Bash (1)
    • 💾Data (16)
      • 🧩Database (13)
      • 📁Storage (3)
    • 🎓BBS (5)
    • 👨‍👧‍👧Git (0)

최근 글

인기 글

최근 댓글

태그

  • 라이믹스
  • 제로보드
  • tomcat
  • 보안
  • 레드마인
  • Redmine
  • 다음 카카오 주소API
  • WAF
  • Tomcat 취약점
  • 레드마인 테마
  • log4j 취약점
  • 웹방화벽
  • 톰캣 HTTP 헤더
  • 카카오 주소API
  • CentOS6 PostgreSQL
  • pcs
  • pacemaker
  • CentOS7 PostgreSQL
  • 방화벽
  • 다음 주소API
  • 톰캣 버전 노출
  • Tomcat 버전 노출
  • nginx
  • CentOS8 PostgreSQL
  • 톰캣
  • RHCS
  • GFS2
  • xe
  • Tomcat HTTP 헤더
  • 취약점

티스토리

hELLO · Designed By 정상우.
공개하기부끄러운블로그

공개하기부끄러운블로그

PostgreSQL 외부접속 설정
💾Data/🧩Database

PostgreSQL 외부접속 설정

2021. 1. 27. 15:07
반응형
OS : CentOS7.9
DB : PostgreSQL9.6

 

[root@localhost ~]# su - postgres 
-bash-4.2$ psql 
psql (9.6.20) 
Type "help" for help. 

# doit계정 생성
postgres=# create user doit superuser; 
CREATE ROLE 

# doit계정 Password 설정
postgres=# alter user doit with password '123123'; 
ALTER ROLE 

# doitDB생성 및 doit계정에게 권한 부여
postgres=# create database doitDB with owner doit encoding 'UTF8';
CREATE DATABASE

# 생성된 DB확인 (doitDB)
postgres=# \l
                                 데이터베이스 목록
   이름    |  소유주  | 인코딩 |   Collate   |    Ctype    |      액세스 권한      
-----------+----------+--------+-------------+-------------+-----------------------
 doitdb    | doit     | UTF8   | ko_KR.UTF-8 | ko_KR.UTF-8 | 
 postgres  | postgres | UTF8   | ko_KR.UTF-8 | ko_KR.UTF-8 | 
 template0 | postgres | UTF8   | ko_KR.UTF-8 | ko_KR.UTF-8 | =c/postgres          +
           |          |        |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8   | ko_KR.UTF-8 | ko_KR.UTF-8 | =c/postgres          +
           |          |        |             |             | postgres=CTc/postgres
(4개 행)

postgres=# pg_ctl reload

 

외부 접속 허용 전 config 파일 확인 후 작업
postgres=# show hba_file;
              hba_file               
-------------------------------------
 /var/lib/pgsql/9.6/data/pg_hba.conf
(1개 행)

# [root@localhost ~]# su - postgres

# -bash-4.2$ vim 9.6/data/pg_hba.conf     // 아래 와 같이 한줄추가

# -bash-4.2$ vim 9.6/data/postgresql.conf     // 주석 해제 후 listen_addresses 수정

 

root로 전환 후 PostgreSQL Restart

[root@localhost ~]# systemctl restart postgresql-9.6

 

[root@localhost ~]# netstat -nltp

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1021/sshd           
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      16981/postmaster    
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1182/master         
tcp6       0      0 :::22                   :::*                    LISTEN      1021/sshd           
tcp6       0      0 :::5432                 :::*                    LISTEN      16981/postmaster    
tcp6       0      0 ::1:25                  :::*                    LISTEN      1182/master   

 

이후에도 외부에서 접근에 문제가 된다면 방화벽을 확인해봐야한다.

PostgreSQL의 Default Port는 5432/tcp 이다.

반응형
저작자표시 비영리 변경금지 (새창열림)

'💾Data > 🧩Database' 카테고리의 다른 글

[MySQL] show_compatibility_56 발생 이유와 해결 방법  (0) 2022.08.13
MySQL Insert시 암호화 복호화  (0) 2021.02.01
PostgreSQL9.x Install  (0) 2021.01.27
MariaDB 10.5 설치  (0) 2020.09.23
MySQL socket Error  (0) 2020.09.16
    '💾Data/🧩Database' 카테고리의 다른 글
    • [MySQL] show_compatibility_56 발생 이유와 해결 방법
    • MySQL Insert시 암호화 복호화
    • PostgreSQL9.x Install
    • MariaDB 10.5 설치
    공개하기부끄러운블로그
    공개하기부끄러운블로그
    IT 기술 블로그

    티스토리툴바