메뉴 건너뛰기

Korea Oracle User Group

DBMS

PostgreSQL 16 설치하기(Installation)

이번 설치에서는 소스 파일을 build 하여 설치하는 방식으로 진행합니다.

 

0. 설치 환경

 

플랫폼 : 오라클 리눅스
Version : 8.2 Enterprise Linux
CPU : 2 core
Memory : 8 GB
OS : Oracle Linux 8.2
Swap : 16 GB

 

Linux OS 설치시 Software Selection 에서 아래 내용으로 패키지 설치하였습니다.

설치시 GNU make 버전 3.81 이상이여야 하기에 확인이 필요하다

 

[root@testpost ~]# make --version
GNU Make 4.2.1
x86_64-redhat-linux-gnu 빌드
Copyright (C) 1988-2016 Free Software Foundation, Inc.
라이선스 GPLv3+: GNU GPL 버전 3 또는 이후 <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@testpost ~]# 

 

1. 그룹 및 유저 생성

 

groupadd postgres
useradd -d /home/postgres -g postgres -m postgres

 

2. PostgreSQL 설치 파일 압축 풀기

 

[postgres@testpost ~]$ mkdir ./postgreSQL16
[postgres@testpost ~]$ tar xvf postgresql-16.1.tar.gz
[postgres@testpost ~]$ ls -al
합계 31700
drwx------. 6 postgres postgres      200  1월 23 17:12 .
drwxr-xr-x. 4 root     root           34  1월 23 17:01 ..
-rw-------. 1 postgres postgres       12  1월 23 17:08 .bash_history
-rw-r--r--. 1 postgres postgres       18  8월  2  2022 .bash_logout
-rw-r--r--. 1 postgres postgres      141  8월  2  2022 .bash_profile
-rw-r--r--. 1 postgres postgres      376  8월  2  2022 .bashrc
drwx------. 2 postgres postgres        6  1월 23 17:01 .cache
drwxr-xr-x. 4 postgres postgres       39  4월  1  2022 .mozilla
-rw-r--r--. 1 postgres postgres      658 10월  2  2022 .zshrc
drwxrwxr-x. 2 postgres postgres        6  1월 23 17:11 postgreSQL16
drwxrwxr-x. 6 postgres postgres     4096 11월  7 07:18 postgresql-16.1
-rw-r--r--. 1 postgres postgres 32433767  1월 23 16:17 postgresql-16.1.tar.gz

 

3. 소스 트리 생성을 위해 Configuration 수행

아래와 같이 다운 받은 설치 파일을 풀 위치에서 configure 명령어를 수행합니다. prefix를 통해 엔진 설치에 빌드 생성 위치를 지정해 줍니다.

 

