[PostgreSQL] CentOS7 환경에 PostgreSQL Database 설치하기
2023. 3. 15. 14:07
1. https://yum.postgresql.org/ 홈페이지 접속
2. Repository 설치를 위해 'Repo RPMs' 클릭
3. 환경에 맞는 버전 마우스 오른쪽 버튼 - 링크주소 복사
4. Repository 설치
[root@key ~]# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Loaded plugins: fastestmirror, langpacks
pgdg-redhat-repo-latest.noarch.rpm | 8.6 kB 00:00:00
Examining /var/tmp/yum-root-KID3Oy/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-32.noarch
Marking /var/tmp/yum-root-KID3Oy/pgdg-redhat-repo-latest.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-32 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================
Installing:
pgdg-redhat-repo noarch 42.0-32 /pgdg-redhat-repo-latest.noarch 13 k
Transaction Summary
===========================================================================================================================
Install 1 Package
Total size: 13 k
Installed size: 13 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pgdg-redhat-repo-42.0-32.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-32.noarch 1/1
Installed:
pgdg-redhat-repo.noarch 0:42.0-32
Complete!
5. 저장소를 추가한 후 시스템 재부팅 수행 (권고)
# yum -y update
# reboot
6. 활성화 된 저장소 목록 확인
[root@key ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.kakao.com
* epel: mirror-jp.misakamikoto.network
* extras: mirror.kakao.com
* updates: mirror.kakao.com
repo id repo name status
base/7/x86_64 CentOS-7 - Base 10,072
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,768
extras/7/x86_64 CentOS-7 - Extras 515
pgdg-common/7/x86_64 PostgreSQL common RPMs for RHEL / CentOS 7 - x86_64 388
pgdg11/7/x86_64 PostgreSQL 11 for RHEL / CentOS 7 - x86_64 1,451
pgdg12/7/x86_64 PostgreSQL 12 for RHEL / CentOS 7 - x86_64 1,069
pgdg13/7/x86_64 PostgreSQL 13 for RHEL / CentOS 7 - x86_64 821
pgdg14/7/x86_64 PostgreSQL 14 for RHEL / CentOS 7 - x86_64 550
pgdg15/7/x86_64 PostgreSQL 15 for RHEL / CentOS 7 - x86_64 261
updates/7/x86_64 CentOS-7 - Updates 4,839
repolist: 33,734
7. V13 설치 가능 여부 확인
[root@key ~]# yum search postgresql13
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.kakao.com
* epel: mirror-jp.misakamikoto.network
* extras: mirror.kakao.com
* updates: mirror.kakao.com
================================================ N/S matched: postgresql13 ================================================
postgresql13.x86_64 : PostgreSQL client programs and libraries
postgresql13-contrib.x86_64 : Contributed source and binaries distributed with PostgreSQL
postgresql13-devel.x86_64 : PostgreSQL development header files and libraries
postgresql13-docs.x86_64 : Extra documentation for PostgreSQL
postgresql13-libs.x86_64 : The shared libraries required for any PostgreSQL clients
postgresql13-llvmjit.x86_64 : Just-in-time compilation support for PostgreSQL
postgresql13-odbc.x86_64 : PostgreSQL ODBC driver
postgresql13-plperl.x86_64 : The Perl procedural language for PostgreSQL
postgresql13-plpython3.x86_64 : The Python3 procedural language for PostgreSQL
postgresql13-pltcl.x86_64 : The Tcl procedural language for PostgreSQL
postgresql13-server.x86_64 : The programs needed to create and run a PostgreSQL server
postgresql13-test.x86_64 : The test suite distributed with PostgreSQL
Name and summary matches only, use "search all" for everything.
8. PostgreSQL13 패키치 설치
[root@key ~]# yum -y install postgresql13 postgresql13-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.kakao.com
* epel: mirror-jp.misakamikoto.network
* extras: mirror.kakao.com
* updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package postgresql13.x86_64 0:13.10-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql13-libs(x86-64) = 13.10-1PGDG.rhel7 for package: postgresql13-13.10-1PGDG.rhel7.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql13-13.10-1PGDG.rhel7.x86_64
---> Package postgresql13-server.x86_64 0:13.10-1PGDG.rhel7 will be installed
--> Running transaction check
---> Package postgresql13-libs.x86_64 0:13.10-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================
Installing:
postgresql13 x86_64 13.10-1PGDG.rhel7 pgdg13 1.4 M
postgresql13-server x86_64 13.10-1PGDG.rhel7 pgdg13 5.4 M
Installing for dependencies:
postgresql13-libs x86_64 13.10-1PGDG.rhel7 pgdg13 385 k
Transaction Summary
===========================================================================================================================
Install 2 Packages (+1 Dependent package)
Total download size: 7.1 M
Installed size: 31 M
Downloading packages:
경고: /var/cache/yum/x86_64/7/pgdg13/packages/postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Public key for postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm is not installed
(1/3): postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm | 385 kB 00:00:02
(2/3): postgresql13-13.10-1PGDG.rhel7.x86_64.rpm | 1.4 MB 00:00:02
(3/3): postgresql13-server-13.10-1PGDG.rhel7.x86_64.rpm | 5.4 MB 00:00:05
---------------------------------------------------------------------------------------------------------------------------
Total 927 kB/s | 7.1 MB 00:00:07
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
Fingerprint: 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
Package : pgdg-redhat-repo-42.0-32.noarch (@/pgdg-redhat-repo-latest.noarch)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql13-libs-13.10-1PGDG.rhel7.x86_64 1/3
Installing : postgresql13-13.10-1PGDG.rhel7.x86_64 2/3
Installing : postgresql13-server-13.10-1PGDG.rhel7.x86_64 3/3
Verifying : postgresql13-server-13.10-1PGDG.rhel7.x86_64 1/3
Verifying : postgresql13-13.10-1PGDG.rhel7.x86_64 2/3
Verifying : postgresql13-libs-13.10-1PGDG.rhel7.x86_64 3/3
Installed:
postgresql13.x86_64 0:13.10-1PGDG.rhel7 postgresql13-server.x86_64 0:13.10-1PGDG.rhel7
Dependency Installed:
postgresql13-libs.x86_64 0:13.10-1PGDG.rhel7
Complete!
9. 기본 데이터베이스 설정 (초기화)
# sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK
+ 이때, 기본 데이터베이스는 'postgres' 이름으로 생성 됨
10. PostgreSQL 서비스 구동
[root@key ~]# systemctl status postgresql-13
● postgresql-13.service - PostgreSQL 13 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://www.postgresql.org/docs/13/static/
처음에 cmd 입력 했더니 .service도 disabled / Active : inactive (dead) ,,,,
아래와 같이 enable, start 시켜줌
[root@key ~]# sudo systemctl enable postgresql-13
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-13.service to /usr/lib/systemd/system/postgresql-13.service.
[root@key ~]# systemctl start postgresql-13
[root@key ~]# systemctl status postgresql-13
● postgresql-13.service - PostgreSQL 13 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
Active: active (running) since 수 2023-03-15 13:55:21 KST; 4s ago
Docs: https://www.postgresql.org/docs/13/static/
Process: 10788 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 10794 (postmaster)
Tasks: 8
CGroup: /system.slice/postgresql-13.service
├─10794 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
├─10796 postgres: logger
├─10798 postgres: checkpointer
├─10799 postgres: background writer
├─10800 postgres: walwriter
├─10801 postgres: autovacuum launcher
├─10802 postgres: stats collector
└─10803 postgres: logical replication launcher
3월 15 13:55:21 key systemd[1]: Starting PostgreSQL 13 database server...
3월 15 13:55:21 key postmaster[10794]: 2023-03-15 13:55:21.123 KST [10794] 로그: 서버 로그를 로그 수집 프로세스…냅니다.
3월 15 13:55:21 key postmaster[10794]: 2023-03-15 13:55:21.123 KST [10794] 힌트: 이제부터 서버 로그는 "log" 디렉…됩니다.
3월 15 13:55:21 key systemd[1]: Started PostgreSQL 13 database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@key ~]#
11. PostgreSQL 접속
[root@key ~]# su - postgres
-bash-4.2$ psql
psql (13.10)
도움말을 보려면 "help"를 입력하십시오.
'Database > 설치' 카테고리의 다른 글
[MariaDB] 삭제 (0) | 2023.03.16 |
---|---|
[Tibero] CentOS7 환경에 Tibero Database 설치하기(ft. WinSCP) (0) | 2023.03.15 |
[MariaDB] CentOS7 환경에 MariaDB Database 설치하기 (0) | 2023.03.15 |
[MySQL] CentOS7 환경에 MySQL Database 설치하기 (0) | 2023.03.14 |