Linux/개인 공부

[ Linux ] Rocky 8.9에 PostgreSQL16.1.2 설치해보기

코딩하는냥이 2025. 12. 1. 15:41
반응형

https://download.postgresql.org/pub/repos/yum/16/redhat/rhel-9-x86_64/

 

Index of /pub/repos/yum/16/redhat/rhel-9-x86_64/

 

download.postgresql.org

 

해당 주소에서 필요한 rpm 설치

postgresql16-16.1-2PGDG.rhel9.x86_64.rpm
postgresql16-server-16.1-2PGDG.rhel9.x86_64.rpm
postgresql16-contrib-16.1-2PGDG.rhel9.x86_64.rpm
postgresql16-devel-16.1-2PGDG.rhel9.x86_64.rpm
postgresql16-docs-16.1-2PGDG.rhel9.x86_64.rpm
postgresql16-libs-16.1-2PGDG.rhel9.x86_64.rpm

 

useradd -G wheel postgres

# 유저 postgres 생성
# 그룹 wheel에 생성

 

# 혹시 모르니 권한 부여
chmod -R 755 ./*

# libs -> postgresql -> server -> contrib -> devel -> docs 순으로 설치
dnf install ./postgresql16-libs-16.1-2PGDG.rhel9.x86_64.rpm
dnf install ./postgresql16-16.1-2PGDG.rhel9.x86_64.rpm
dnf install ./postgresql16-server-16.1-2PGDG.rhel9.x86_64.rpm
dnf install ./postgresql16-contrib-16.1-2PGDG.rhel9.x86_64.rpm
dnf install ./postgresql16-devel-16.1-2PGDG.rhel9.x86_64.rpm

 

# 만약 중간에 EPEL 저장소(epel-release) 문제가 생긴다면
dnf install -y epel_release
dnf install -y perl-IPC-Run

# 하지만 필자는 여기서 perl-IPC-Run이 깔리지 않았는데..
# 1. CRB 활성화
/usr/bin/crb enable
dnf clean all
dnf makecache

# 2. perl(IPC::Run)을 제공하는 패키지 탐색
dnf provides "perl(IPC::Run)"
dnf install -y perl-IPC-Run

# 3. 다시 설치 진행
dnf install -y ...

 

# 설치가 완료되었다면 PostgreSQL DB를 초기화한다.
/usr/pgsql-16/bin/postgresql-16-setup initdb
# 결과 : Initializing database ... OK

# 그리고 PostgreSQL DB 활성화
systemctl start postgresql-16.service

 

[root@localhost postgresql]# su postgres
[postgres@localhost postgresql]$ psql -c 'select version();'
                                                 version

--------------------------------------------------------------------------------
-------------------------
 PostgreSQL 16.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (R
ed Hat 8.5.0-18), 64-bit
(1개 행)

마지막으로 성공적으로 동작하는 모습