[postgres@testpost postgreSQL16]$ /home/postgres/postgresql-16.1/configure --prefix=/home/postgres/postgreSQL16
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gcc option to accept ISO C99... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gawk... gawk
checking whether gcc supports -Wdeclaration-after-statement, for CFLAGS... yes
checking whether gcc supports -Werror=vla, for CFLAGS... yes
checking whether gcc supports -Werror=unguarded-availability-new, for CFLAGS... no
checking whether g++ supports -Werror=unguarded-availability-new, for CXXFLAGS... no
checking whether gcc supports -Wendif-labels, for CFLAGS... yes
checking whether g++ supports -Wendif-labels, for CXXFLAGS... yes
checking whether gcc supports -Wmissing-format-attribute, for CFLAGS... yes
checking whether g++ supports -Wmissing-format-attribute, for CXXFLAGS... yes
checking whether gcc supports -Wimplicit-fallthrough=3, for CFLAGS... yes
checking whether g++ supports -Wimplicit-fallthrough=3, for CXXFLAGS... yes
checking whether gcc supports -Wcast-function-type, for CFLAGS... yes
checking whether g++ supports -Wcast-function-type, for CXXFLAGS... yes
checking whether gcc supports -Wshadow=compatible-local, for CFLAGS... yes
checking whether g++ supports -Wshadow=compatible-local, for CXXFLAGS... yes
checking whether gcc supports -Wformat-security, for CFLAGS... yes
checking whether g++ supports -Wformat-security, for CXXFLAGS... yes
checking whether gcc supports -fno-strict-aliasing, for CFLAGS... yes
checking whether g++ supports -fno-strict-aliasing, for CXXFLAGS... yes
checking whether gcc supports -fwrapv, for CFLAGS... yes
checking whether g++ supports -fwrapv, for CXXFLAGS... yes
checking whether gcc supports -fexcess-precision=standard, for CFLAGS... yes
checking whether g++ supports -fexcess-precision=standard, for CXXFLAGS... no
checking whether gcc supports -funroll-loops, for CFLAGS_UNROLL_LOOPS... yes
checking whether gcc supports -ftree-vectorize, for CFLAGS_VECTORIZE... yes
checking whether gcc supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... no
checking whether gcc supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... no
checking whether gcc supports -Wformat-truncation, for NOT_THE_CFLAGS... yes
checking whether gcc supports -Wstringop-truncation, for NOT_THE_CFLAGS... yes
checking whether gcc supports -Wcast-function-type-strict, for NOT_THE_CFLAGS... no
checking whether gcc supports -fvisibility=hidden, for CFLAGS_SL_MODULE... yes
checking whether g++ supports -fvisibility=hidden, for CXXFLAGS_SL_MODULE... yes
checking whether g++ supports -fvisibility-inlines-hidden, for CXXFLAGS_SL_MODULE... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking allow thread-safe client libraries... yes
checking whether to build with ICU support... yes
checking for icu-uc icu-i18n... no
configure: error: ICU library not found
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.
[postgres@testpost postgreSQL16]$ 

 

위와 같이 configuration시 점검을 먼저 진행하는데 ICU library not found라는 이슈가 발생했습니다.

여기에 표시는 하지 않았지만 이슈 회피 후 재점검시 error: readline library not found 도 발생했습니다.

해당 부분은 --without 옵션으로 이슈 회피 후 설치 가능합니다.

해서 아래와 같이 다시 configuration 실행을 합니다.

 

[postgres@testpost postgreSQL16]$ /home/postgres/postgresql-16.1/configure --prefix=/home/postgres/postgreSQL16 --without-icu --without-readline
...
...
...
checking for fop... no
checking for dbtoepub... no
checking whether gcc supports -Wl,--as-needed, for LDFLAGS... yes
checking whether gcc supports -Wl,--export-dynamic, for LDFLAGS_EX_BE... yes
configure: using compiler=gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20.0.2)
configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement ...
configure: using CPPFLAGS= -D_GNU_SOURCE 
configure: using LDFLAGS=  -Wl,--as-needed
preparing build tree... done
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/include/pg_config_ext.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking /home/postgres/postgresql-16.1/src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking /home/postgres/postgresql-16.1/src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
config.status: linking /home/postgres/postgresql-16.1/src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking /home/postgres/postgresql-16.1/src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking /home/postgres/postgresql-16.1/src/makefiles/Makefile.linux to src/Makefile.port
[postgres@testpost postgreSQL16]$

 

위와 같이 configuration이 정상적으로 완료되었습니다.

 

4. 빌드 수행

빌드를 위해서는 make, make all, make world, make world-bin 중 한가지 방식을 선택하면 된다.

각 방식 별로 빌드되는 범위가 달라지니 필요한 빌드 방식을 사용하시면 됩니다. 

관련 내용은 다음을 참고하시기 바랍니다. 

https://www.postgresql.org/docs/current/install-make.html

 

우리는 make world를 사용하도록 하겠습니다.

configure를 통해 만들어지 소스 트리를 사용하기 위해 /home/ postgres/postgreSQL16에서 아래 명령어를 수행합니다.

 

[postgres@testpost postgreSQL16]$ make world

 

설치 전 build 버전 테스트를 수행해 봅니다.

 

