Oracle Database 19c 설치

오라클 데이터베이스 19c (Oracle Database 19c) 설치에 대한 문서다. 설치는 Slient Mode 로 설치되었으면 PDB 를 기반으로 하였다. PDB, CDB 에 대한 설명은 오라클 문서를 참고.

환경

  • Oracle Linux 8.3
  • Kernel: 5.4.17-2102.200.13.el8uek.x86_64
  • Memory: 7.7Gib
  • Swap: 12Gi
  • Root Partition: 32GB

호스트 네임 변경

]# hostnamectl set-hostname oradb1.systemv.local
]# vim /etc/hosts
192.168.96.29   oradb1.systemv.local    oradb1

Selinux 를 Permissive 로 변경

]# setenforce Permissive
]# sed -i 's/^SELINUX=enforcing$/SELINUX=Permissive/' /etc/selinux/config

HugePages 비활성화.

오라클은 HugePages 를 비활성화할 것을 권장하고 있다.

]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
]# vim /etc/default/grub
- GRUB_CMDLINE_LINUX="crashkernel=auto resume=UUID=e17bf72e-de7f-49a6-9d37-4c61864a4ba3"
+ GRUB_CMDLINE_LINUX="crashkernel=auto resume=UUID=e17bf72e-de7f-49a6-9d37-4c61864a4ba3 transparent_hugepage=never"
]# systemctl reboot

PreInstallation RPM 설치

오라클은 시스템 계정, 설치 디렉토리, 시스템 리소스 설정등을 필요로 하는데 PreInstallation RPM 은 이것을 자동으로 해준다.

]# dnf install oracle-database-preinstall-19c

이것은 자동으로 필요로하는 시스템 설정을 해준다. 이것을 하고 난후에 변경된 시스템 설정들은 다음과 같다.

시스템 그룹 생성

다음과 같은 시스템 그룹이 생성되었다.

]# groupadd -g 54321 oinstall
]# groupadd -g 54322 dba
]# groupadd -g 54323 oper
]# groupadd -g 54324 backupdba
]# groupadd -g 54325 dgdba
]# groupadd -g 54326 kmdba
]# groupadd -g 54330 racdba

oracle 계정 생성 및 소속 그룹 변경

oracle 계정이 생성되는데 기본 소속 그룹은 oinstall 이며 dba,oper,backupdba,dgdba,kmdba,racdba 그룹에도 속해야 한다.

]# useradd -u 54321 -g oinstall -G dba,oper,backupdba,dgdba,kmdba,racdba oracle
]# echo "oracle" | passwd oracle --stdin
Changing password for user oracle.
passwd: all authentication tokens updated successfully.

oracle 시스템 계정에 대한 시스템 자원 제한 설정.

파일, 메모리, 프로세스 등에 대한 자원 사용에 대해서 oracle 계정에 제한을 둔다. 이것은 /etc/security/limits.d 디렉토리에 파일을 생성해 설정한다.

]# vim /etc/security/limits.d/oracle-database-19c.conf
# oracle database 19c setting for nofile soft limit is 1024
oracle   soft   nofile    1024

# oracle database 19c setting for nofile hard limit is 65536
oracle   hard   nofile    65536

# oracle database 19c setting for nproc soft limit is 16384
# refer orabug15971421 for more info.
oracle   soft   nproc    16384

# oracle database 19c setting for nproc hard limit is 16384
oracle   hard   nproc    16384

# oracle database 19c setting for stack soft limit is 10240KB
oracle   soft   stack    10240

# oracle database 19c setting for stack hard limit is 32768KB
oracle   hard   stack    32768

# oracle database 19c setting for memlock hard limit is maximum of 128GB on x86_64 or 3GB on x86 OR 90 % of RAM
oracle   hard   memlock    134217728

# oracle database 19c setting for memlock soft limit is maximum of 128GB on x86_64 or 3GB on x86 OR 90% of RAM
oracle   soft   memlock    134217728

# oracle database 19c setting for data soft limit is 'unlimited'
oracle   soft   data    unlimited

# oracle database 19c setting for data hard limit is 'unlimited'
oracle   hard   data    unlimited

memlock 부분을 조정해 줄 필요가 있다. 전체 물리 메모리가 128GB 이하라면 약 90%를 할당을 권장하고 있다.

커널 파라메터 수정.

커널 파라메터는 sysctl 명령어로 조정이 되는데, 이것은 /etc/sysctl.d 디렉토리에 파일을 생성해 적용해 준다.

]# vim /etc/systctl.d/97-oracle-database-19c.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

# oracle database 19c setting for fs.file-max is 6815744
fs.file-max = 6815744

# oracle database 19c setting for kernel.sem is '250 32000 100 128'
kernel.sem = 250 32000 100 128

