O2๋ PostgreSQL ํ๊ฒฝ์์ ์ค๋ผํด์ด ์ง์ํ๋ ํจ์/ํจํค์ง/ํ์ ๋ค๊ณผ ํธํ๋๋ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํ์ฌ ์ฌ์ฉ์๋ค์ ํธ์๋ฅผ ํฅ์์ํค๋ PostgreSQL Extension ์ ๋๋ค.
OpenSQL์์ ์ง์ํ๋ ์ด์์ฒด์ /ํ๋์จ์ด ์ฌ์๊ณผ ๋์ผํฉ๋๋ค.
O2 Extension์์๋ ์ ํ ์ค์น๋ฅผ ์ํ ๋ฐฉ๋ฒ์ ๋ค์์ 2๊ฐ์ง ์ค์น ํํ๋ก ์ ๊ณตํ๊ณ ์์ต๋๋ค.
make ๋ฐฉ์์ผ๋ก ์ค์น
shell ๋ฐฉ์์ผ๋ก ์ค์น
OpenSQL ์ค์น ํจํค์ง ๋ด๋ถ์ ๋๋ด๋ O2 ์ค์นํ์ผ ๋ชจ์ ๋๋ ํ ๋ฆฌ๋ ์๋์ ๊ฐ์ ํ์์ผ๋ก ์ ๊ณต๋ฉ๋๋ค.
๋ด๋ถ์๋ 2๊ฐ์ง ์ค์น๋ฐฉ๋ฒ์ ์ํ ํ์ผ(Makefile, install.sh)๋ค์ด ์ ๊ณต๋ฉ๋๋ค.
PostgreSQL๊ฐ ์ค์น๋ Linux ํ๋ซํผ์์ O2 Extension์ make ์ปค๋งจ๋๋ฅผ ํตํด ์๋์ผ๋ก ์ค์นํ ์ ์์ต๋๋ค
O2 Extension์ด ํฌํจํ๋ ๋ชจ๋ Extension์ ๋์ ์ค์นํ๋ ์ ์ฒด ์ค์น, ๊ฐ๋ณ Extension์ ์ค์นํ๋ ๊ฐ๋ณ ์ค์น๋ก ๊ตฌ๋ถํฉ๋๋ค.
PostgreSQL์ด ์ค์น๊ฐ ๋์ด์๊ณ , ํฐ๋ฏธ๋ ๋ช
๋ น์ค์์ make, pg_config ์ปค๋งจ๋๊ฐ ์ฌ์ฉ ๊ฐ๋ฅํ ์ํ์ฌ์ผ ํฉ๋๋ค.
O2 Extension ์ค์น ๊ตฌ์ฑ ์์๊ฐ ๋ชจ์ฌ ์๋ ๋๋ ํ ๋ฆฌ(Makefile ์ด ์๋ ๋๋ ํ ๋ฆฌ) ๋ด๋ถ๋ก ์ด๋ํ์ฌ ์๋์ make ์ปค๋งจ๋๋ฅผ ์ํํฉ๋๋ค.
๊ฐ๋ณ ์ค์น๋ make ์ปค๋งจ๋์ ์ค์นํ๋ ค๋ extension ์ด๋ฆ์ ์ธ์๋ก ์ถ๊ฐํด์ผ ํฉ๋๋ค.
DBMS_ALERT
DBMS_ASSERT
DBMS_OUTPUT
DBMS_PIPE
make ์ปค๋งจ๋๋ฅผ ์ฌ์ฉํ ์ ์๋ ํ๊ฒฝ์์ shell script๋ฅผ ์ด์ฉํ์ฌ ์๊ธฐ๋ก ์ค์นํ ์ ์์ต๋๋ค.
PostgreSQL๊ฐ ์ค์น๋ Linux ํ๋ซํผ์์ O2 Extension์ ์๋์ผ๋ก ์ค์นํ ์ ์์ต๋๋ค. O2 Extension์ด ํฌํจํ๋ ๋ชจ๋ Extension์ ๋์ ์ค์นํ๋ ์ ์ฒด ์ค์น, ๊ฐ๋ณ Extension์ ์ค์นํ๋ ๊ฐ๋ณ ์ค์น๋ก ๊ตฌ๋ถ๋ฉ๋๋ค.
PostgreSQL์ด ์ค์น๊ฐ ๋์ด์๊ณ , ํฐ๋ฏธ๋ ๋ช
๋ น์ค์์ pg_config ๋ฐ์ด๋๋ฆฌ๊ฐ ์ฌ์ฉ๊ฐ๋ฅํ ์ํ์ฌ์ผ ํฉ๋๋ค.
OpenSQL ๋ฐ์ด๋๋ฆฌ ์ค์น ์คํฌ๋ฆฝํธ๊ฐ ๋ชจ์ฌ์๋ ๋๋ ํฐ๋ฆฌ(scripts)๋ก ์ด๋ํ ํ install.sh ์คํฌ๋ฆฝํธ๋ฅผ ์คํํฉ๋๋ค.
O2 Extension ์ค์น ๊ตฌ์ฑ ์์๊ฐ ๋ชจ์ฌ ์๋ ๋๋ ํ ๋ฆฌ(Makefile ์ด ์๋ ๋๋ ํ ๋ฆฌ) ๋ด๋ถ๋ก ์ด๋ํ์ฌ install.sh ์ ์ํํฉ๋๋ค. ์ค์น ์ปค๋งจ๋์ ์ค์นํ๋ ค๋ extension ์ด๋ฆ์ ์ธ์๋ก ๋ฃ์ด์ฃผ์ด์ผ ํฉ๋๋ค.
DBMS_ALERT
DBMS_ASSERT
DBMS_OUTPUT
DBMS_PIPE
make/shell ์ค์น ๋ฐฉ๋ฒ ๋ชจ๋ pg_config ๊ฐ ์ฌ์ฉ ๊ฐ๋ฅํ ๊ณ์ ์ผ๋ก ์ค์น๋ฅผ ์ํํด์ผ ํฉ๋๋ค.
$PATH ๋ณ์ ๊ฐ์ /usr/pgsql-{PG๋ฒ์ }/bin ์ด ํฌํจ๋์ด ์๋์ง ํ์ธํด์ผํฉ๋๋ค.
$PATH๊ฐ ์ค์ ๋์ด์๋ ์ ์ ์ ๊ถํ์ผ๋ก ์ฐํํ์ฌ ์ค์น๋ฅผ ์งํํด์ผ ํฉ๋๋ค.
sudo ๊ถํ์ ํตํด ์๋์ ๊ฐ์ ๋ช ๋ น์ด๋ฅผ ์ํํฉ๋๋ค.
O2 extension ์ OpenSQL ๋ผ์ด์ผ์ค๋ฅผ ํ์ธํ๋ฏ๋ก, ์๋์ ๊ฐ์ด ๋ผ์ด์ผ์ค ํ์ผ ๊ฒฝ๋ก๋ฅผ ์ง์ ํด์ฃผ์ด์ผ ํฉ๋๋ค.
O2 Extension๋ค์ ์๋์ ๊ฐ์ด ํฌ๊ฒ 4์ข ๋ฅ ๊ทธ๋ฃน์ผ๋ก ๋ถ๋ฅ๋ฉ๋๋ค.
๊ฐ ๊ทธ๋ฃน๋ค์ ํ์ ๋ชฉ๋ก์ ์ค์ ์ ๊ณต๋๋ ๊ฐ๋ณ Extension์ ์ด๋ฆ์ ๋์ดํ ๊ฒ์ ๋๋ค.
Types Extension
O2Types
Views Extension
O2Views
๊ฐ extension๋ค์ ์๋์ ๊ฐ์ ํ์ผ๋ค๋ก ๊ตฌ์ฑ๋์ด ์๊ณ ๊ฐ extension๋ณ๋ก ๊ฐ๋ณ ์์ฑ ๊ฐ๋ฅํฉ๋๋ค.
์์) O2Functions Extension์ ๊ตฌ์ฑ ํ์ผ์ ๋ค์๊ณผ๊ฐ์ต๋๋ค.
Shared object file (eg. o2functions.so)
Control file (eg. o2functions.control)
Script file (eg. o2functionsโ1.0.sql, o2functionsโ1.0โ1.1.sql, โฆ)
๊ทธ๋ฆฌ๊ณ extension๋ค์ ๋ฒ์ ์ ๋ณด๋ฅผ ํ ๊ณณ์ผ๋ก ๋ฌถ์ VERSION.json ํ์ผ์ด ์กด์ฌํฉ๋๋ค.
O2 Extension์ ์ค์นํ ํ ํ์ฑํ๋ฅผ ํ๊ธฐ ์ํด์๋ ์๋์ ๊ฐ์ด SQL ์ปค๋งจ๋๋ฅผ ์คํํด์ผ ํฉ๋๋ค.
O2 Extension๋ค์ ๋ด๋ถ์ ์ ์ํ ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ธฐ ์ํด ์คํค๋ง oracle ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
Package Extension(DBMS_ALERT, DBMS_PIPE ๋ฑ)์ ๊ฐ์ extension ์ด๋ฆ์ ์คํค๋ง๋ก ์ฌ์ฉํฉ๋๋ค.
O2 Extension์์ ์ฌ์ฉ๋ ์คํค๋ง ์ด๋ฆ์ ๋ณ๊ฒฝํ๊ธฐ ์ํด์๋ ๊ฐ extension์ control ํ์ผ ๋ด๋ถ schema ํญ๋ชฉ์ ๊ฐ์ ์์ ํด์ผํฉ๋๋ค. (๋จ, ๊ฐ Package extension๋ค์ ์คํค๋ง ์ด๋ฆ์ด ๊ณ ์ ๊ฐ์ผ๋ก ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.)
O2 Extension์ ์์ ๋ฒ์ ์ผ๋ก ์ ๋ฐ์ดํธ ํ๊ธฐ ์ํด์๋ ์๋์ ๊ฐ์ด SQL ์ปค๋งจ๋๋ฅผ ์คํํด์ผ ํฉ๋๋ค.
HA ๊ตฌ์ฑ ์ ๊ฐ ๋ ธ๋์ ์ง์ ๋ถ์ด ์๋์ผ๋ก O2 Extension ์ค์น ๋ฐ ์ ๋ฐ์ดํธ๋ฅผ ์งํํด์ผ ํฉ๋๋ค.
๋ํ ๊ฐ ๋ ธ๋์ ์ค์น๋ O2 Extension version์ ์ผ์นํ๊ฒ ์ค์น๋๋๋ก ํฉ๋๋ค.
๋ ธ๋ ๊ฐ ๋ฒ์ ์ฐจ์ด๊ฐ ๋ฐ์ํ๋ฉด ๋ฒ์ ๊ฐ ๋์ ์ฐจ์ด๋ก ์ธํด ์ฟผ๋ฆฌ ์ํ ์ ์ด๋ ๋ ธ๋๋ก ๋ณด๋ด ์ก๋์ง์ ๋ฐ๋ผ ๋ค๋ฅธ ๊ฒฐ๊ณผ๊ฐ์ด ๋์ฌ ์ ์์ต๋๋ค.
DBMS_SCHEDULER
DBMS_SQL
DBMS_JOB
DBMS_RLS
UTL_FILE
O2Functions
O2Types
O2Views
DBMS_SCHEDULER
DBMS_SQL
DBMS_JOB
DBMS_RLS
UTL_FILE
O2Functions
O2Types
O2Views
Functions Extension
O2Functions
Package Extensions
DBMS_ALERT
DBMS_ASSERT
DBMS_OUTPUT
DBMS_PIPE
DBMS_RANDOM
DBMS_SCHEDULER
DBMS_SQL
DBMS_JOB
DBMS_RLS
UTL_FILE
ls -rlta
total 60
drwxr-xr-x 2 root root 4096 Mar 13 05:09 utl_file
drwxr-xr-x 2 root root 4096 Mar 13 05:09 o2views
drwxr-xr-x 2 root root 4096 Mar 13 05:09 o2types
drwxr-xr-x 2 root root 4096 Mar 13 05:09 o2functions
-rw-r--r-- 1 root root 3266 Mar 13 05:09 install.sh # sh ์ค์น์ฉ ์คํฌ๋ฆฝํธ
drwxr-xr-x 2 root root 4096 Mar 13 05:09 dbms_sql
drwxr-xr-x 2 root root 4096 Mar 13 05:09 dbms_random
drwxr-xr-x 2 root root 4096 Mar 13 05:09 dbms_pipe
drwxr-xr-x 2 root root 4096 Mar 13 05:09 dbms_output
drwxr-xr-x 2 root root 4096 Mar 13 05:09 dbms_alert
-rw-r--r-- 1 root root 1465 Mar 13 05:09 VERSION.json # o2 extensions ๋ฒ์ ์ ๋ณด
-rw-r--r-- 1 root root 672 Mar 13 05:09 Makefile # make ๋ฐฉ์์ค์น์ฉ ํ์ผ
drwxr-xr-x 12 root root 4096 Mar 13 05:09 .
drwxr-xr-x 6 root root 4096 Mar 13 05:09 ..cd o2
make all # o2 extensions ์ ์ฒด ์ค์น
# ์๋๋ ์ ์ฒด ์ค์น ๊ณผ์ ์์ ์ถ๋ ฅ๋๋ ์์ ๋ก๊ทธ
make[1]: Entering directory '/home/opensql/o2/build/o2-dist-1.0.1/o2functions'
/usr/bin/mkdir -p '/home/opensql/postgres/build/16/lib'
/usr/bin/mkdir -p '/home/opensql/postgres/build/16/share/extension'
/usr/bin/mkdir -p '/home/opensql/postgres/build/16/share/extension'
/usr/bin/install -c -m 755 o2functions.so '/home/opensql/postgres/build/16/lib/o2functions.so'
/usr/bin/install -c -m 644 .//o2functions.control '/home/opensql/postgres/build/16/share/extension/'
/usr/bin/install -c -m 644 .//VERSION.json .//o2functions--1.0.sql '/home/opensql/postgres/build/16/share/extension/'
make[1]: Leaving directory '/home/opensql/o2/build/o2-dist-1.0.1/o2functions'
...cd o2
# make [ extension1 extension2 ... ]
make o2functions o2types dbms_output
# ์๋๋ make ์ํ ์ ๋์ค๋ ์์ ๋ก๊ทธ
make -C o2functions install
make[1]: Entering directory '/home/opensql/o2/build/o2-dist-1.0.1/o2functions'
/usr/bin/mkdir -p '/home/opensql/postgres/build/16/lib'
/usr/bin/mkdir -p '/home/opensql/postgres/build/16/share/extension'
/usr/bin/mkdir -p '/home/opensql/postgres/build/16/share/extension'
/usr/bin/install -c -m 755 o2functions.so '/home/opensql/postgres/build/16/lib/o2functions.so'
/usr/bin/install -c -m 644 .//o2functions.control '/home/opensql/postgres/build/16/share/extension/'
/usr/bin/install -c -m 644 .//VERSION.json .//o2functions--1.0.sql '/home/opensql/postgres/build/16/share/extension/'
make[1]: Leaving directory '/home/opensql/o2/build/o2-dist-1.0.1/o2functions'
...cd scripts
sh ./install.sh o2# sh install.sh [ extension1 extension2 ... ]
sh install.sh o2functions o2types dbms_output
# ์๋๋ ๊ฐ๋ณ ์ค์น ๊ณผ์ ์์ ์ถ๋ ฅ๋๋ ์์๋ก๊ทธ
Installing extensions to:
Library directory: /home/opensql/postgres/build/16/lib
Shared extension directory: /home/opensql/postgres/build/16/share/extension
Extensions to install: o2functions o2types dbms_output
Installing extension: o2functions
Copied control file: ./o2functions.control
Copied SQL file: ./o2functions--1.0.sql
Copied shared library: ./extensions/functions/o2functions.so
Installing extension: o2types
Copied control file: ./o2types.control
Copied SQL file: ./o2types--1.0.sql
Copied shared library: ./extensions/types/o2types.so
Installing extension: dbms_output
Copied control file: ./dbms_output.control
Copied SQL file: ./dbms_output--1.0.sql
Copied shared library: ./extensions/dbms_output/dbms_output.so
Copied METADATA: VERSION.json
Installation completed.[root@20fec5585ddd /]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/pgsql-16/bin/
# ํ์ฌ ์ ์ํ ๊ณ์ ์ $PATH์ ๊ฒฝ๋ก๊ฐ์ด ์๋ค๋ฉด PG ๋ฒ์ ์ ์๋ง์ ๊ฒฝ๋ก๋ฅผ $PATH ๊ฒฝ๋ก์ ์ถ๊ฐ
[root@20fec5585ddd /]# echo "export PATH=$PATH:/usr/pgsql-16/bin/" >> ~/.bashrc
[root@20fec5585ddd /]# source ~/.bashrcsudo -u {PG๊ฒฝ๋ก๊ฐ $PATH์ ์ค์ ๋ ๋ค๋ฅธ USER} bash -l -c "{make ๋๋ shell ์ค์น ๋ช
๋ น}"
# ์์)
# postgres ์ ์ ์ $PATH์ /usr/pgsql-16/bin/ ๊ฒฝ๋ก๊ฐ ๋ฑ๋ก๋์ด ์๊ณ ,
# opensql์ด๋ผ๋ ์ ์ ๋ก ์ ์ํ์ฌ make ๋ฐฉ์์ผ๋ก o2 ์ค์นํ๋ ค๋ ๊ฒฝ์ฐ
[opensql@20fec5585ddd /]# sudo -u postgres bash -l -c "make all"# postgresql.conf์ shared_preload_libraries์ ์ฒซ ๋ฒ์งธ๋ก opensql_license ์ถ๊ฐ
shared_preload_libraries = 'opensql_license'
# ๋ผ์ด์ ์ค ํ์ผ ๊ฒฝ๋ก ํ๊ฒฝ๋ณ์ ์ค์
export OPENSQL_LICENSE_PATH="/path/to/license.xml"CREATE EXTENSION {extension name};ALTER EXTENSION {extension name} UPDATE TO {new version};