[postgres@testpost postgreSQL16]$ make check
...
...
...
ok 210       + memoize                                   437 ms
ok 211       + stats                                    1716 ms
# parallel group (2 tests):  event_trigger oidjoins
ok 212       + event_trigger                             157 ms
ok 213       + oidjoins                                  241 ms
ok 214       - fast_default                              377 ms
ok 215       - tablespace                                465 ms
1..215
# All 215 tests passed.
make[1]: 디렉터리 '/home/postgres/postgreSQL16/src/test/regress' 나감
[postgres@testpost postgreSQL16]$ 

 

5. PostgreSQL Server 설치

Build된 파일이 있는 디렉토리(/home/postgres/postgreSQL16)에서 설치 수행

make install, make install-docs, make install-world, make install-world-bin 과 같은 방식으로 설치를 진행할 수 있습니다.

자세한 사항은 아래 링크를 참조하세요

https://www.postgresql.org/docs/current/install-make.html

 

[postgres@testpost postgreSQL16]$ make install-world
...
...
...
make -C vacuumlo install
make[2]: 디렉터리 '/home/postgres/postgreSQL16/contrib/vacuumlo' 들어감
/usr/bin/mkdir -p '/home/postgres/postgreSQL16/bin'
/usr/bin/install -c  vacuumlo '/home/postgres/postgreSQL16/bin'
make[2]: 디렉터리 '/home/postgres/postgreSQL16/contrib/vacuumlo' 나감
make[1]: 디렉터리 '/home/postgres/postgreSQL16/contrib' 나감
[postgres@testpost postgreSQL16]$ 

 

6. 설치 후 필요한 몇 가지 설정

.bash_profile 파일을 아래 라인 추가 수정

 

export LD_LIBRARY_PATH=/home/postgres/postgreSQL16/bin
export PATH=/home/postgres/postgreSQL16/bin:$PATH
export MANPATH=/home/postgres/postgreSQL16/share/man:$MANPATH

 

7. 초기 DB 생성(매뉴얼에서 이야기하는 Database Cluster 생성)

먼저 데이터 파일이 설치될 디렉토리와 로그 파일을 저장할 디렉토리를 생성합니다.

그리고 초기 DB 생성하도록 하겠습니다. 

 

[postgres@testpost ~]$ pwd
/home/postgres
[postgres@testpost ~]$ mkdir postgresql_data
[postgres@testpost ~]$ mkdir /home/postgres/postgreSQL16/log
[postgres@testpost ~]$ which initdb
~/postgreSQL16/bin/initdb
[postgres@testpost ~]$ initdb -D /home/postgres/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 "ko_KR.UTF-8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "ko_KR.UTF-8"
The default text search configuration will be set to "simple".
 
Data page checksums are disabled.
 
fixing permissions on existing directory /home/postgres/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
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or ...
 
Success. You can now start the database server using:
 
    pg_ctl -D /home/postgres/postgresql_data -l logfile start
 
[postgres@testpost ~]$ 

 

위 초기 DB 생성은 아래의 명령어를 통해서도 수행할 수 있습니다.

 

pg_ctl -D /home/postgres/postgresql_data initdb

 

8. 서버 기동 및 로그 확인

 

[postgres@testpost ~]$ pg_ctl start -l /home/postgres/postgreSQL16/log/postgresql.log -D /home/postgres/postgresql_data
waiting for server to start.... done
server started
[postgres@testpost ~]$ cat /home/postgres/postgreSQL16/log/postgresql.log 
2024-01-23 19:29:13.537 KST [33601] LOG:  starting PostgreSQL 16.1 on x86_64-pc-linux-gnu, compiled by gcc ...
2024-01-23 19:29:13.540 KST [33601] LOG:  listening on IPv6 address "::1", port 5432
2024-01-23 19:29:13.540 KST [33601] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2024-01-23 19:29:13.555 KST [33601] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2024-01-23 19:29:13.561 KST [33604] LOG:  database system was shut down at 2024-01-23 19:19:01 KST
2024-01-23 19:29:13.566 KST [33601] LOG:  database system is ready to accept connections
[postgres@testpost log]$

 

9. 설치 정보 확인 및 Extension 확인, ps_stat_statements extension 설치

 