# oracle database 19c setting for kernel.shmmni is 4096
kernel.shmmni = 4096

# oracle database 19c setting for kernel.shmall is 1073741824 on x86_64
kernel.shmall = 1073741824

# oracle database 19c setting for kernel.shmmax is 4398046511104 on x86_64
kernel.shmmax = 4398046511104

# oracle database 19c setting for kernel.panic_on_oops is 1 per Orabug 19212317
kernel.panic_on_oops = 1

# oracle database 19c setting for net.core.rmem_default is 262144
net.core.rmem_default = 262144

# oracle database 19c setting for net.core.rmem_max is 4194304
net.core.rmem_max = 4194304

# oracle database 19c setting for net.core.wmem_default is 262144
net.core.wmem_default = 262144

# oracle database 19c setting for net.core.wmem_max is 1048576
net.core.wmem_max = 1048576

# oracle database 19c setting for net.ipv4.conf.all.rp_filter is 2
net.ipv4.conf.all.rp_filter = 2

# oracle database 19c setting for net.ipv4.conf.default.rp_filter is 2
net.ipv4.conf.default.rp_filter = 2

# oracle database 19c setting for fs.aio-max-nr is 1048576
fs.aio-max-nr = 1048576

# oracle database 19c setting for net.ipv4.ip_local_port_range is 9000 65500
net.ipv4.ip_local_port_range = 9000 6550
]# sysctl --system

Firewalld 설정

Oracle SQL* NET Listener 포트인 1521/tcp 를 열어준다.

]# firewall-cmd --permanent --add-port=1521/tcp
success
]# firewall-cmd --reload
success

Oracle Universal Installer (OUI)

OUI 설치는 터미널에 명령행으로 설치를 진행할 수 있도록 해준다. 이를 위해서 필요한 작업이 있다.

디렉토리 생성

다음과 같이 디렉토리를 생성해 준다.

]# mkdir -p /u01/app/oracle/product/19.3.0/dbhome_1
]# mkdir -p /u01/app/oraInventory
]# mkdir -p /u02/oradata
]#
]# mkdir -p /u01/software
]#
]# chown -R oracle:oinstall /u01 /u02
]# chmod -R 775 /u01 /u02

/u01/software 는 Oracle database 19c 설치파일들을 압축해제해 넣을 디렉토리다.

.bashrc 파일 설정

설치를 하기 위해서 환경변수를 설정해 준다. 이것은 oracle 계정에 .bashrc 파일에 해주면 된다.

# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP

export ORACLE_HOSTNAME=oradb1.systemv.local
export ORACLE_UNQNAME=o19c
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=o19c
export PDB_NAME=pdb1
export DATA_DIR=/u02/oradata

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

설치

이제 설치를 진행 해준다.

먼저, 오라클 데이터베이스 19c 에 설치 프로그램을 압축 해제해 준다.

]$ export SOFTWARE_DIR=/u01/software
]$ export DB_SOFTWARE=LINUX.X64_193000_db_home.zip
]$ # Unzip the media
]$ mkdir -p ${ORACLE_HOME}
]$ cd ${ORACLE_HOME}
]$ unzip -oq ${SOFTWARE_DIR}/${DB_SOFTWARE}

이제 Silent 설치를 위한 쉘 스크립트 파일을 작성해 준다.

]# vim ora_19c_install.sh
#!/bin/bash
  
source $HOME/.bashrc

export CV_ASSUME_DISTID=RHEL8.0

${ORACLE_HOME}/runInstaller \
-ignorePrereq -waitforcompletion -showProgress -silent \
-responseFile ${ORACLE_HOME}/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
ORACLE_HOSTNAME=${ORACLE_HOSTNAME} \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=${ORA_INVENTORY} \
SELECTED_LANGUAGES=en \
ORACLE_HOME=${ORACLE_HOME} \
ORACLE_BASE=${ORACLE_BASE} \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true
]# chmod +x ora_19c_install.sh

“export CV_ASSUME_DISTID=RHEL8.0” 는 설치 오류를 피하기 위한 것이다. 이제 실행해준다.

]# ./ora_19c_install.sh
Launching Oracle Database Setup Wizard...

The response file for this session can be found at:
 /u01/app/oracle/product/19.3.0/dbhome_1/install/response/db_2021-04-30_00-53-34AM.rsp

You can find the log of this install session at:
 /tmp/InstallActions2021-04-30_00-53-34AM/installActions2021-04-30_00-53-34AM.log


As a root user, execute the following script(s):
        1. /u01/app/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/19.3.0/dbhome_1/root.sh

Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes: 
[oradb1]
Execute /u01/app/oracle/product/19.3.0/dbhome_1/root.sh on the following nodes: 
[oradb1]


