O2 Extension 설치
O2는 PostgreSQL 환경에서 오라클이 지원하는 함수/패키지/타입들과 호환되는 인터페이스를 제공하여 사용자들의 편의를 향상시키는 PostgreSQL Extension이다.
시스템 요구 사항
OpenSQL에서 지원하는 운영체제/하드웨어 사양에 따른다.
개요
O2 Extension에서는 제품 설치를 위한 방법을 다음의 2가지 설치 형태로 제공하고 있다.
make 방식으로 설치
shell 방식으로 설치
O2 설치파일 디렉토리 구조
OpenSQL 설치 패키지 내부에 동봉될 O2 설치파일 모음 디렉토리는 아래와 같은 형식으로 제공된다.
내부에는 2가지 설치방법을 위한 파일(Makefile
, install.sh
)들이 제공된다.
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 ..
make 설치방법
PostgreSQL가 설치된 Linux 플랫폼에서 O2 Extension을 make
커맨드를 통해 자동으로 설치할 수 있다.
O2 Extension이 포함하는 모든 Extension을 동시 설치하는 전체 설치, 개별 Extension을 설치하는 개별 설치로 구분한다.
설치 전 요구사항
PostgreSQL이 설치가 되어있고, 터미널 명령줄에서 make, pg_config
커맨드가 사용 가능한 상태여야 한다.
전체 설치
O2 Extension 설치 구성 요소가 모여 있는 디렉토리(Makefile
이 있는 디렉토리) 내부로 이동하여 아래의 make 커맨드를 수행한다.
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'
...
개별 설치
개별 설치는 make
커맨드에 설치하려는 extension 이름을 인자로 추가하여 준다.
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'
...
개별 설치 extension 이름 목록
DBMS_ALERT
DBMS_OUTPUT
DBMS_PIPE
DBMS_RANDOM
DBMS_SQL
UTL_FILE
O2Functions
O2Types
O2Views
shell 설치방법
make
커맨드를 사용할 수 없는 환경에서 shell script를 이용하여 수기로 설치할 수 있다.
PostgreSQL가 설치된 Linux 플랫폼에서 O2 Extension을 수동으로 설치할 수 있다. O2 Extension이 포함하는 모든 Extension을 동시 설치하는 전체 설치, 개별 Extension을 설치하는 개별 설치로 구분한다.
설치 전 요구사항
PostgreSQL이 설치가 되어있고, 터미널 명령줄에서 pg_config
바이너리가 사용가능한 상태여야 한다.
전체 설치
O2 Extension 설치 구성요소가 모여 있는 디렉토리(o2
) 내부에 동봉되어 있는 install.sh
스크립트를 실행한다.
cd o2
sh install.sh
# 아래는 전체 설치 과정에서 출력되는 예시 로그
Installing extensions to:
Library directory: /home/opensql/postgres/build/16/lib
Shared extension directory: /home/opensql/postgres/build/16/share/extension
No extension names provided. Scanning ./extensions/ for valid extensions...
Extensions to install: o2checks dbms_alert dbms_output dbms_pipe dbms_random dbms_sql o2functions o2packages o2types utl_file o2views
Installing extension: o2checks
Skipped installing o2checks; This is the internal test framework.
Installing extension: dbms_alert
Copied control file: ./dbms_alert.control
Copied SQL file: ./dbms_alert--1.0.sql
Copied shared library: ./extensions/dbms_alert/dbms_alert.so
...
Copied METADATA: VERSION.json
Installation completed.
개별 설치
개별 설치는 install.sh
커맨드에 설치하려는 extension 이름을 인자로 추가하여 준다.
# 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.
개별 설치 extension 이름 목록
DBMS_ALERT
DBMS_OUTPUT
DBMS_PIPE
DBMS_RANDOM
DBMS_SQL
UTL_FILE
O2Functions
O2Types
O2Views
설치 유의 사항
pg_config와 $PATH 설정
make/shell 설치 방법 모두 pg_config
가 사용 가능한 계정으로 설치를 수행해야 한다.
$PATH
변수 값에 /usr/pgsql-{PG버전}/bin
이 포함되어 있는지 확인한다.
[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 ~/.bashrc
$PATH 값에 PG경로가 설정 되어있지 않은 유저 계정에서의 설치 방법
$PATH가 설정되어있는 유저의 권한으로 우회하여 설치를 진행해야 한다.
sudo 권한을 통해 아래와 같은 명령어를 수행한다.
sudo -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"
설치 구성 요소
Extension 종류
O2 Extension들은 아래와 같이 크게 4종류 그룹으로 분류된다.
각 그룹들의 하위 목록은 실제 제공되는 개별 Extension의 이름을 나열한 것이다.
Types Extension
O2Types
Views Extension
O2Views
Functions Extension
O2Functions
Package Extensions
DBMS_ALERT
DBMS_OUTPUT
DBMS_PIPE
DBMS_RANDOM
DBMS_SQL
UTL_FILE
Extension 구성 요소
각 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 활성화
O2 Extension을 설치한 후 활성화를 하기 위해서는 아래와 같이 SQL 커맨드를 실행해야 한다.
CREATE EXTENSION {extension name} [WITH SCHEMA {default schema}];
WITH SCHEMA
절을 통해 Extension에서 정의한 객체가 생성될 스키마를 지정해 줄 수 있으며, 지정하지 않을 경우 Extension의 Control File에 지정된 기본 스키마로 지정된다.
단, Package Extension(DBMS_ALERT, DBMS_PIPE, 등)의 기본 스키마는 지정할 수 없다.
O2 Extension 업데이트
O2 Extension을 상위 버전으로 업데이트 하기 위해서는 아래와 같이 SQL 커맨드를 실행해야 한다.
ALTER EXTENSION {extension name} UPDATE TO {new version};
HA 구성 시 주의 사항
HA 구성 시 각 노드에 직접 붙어 수동으로 O2 Extension 설치 및 업데이트를 진행해야 한다.
또한 각 노드에 설치된 O2 Extension version은 일치하게 설치되도록 해야 한다.
노드 간 버전 차이가 발생하면 버전 간 동작 차이로 인해 쿼리 수행 시 어느 노드로 보내 졌는지에 따라 다른 결과값이 나올 수 있다.
Last updated