반응형
[PostgreSQL] Rocky Linux 8.7에 PostgreSQL 14 설치 가이드
OS 환경
Rocky Linux 8.7
DB 환경
PostgreSQL 14
사전작업
locale 설정
[root@rocky1 ~]# export LANG=c
설치
Repository 추가
# PostgreSQL 최신 설치를 위해 Repository를 연결
[root@rocky1 ~]# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Rocky Linux 8 - AppStream 2.6 MB/s | 11 MB 00:04
Rocky Linux 8 - BaseOS 3.8 MB/s | 6.0 MB 00:01
Rocky Linux 8 - Extras 12 kB/s | 13 kB 00:01
pgdg-redhat-repo-latest.noarch.rpm 9.8 kB/s | 13 kB 00:01
종속성이 해결되었습니다.
========================================================================================================
꾸러미 구조 버전 레포지터리 크기
========================================================================================================
설치 중:
pgdg-redhat-repo noarch 42.0-34PGDG @commandline 13 k
연결 요약
========================================================================================================
설치 1 꾸러미
전체 크기: 13 k
설치된 크기 : 15 k
꾸러미 내려받기 중:
연결 확인 실행 중
연결 확인에 성공했습니다.
연결 시험 실행 중
연결 시험에 성공했습니다.
연결 실행 중
준비 중 : 1/1
설치 중 : pgdg-redhat-repo-42.0-34PGDG.noarch 1/1
확인 중 : pgdg-redhat-repo-42.0-34PGDG.noarch 1/1
설치되었습니다:
pgdg-redhat-repo-42.0-34PGDG.noarch
완료되었습니다!
postgresql 모듈 사용 중지(기본내장)
[root@rocky1 ~]# dnf -qy module disable postgresql
Failed to set locale, defaulting to C.UTF-8
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
From : /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
From : /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
From : /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
From : /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
From : /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
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
반응형
PostgreSQL 14 설치
# 추가한 repository를 활용해 배포된 버전의 postgresql 14를 설치
[root@rocky1 ~]# dnf install -y postgresql14-server
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:04:56 ago on Tue Aug 22 10:20:38 2023.
Dependencies resolved.
========================================================================================================
Package Architecture Version Repository Size
========================================================================================================
Installing:
postgresql14-server x86_64 14.9-2PGDG.rhel8 pgdg14 5.7 M
Installing dependencies:
lz4 x86_64 1.8.3-3.el8_4 baseos 102 k
postgresql14 x86_64 14.9-2PGDG.rhel8 pgdg14 1.5 M
postgresql14-libs x86_64 14.9-2PGDG.rhel8 pgdg14 280 k
Transaction Summary
========================================================================================================
Install 4 Packages
Total download size: 7.6 M
Installed size: 32 M
Downloading Packages:
(1/4): lz4-1.8.3-3.el8_4.x86_64.rpm 1.0 MB/s | 102 kB 00:00
(2/4): postgresql14-libs-14.9-2PGDG.rhel8.x86_64.rpm 104 kB/s | 280 kB 00:02
(3/4): postgresql14-14.9-2PGDG.rhel8.x86_64.rpm 304 kB/s | 1.5 MB 00:05
(4/4): postgresql14-server-14.9-2PGDG.rhel8.x86_64.rpm 1.0 MB/s | 5.7 MB 00:05
--------------------------------------------------------------------------------------------------------
Total 1.2 MB/s | 7.6 MB 00:06
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : postgresql14-libs-14.9-2PGDG.rhel8.x86_64 1/4
Running scriptlet: postgresql14-libs-14.9-2PGDG.rhel8.x86_64 1/4
Installing : lz4-1.8.3-3.el8_4.x86_64 2/4
Installing : postgresql14-14.9-2PGDG.rhel8.x86_64 3/4
Running scriptlet: postgresql14-14.9-2PGDG.rhel8.x86_64 3/4
Running scriptlet: postgresql14-server-14.9-2PGDG.rhel8.x86_64 4/4
Installing : postgresql14-server-14.9-2PGDG.rhel8.x86_64 4/4
Running scriptlet: postgresql14-server-14.9-2PGDG.rhel8.x86_64 4/4
Verifying : lz4-1.8.3-3.el8_4.x86_64 1/4
Verifying : postgresql14-14.9-2PGDG.rhel8.x86_64 2/4
Verifying : postgresql14-libs-14.9-2PGDG.rhel8.x86_64 3/4
Verifying : postgresql14-server-14.9-2PGDG.rhel8.x86_64 4/4
Installed:
lz4-1.8.3-3.el8_4.x86_64 postgresql14-14.9-2PGDG.rhel8.x86_64
postgresql14-libs-14.9-2PGDG.rhel8.x86_64 postgresql14-server-14.9-2PGDG.rhel8.x86_64
Complete!
[root@rocky1 ~]#
PostgreSQL 초기화 설치
# 기본 설치위치 /var/lib/pgsql/14/data
[root@rocky1 ~]# /usr/pgsql-14/bin/postgresql-14-setup initdb
Initializing database ... OK
[root@rocky1 ~]#
systemctl 서비스 등록
# postgresql로 기동할 수 있게 심볼릭 링크 설정
[root@rocky1 ~]# systemctl status postgresql-14
● postgresql-14.service - PostgreSQL 14 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://www.postgresql.org/docs/14/static/
[root@rocky1 ~]# ln -s /usr/lib/systemd/system/postgresql-14.service /usr/lib/systemd/system/postgresql.service
[root@rocky1 ~]#
[root@rocky1 ~]# systemctl status postgresql
● postgresql-14.service - PostgreSQL 14 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://www.postgresql.org/docs/14/static/
[root@rocky1 ~]#
[root@rocky1 ~]# systemctl enable postgresql
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-14.service → /usr/lib/systemd/system/postgresql-14.service.
PostgreSQL 기동
[root@rocky1 ~]# systemctl start postgresql
[root@rocky1 ~]# systemctl status postgresql
● postgresql-14.service - PostgreSQL 14 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2023-08-22 10:39:10 KST; 6s ago
Docs: https://www.postgresql.org/docs/14/static/
Process: 29731 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, stat>
Main PID: 29736 (postmaster)
Tasks: 8 (limit: 23648)
Memory: 16.7M
CGroup: /system.slice/postgresql-14.service
├─29736 /usr/pgsql-14/bin/postmaster -D /var/lib/pgsql/14/data/
├─29738 postgres: logger
├─29740 postgres: checkpointer
├─29741 postgres: background writer
├─29742 postgres: walwriter
├─29743 postgres: autovacuum launcher
├─29744 postgres: stats collector
└─29745 postgres: logical replication launcher
Aug 22 10:39:10 rocky1 systemd[1]: Starting PostgreSQL 14 database server...
Aug 22 10:39:10 rocky1 postmaster[29736]: 2023-08-22 10:39:10.648 KST [29736] 로그: 서버 로그를 로그 >
Aug 22 10:39:10 rocky1 postmaster[29736]: 2023-08-22 10:39:10.648 KST [29736] 힌트: 이제부터 서버 로그>
Aug 22 10:39:10 rocky1 systemd[1]: Started PostgreSQL 14 database server.
[root@rocky1 ~]#
PostgreSQL 접속
# PostgreSQL에 접속하려면 설치된 postgres 유저로 변경 후 접근
[root@rocky1 ~]# su - postgres
[postgres@rocky1 ~]$
[postgres@rocky1 ~]$ psql
psql (14.9)
도움말을 보려면 "help"를 입력하십시오.
postgres=#
PostgreSQL 유저 생성
postgres=# create role test with login nosuperuser password 'test';
CREATE ROLE
postgres=#
데이터베이스 생성
# testdb라는 명칭의 소유자는 test 인코딩 타입은 'UTF-8'
postgres=# create database testdb with owner = test encoding = 'UTF8';
CREATE DATABASE
postgres=#
데이터베이스 조회
postgres=# \l
데이터베이스 목록
이름 | 소유주 | 인코딩 | Collate | Ctype | 액세스 권한
-----------+----------+--------+-------------+-------------+-----------------------
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
testdb | test | UTF8 | ko_KR.UTF-8 | ko_KR.UTF-8 |
(4개 행)
postgres=#
반응형
'PostgreSQL' 카테고리의 다른 글
| [PostgreSQL] PostgreSQL 13 Primary/standby 이중화(HA) 구성 (0) | 2023.09.13 |
|---|---|
| [PostgreSQL] PostgreSQL 기초 Database 및 User 생성 (0) | 2023.09.04 |
| [PostgreSQL] Database Owner(소유주) 변경 (0) | 2023.08.29 |
| [PostgreSQL] 현재 사용자 및 현재 사용중인 DB name 확인 (0) | 2023.08.29 |