[postgres@testpost log]$ psql
psql (16.1)
Type "help" for help.
 
-- 버전 정보 확인
postgres=# select version();
                                                   version                                                   
-------------------------------------------------------------------------------------------------------------
 PostgreSQL 16.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20.0.2), 64-bit
(1 row)
 
-- DB 리스크 조회
postgres=# \l
                                                       List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | ICU Locale | ICU Rules |   Access privileges   
-----------+----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------
 postgres  | postgres | UTF8     | libc            | ko_KR.UTF-8 | ko_KR.UTF-8 |            |           | 
 template0 | postgres | UTF8     | libc            | ko_KR.UTF-8 | ko_KR.UTF-8 |            |           | =c/postgres          +
           |          |          |                 |             |             |            |           | postgres=CTc/postgres
 template1 | postgres | UTF8     | libc            | ko_KR.UTF-8 | ko_KR.UTF-8 |            |           | =c/postgres          +
           |          |          |                 |             |             |            |           | postgres=CTc/postgres
(3 rows)
 
-- 현재 설치 가능한 Extension 조회
postgres=# select * from pg_available_extensions;
        name        | default_version | installed_version |                                comment                                 
--------------------+-----------------+-------------------+------------------------------------------------------------------------
 plpgsql            | 1.0             | 1.0               | PL/pgSQL procedural language
 adminpack          | 2.1             |                   | administrative functions for PostgreSQL
 amcheck            | 1.3             |                   | functions for verifying relation integrity
 bloom              | 1.0             |                   | bloom access method - signature file based index
 btree_gin          | 1.3             |                   | support for indexing common datatypes in GIN
 btree_gist         | 1.7             |                   | support for indexing common datatypes in GiST
 citext             | 1.6             |                   | data type for case-insensitive character strings
 cube               | 1.5             |                   | data type for multidimensional cubes
 dblink             | 1.2             |                   | connect to other PostgreSQL databases from within a database
 dict_int           | 1.0             |                   | text search dictionary template for integers
 dict_xsyn          | 1.0             |                   | text search dictionary template for extended synonym processing
 earthdistance      | 1.1             |                   | calculate great-circle distances on the surface of the Earth
 file_fdw           | 1.0             |                   | foreign-data wrapper for flat file access
 fuzzystrmatch      | 1.2             |                   | determine similarities and distance between strings
 hstore             | 1.8             |                   | data type for storing sets of (key, value) pairs
 intagg             | 1.1             |                   | integer aggregator and enumerator (obsolete)
 intarray           | 1.5             |                   | functions, operators, and index support for 1-D arrays of integers
 isn                | 1.2             |                   | data types for international product numbering standards
 lo                 | 1.1             |                   | Large Object maintenance
 ltree              | 1.2             |                   | data type for hierarchical tree-like structures
 old_snapshot       | 1.0             |                   | utilities in support of old_snapshot_threshold
 pageinspect        | 1.12            |                   | inspect the contents of database pages at a low level
 pg_buffercache     | 1.4             |                   | examine the shared buffer cache
 pg_freespacemap    | 1.2             |                   | examine the free space map (FSM)
 pg_prewarm         | 1.2             |                   | prewarm relation data
 pg_stat_statements | 1.10            |                   | track planning and execution statistics of all SQL statements executed
 pg_surgery         | 1.0             |                   | extension to perform surgery on a damaged relation
 pg_trgm            | 1.6             |                   | text similarity measurement and index searching based on trigrams
 pgrowlocks         | 1.2             |                   | show row-level locking information
 pgstattuple        | 1.5             |                   | show tuple-level statistics
 pg_visibility      | 1.2             |                   | examine the visibility map (VM) and page-level visibility info
 pg_walinspect      | 1.1             |                   | functions to inspect contents of PostgreSQL Write-Ahead Log
 postgres_fdw       | 1.1             |                   | foreign-data wrapper for remote PostgreSQL servers
 seg                | 1.4             |                   | data type for representing line segments or floating-point intervals
 autoinc            | 1.0             |                   | functions for autoincrementing fields
 insert_username    | 1.0             |                   | functions for tracking who changed a table
 moddatetime        | 1.0             |                   | functions for tracking last modification time
 refint             | 1.0             |                   | functions for implementing referential integrity (obsolete)
 tablefunc          | 1.0             |                   | functions that manipulate whole tables, including crosstab
 tcn                | 1.0             |                   | Triggered change notifications
 tsm_system_rows    | 1.0             |                   | TABLESAMPLE method which accepts number of rows as a limit
 tsm_system_time    | 1.0             |                   | TABLESAMPLE method which accepts time in milliseconds as a limit
 unaccent           | 1.1             |                   | text search dictionary that removes accents