Successfully Setup Software.
Moved the install session logs to:
 /u01/app/oraInventory/logs/InstallActions2021-04-30_00-53-34AM

출력 결과 안내대로 실행해 준다.

]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
]# /u01/app/oracle/product/19.3.0/dbhome_1/root.sh
Check /u01/app/oracle/product/19.3.0/dbhome_1/install/root_oradb1.systemv.local_2021-04-30_00-59-09-117429191.log for the output of root script

멀티테넌트 데이터베이스 생성하기

오라클 12c 로 넘어오면서 CDB, PDB 라는 개념을 도입했는데 이것이 멀티테넌트 데이터베이스 개념이라 간략히 말할 수 있다. 먼저 데이터베이스를 설치하기 위해서는 오라클 리스너(Oracle Listener) 를 실행 시켜준다.

$ lsnrctl start
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 30-APR-2021 01:25:23

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/oradb1/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oradb1.systemv.local)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                30-APR-2021 01:25:27
Uptime                    0 days 0 hr. 0 min. 4 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/oradb1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oradb1.systemv.local)(PORT=1521)))
The listener supports no services
The command completed successfully

이제 멀티테넌트 데이터베이스를 생성해 준다.

$ dbca -silent -createDatabase \
> -templateName General_Purpose.dbc \
> -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID} \
> -responseFile NO_VALUE \
> -characterSet AL32UTF8 \
> -sysPassword SysPassword1 \
> -systemPassword SysPassword1 \
> -createAsContainerDatabase true \
> -numberOfPDBs 1 \
> -pdbName ${PDB_NAME} \
> -pdbAdminPassword PdbPassword1 \
> -databaseType MULTIPURPOSE \
> -automaticMemoryManagement false \
> -totalMemory 4000 \
> -storageType FS \
> -datafileDestination "${DATA_DIR}" \
> -redoLogFileSize 50 \
> -emConfiguration NONE \
> -ignorePreReqs
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/o19c.
Database Information:
Global Database Name:o19c
System Identifier(SID):o19c
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/o19c/o19c.log" for further details.

이렇게하면 하나의 CDB, PDB 가 생성된다. CDB 의 이름은 O19C, PDB 의 이름은 pdb1 이다.

]$ pwd
/u02/oradata/O19C
[oracle@oradb1 O19C]$ ls -lh
total 1.9G
-rw-r-----. 1 oracle oinstall  18M Apr 30 02:01 control01.ctl
-rw-r-----. 1 oracle oinstall  18M Apr 30 02:01 control02.ctl
drwxr-x---. 2 oracle oinstall  104 Apr 30 01:56 pdb1
drwxr-x---. 2 oracle oinstall  111 Apr 30 01:41 pdbseed
-rw-r-----. 1 oracle oinstall  51M Apr 30 02:01 redo01.log
-rw-r-----. 1 oracle oinstall  51M Apr 30 01:56 redo02.log
-rw-r-----. 1 oracle oinstall  51M Apr 30 01:56 redo03.log
-rw-r-----. 1 oracle oinstall 511M Apr 30 02:01 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 901M Apr 30 02:01 system01.dbf
-rw-r-----. 1 oracle oinstall  33M Apr 30 01:45 temp01.dbf
-rw-r-----. 1 oracle oinstall 331M Apr 30 02:01 undotbs01.dbf
-rw-r-----. 1 oracle oinstall 5.1M Apr 30 01:56 users01.dbf

필요한 데이터 파일들이 CDB 디렉토리 아래에 모두 자동으로 생성 되었다. 수동으로 생성할 수도 있는데, 이것은 추후 논의 한다.

루트(root) 사용자로 oratab 설정을 변경해 준다. 이것은 오라클 데이터베이스를 자동 시작을 활성화 해준다.

]# sed -i 's/:N$/:Y/g' /etc/oratab

이제 SQL Shell 을 실행하고 Oracle Managed File 를 활성화, CDB 시작시 PDB도 자동시작 활성화를 해준다.

]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Apr 30 02:08:18 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> ALTER SYSTEM SET DB_CREATE_FILE_DEST='/u02/oradata' SCOPE=BOTH;

System altered.

SQL> ALTER PLUGGABLE DATABASE pdb1 SAVE STATE;

Pluggable database altered.

SQL>

시작/중지.

오라클 데이터베이스 시작/중지는 다음과 같다.

]$ /u01/app/oracle/product/19.3.0/dbhome_1/bin/dbstart /u01/app/oracle/product/19.3.0/dbhome_1 # 시작
]$ /u01/app/oracle/product/19.3.0/dbhome_1/bin/dbshut /u01/app/oracle/product/19.3.0/dbhome_1 # 중지

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다