본문 바로가기
IT

Postgresql Offline Linux(CentOS7) 환경 설치

by 쪼이빠빠 2023. 2. 23.
728x90
반응형
1. 설치 파일 다운로드

postgresql13 - PostgreSQL client programs and libraries
postgresql13-contrib - Contributed source and binaries distributed with PostgreSQL
postgresql13-libs - The shared libraries required for any PostgreSQL clients
postgresql13-server - The programs needed to create and run a PostgreSQL server

RepoView: PostgreSQL PGDG 13 Updates RPMs
https://yum.postgresql.org/13/redhat/rhel-7-x86_64/repoview/postgresqldbserver13.group.html

 

2. 관련 패키지 확인

rpm -qa [패키지명]
gcc gcc-c++ make autoconf wget readline readline-devel zlib zlib-devel openssl openssl-devel gettext gettext-devel python python-devel

rpm -qa gcc
rpm -qa gcc-c++
rpm -qa make
rpm -qa autoconf
rpm -qa wget
rpm -qa readline
rpm -qa readline-devel
rpm -qa zlib
rpm -qa zlib-devel
rpm -qa openssl
rpm -qa openssl-devel
rpm -qa gettext
rpm -qa gettext-devel
rpm -qa python
rpm -qa python-devel

 

3. 설치파일 FTP로 이동

[root@centos7:/data/postgresql/postgresql13_media]ls -lrt
total 7940
-rw-rw-r-- 1 postgres postgres 1485584 Feb 23 10:35 postgresql13-13.10-1PGDG.rhel7.x86_64.rpm
-rw-rw-r-- 1 postgres postgres  629284 Feb 23 10:35 postgresql13-contrib-13.10-1PGDG.rhel7.x86_64.rpm
-rw-rw-r-- 1 postgres postgres  393964 Feb 23 10:35 postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm
-rw-rw-r-- 1 postgres postgres 5615388 Feb 23 10:35 postgresql13-server-13.10-1PGDG.rhel7.x86_64.rpm

 

4. rpm 설치

설치순서

postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm

postgresql13-13.10-1PGDG.rhel7.x86_64.rpm

postgresql13-server-13.10-1PGDG.rhel7.x86_64.rpm

postgresql13-contrib-13.10-1PGDG.rhel7.x86_64.rpm

 

[root@centos7:/data/postgresql/postgresql13_media]rpm -ivh postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:postgresql13-libs-13.10-1PGDG.rhe################################# [100%]
[root@centos7:/data/postgresql/postgresql13_media]rpm -ivh postgresql13-13.10-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-13.10-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:postgresql13-13.10-1PGDG.rhel7   ################################# [100%]
[root@centos7:/data/postgresql/postgresql13_media]rpm -ivh postgresql13-server-13.10-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-server-13.10-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:postgresql13-server-13.10-1PGDG.r################################# [100%]
[root@centos7:/data/postgresql/postgresql13_media]rpm -ivh postgresql13-contrib-13.10-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-contrib-13.10-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:postgresql13-contrib-13.10-1PGDG.################################# [100%]

5. 엔진 경로 변경(필요할 경우)

[root@centos7:/data/postgresql/postgresql13_media]cp -R /usr/pgsql-13/* /data/postgresql/pgsql

6. 엔진 경로 소유권 변경

[root@centos7:/data/postgresql/postgresql13_media]chown -R postgres:postgres /data/postgresql/pgsql

7. postgres(OS 계정) 환경 설정 파일 수정

[postgres@centos7:~]vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

export PGDATA=/data/postgresql/data
export PGHOME=/data/postgresql/pgsql
export LD_LIBRARY_PATH=$PGHOME/lib

PATH=$PATH:$HOME/.local/bin:$HOME/bin:$PGHOME/bin

export PATH

8. 프로파일 적용

[postgres@centos7:~]. .bash_profile

9. 데이터베이스 경로 생성(PGDATA)

[postgres@centos7:~]mkdir /data/postgresql/data

10. 데이터베이스 생성

[postgres@centos7:/data/postgresql/pgsql/bin]initdb -D /data/postgresql/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /data/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Seoul
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /data/postgresql/data -l logfile start

11. 데이터베이스 생성 확인

[postgres@centos7:/data/postgresql/pgsql/bin]cd $PGDATA
[postgres@centos7:/data/postgresql/data]ls -lrt
total 52
-rw------- 1 postgres postgres     3 Feb 23 14:06 PG_VERSION
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_twophase
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_tblspc
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_stat_tmp
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_stat
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_snapshots
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_serial
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_replslot
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_notify
drwx------ 4 postgres postgres    36 Feb 23 14:06 pg_multixact
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_dynshmem
drwx------ 2 postgres postgres     6 Feb 23 14:06 pg_commit_ts
-rw------- 1 postgres postgres 28085 Feb 23 14:06 postgresql.conf
-rw------- 1 postgres postgres    88 Feb 23 14:06 postgresql.auto.conf
-rw------- 1 postgres postgres  1636 Feb 23 14:06 pg_ident.conf
-rw------- 1 postgres postgres  4760 Feb 23 14:06 pg_hba.conf
drwx------ 2 postgres postgres    18 Feb 23 14:06 pg_xact
drwx------ 3 postgres postgres    60 Feb 23 14:06 pg_wal
drwx------ 2 postgres postgres    18 Feb 23 14:06 pg_subtrans
drwx------ 2 postgres postgres  4096 Feb 23 14:06 global
drwx------ 5 postgres postgres    41 Feb 23 14:06 base
drwx------ 4 postgres postgres    68 Feb 23 14:06 pg_logical

12. 데이터베이스 Start

[postgres@centos7:/data/postgresql/data]pg_ctl -D $PGDATA -l logfile start
waiting for server to start....2023-02-23 14:06:33.455 KST [27176] LOG:  redirecting log output to logging collector process
2023-02-23 14:06:33.455 KST [27176] HINT:  Future log output will appear in directory "log".
 done
server started
[postgres@centos7:/data/postgresql/data]psql
psql (13.10)
Type "help" for help.

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

postgres=# exit

반응형

댓글