(43 rows)
 
--설치된 Extension 조회
postgres=# select * from pg_extension;
  oid  | extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition 
-------+---------+----------+--------------+----------------+------------+-----------+--------------
 12813 | plpgsql |       10 |           11 | f              | 1.0        |           | 
(1 row)
 
--사용 가능한 extension 설치
postgres=# create extension pg_stat_statements;
CREATE EXTENSION
postgres=# select * from pg_extension;
  oid  |      extname       | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition 
-------+--------------------+----------+--------------+----------------+------------+-----------+--------------
 12813 | plpgsql            |       10 |           11 | f              | 1.0        |           | 
 16388 | pg_stat_statements |       10 |         2200 | t              | 1.10       |           | 
(2 rows)
 
postgres=# quit
[postgres@testpost log]$ 

 

위와 같이 설치된 PostgreSQL의 버전을 확인하고 Extension 중 ps_stat_statement 를 설치해 봤습니다.

 

10. 결론

PostgreSQL의 소스 파일을 빌드하여 설치하는 부분을 알아봤습니다.

진행중에 크게 어려운 부분은 없었으며 이슈가 발생할 경우 나오는 내용과 문구를 잘 살펴서 해결 방안을 찾으면 크게 문제 없으리라 생각이 듭니다.

 

번호 제목 글쓴이 날짜 조회 수
» PostgreSQL 16 설치하기(Installation) [1] 명품관 2024.01.24 421
18 Top-Rated PostgreSQL GUI Clients for Windows 명품관 2023.05.10 96
17 기동시 "Job for mysqld.service failed because the control process exited with error code." 에러로 기동 실패 명품관 2020.09.03 7923
16 MySQL 8.0 Reference Manual - MySQL Server Administration2 - Server Configuration Validation 명품관 2020.04.17 419
15 MySQL 8.0 Reference Manual - MySQL Server Administration1 - Configuring the Server 명품관 2020.03.05 9598
14 MySQL 8.0 Reference Manual - Tutorial - Creating and Using a Database4 명품관 2020.03.03 254
13 MySQL 8.0 Reference Manual - Tutorial - Creating and Using a Database3 명품관 2020.03.02 418
12 Windows 버전 MySQL의 my.ini 파일 찾기 file 명품관 2020.03.01 13302
11 MySQL 8.0 Reference Manual - Tutorial - Creating and Using a Database2 명품관 2020.02.29 235
10 MySQL 8.0 Reference Manual - Tutorial - Creating and Using a Database1 명품관 2020.02.28 190
9 MySQL 8.0 Reference Manual - Tutorial - Entering Queries 명품관 2020.02.28 202
8 MySQL 8.0 Reference Manual - Tutorial - Connecting to and Disconnecting from the Server 명품관 2020.02.27 193
7 MySQL Admin - 01 명품관 2019.10.08 704
6 How to Install MariaDB 10 on RHEL 8 [2] 명품관 2019.01.31 254
5 MySQL 설치 후 외부 접속 허용하기 명품관 2016.09.09 2844
4 CentOS 6.7 에서 MySQL 5.7 설치 명품관 2016.09.09 13792
3 티베로 trace log 중 ERROR_PSM_COMPILE_FAILED 에러란 명품관 2016.09.06 11434
2 DP, DPL, DPI에 관한trace log 내용 분석 명품관 2016.09.06 1038
1 티베로 에러 내용 확인 방법 명품관 2016.08.26 10742
위로