RHEL8へOracle DatabaseをRPMパッケージでインストール

##目標
 - Oracle Databaseをrpmでインストールする
 
参考）
[RPMパッケージの実行によるOracle Databaseのインストール](https://docs.oracle.com/cd/F19136_01/ladbi/running-rpm-packages-to-install-oracle-database.html#GUID-BB7C11E3-D385-4A2F-9EAF-75F4F0AACF02)
[Oracle Database Preinstallation RPMによるOracle Linuxの自動構成](https://docs.oracle.com/cd/F19136_01/ladbi/automatically-configuring-oracle-linux-with-oracle-preinstallation-rpm.html#GUID-22846194-58EF-4552-AAC3-6F6D0A1DF794)
##環境
 - RHEL8.5
 - Oracle Database 19c(19.3.0.0.0)

##準備するもの
 - Oracle Database 19c(oracle-database-ee-19c-1.0-1.x86_64.rpm)
 - Oracle Database Preinstallation(oracle-database-preinstall-19c-1.0-2.el8.x86_64.rpm)

　Oracle Database 19cはOracleのサイトよりダウンロード(OTNアカウントが必要)
　Oracle Database Preinstallationはcurlでダウンロード可能

※　OSのパッケージが必要となるため、yum installができること
[RHEL8で必要なパッケージ](https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/supported-oracle-linux-8-distributions-for-x86-64.html#GUID-F4902762-325B-4C89-B85B-F52BA482190F)

##kernel Parameterを設定
```shell-session
# vi /etc/sysctl.conf
```

以下の内容を設定

```shell-session
### Oracle Parameter
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
### Oracle Parameter
```

##RHEL8に対応したPreinstallationをダウンロード＋インストール
```shell-session
# curl -o oracle-database-preinstall-19c-1.0-2.el8.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinstall-19c-1.0-2.el8.x86_64.rpm
# yum install oracle-database-preinstall-19c-1.0-2.el8.x86_64.rpm
# cat /etc/security/limits.d/oracle-database-preinstall-19c.conf
```
oracle-database-preinstall-19c.confにlimitなどの情報があることを確認

##Oracle Databaseをインストール

```shell-session
# yum -y localinstall ./oracle-database-ee-19c-1.0-1.x86_64.rpm
```
インストールは時間がかかるのでエラーがでなければ気長に待つ

```shell-session
Last metadata expiration check: 1:09:14 ago on Wed 02 Feb 2022 04:52:55 PM JST.
Dependencies resolved.
=============================================================================================================================================================
 Package                                         Architecture                    Version                         Repository                             Size
=============================================================================================================================================================
Installing:
 oracle-database-ee-19c                          x86_64                          1.0-1                           @commandline                          2.5 G

Transaction Summary
=============================================================================================================================================================
Install  1 Package
Total size: 2.5 G
Installed size: 6.9 G
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
~~~~~~~~~~~~~~~~~~~~~~~~~~　省略
[INFO] Executing post installation scripts...
[INFO] Oracle home installed successfully and ready to be configured.
To configure a sample Oracle Database you can execute the following service configuration script as root: /etc/init.d/oracledb_ORCLCDB-19c configure

  Verifying        : oracle-database-ee-19c-1.0-1.x86_64                                                                                                 1/1 
Installed products updated.

Installed:
  oracle-database-ee-19c-1.0-1.x86_64                                                                                                                        

Complete!
# 
```
コンフィグ設定を行う(上のスクリプト結果に表示されているコマンドを実行)

```shell-session
# /etc/init.d/oracledb_ORCLCDB-19c configure
```

コマンド実行出力例は以下

```shell-session
Configuring Oracle Database ORCLCDB.
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
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
Database Information:
Global Database Name:ORCLCDB
System Identifier(SID):ORCLCDB
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.

Database configuration completed successfully. The passwords were auto generated, you must change them by connecting to the database using 'sqlplus / as sysdba' as the oracle user.
```


Oracleの環境parameterを設定

```shell-session
# vi /etc/profile.d/oracle.sh
```

以下の内容を設定

```shell-session
export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export ORACLE_SID=ORCLCDB
export NLS_LANG=Japanese_Japan.AL32UTF8
export PATH=$ORACLE_HOME/bin:$PATH
```
##Oracle Database 19cが起動することを確認

```shell-session
# su - oracle
$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on 水 2月 2 20:57:52 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
アイドル・インスタンスに接続しました。
SQL> exit
切断しました。
#
```