LoginSignup
11
5

CentOS Stream 8にOracle Database 23c Freeをインストールしてみた

Posted at

はじめに

2023年4月に、Oracle Database 23c Free(以下、23cFree)の提供が開始されました。
従来でいうところのXEに似たものになるかと思いますが、XEは正式版がリリースされた後に提供されていましたが、今回はFreeが先行して提供されています。

Oracle Database 23cは、19c以降で初のLong Term Releaseになり、非CDBがサポート外になる初めてのバージョンになります。

正式版のリリース時期は未定で、23cFreeと正式版とでは機能的にも差異があるようですが、どのようなものなのか、先行調査をしてみるべく、まずはインストールをしてみました。

以前よく利用していたCentOSは、もう利用できないものとばかり思っていたのですが、CentOS Stream 8(9も)が利用できる事を今更ながら知ったので、今回は、CentOS Stream 8に23cFreeをインストールしてみる事にします。

また、せっかくなので、CentOS Stream 8環境にOracle Databaseを入れる際にやっておいた方がよい設定について、改めて整理してみる事にしました。

23cFreeについての記事は、以下を参照ください。

CentOS Stream 8のインストール

ISOイメージのダウンロードやインストールについては、以下の記事などを参照ください。
今回は、OracleVM上に環境を構築しました。

CentOS Stream 8の設定

23cFreeを入れる前に念のためお約束のOS設定をしておきます。

CentOS Stream 8では、OSインストール時にOSアカウントを作成すると自動で「wheel」グループに追加されるので、お作法的にはsudoで以下の設定を行うべきなのですが、便宜的にrootユーザーで操作をしています。

SELinuxの無効化

/etc/selinux/configを編集し、SELINUXの値をdisabledにしてOSを再起動します。

[root@centos8stream ~]# vim /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

[root@centos8stream ~]# 
[root@centos8stream ~]# reboot

Firewalldの無効化

Firewalldの停止、無効化をします。

[root@centos8stream etc]# systemctl stop firewalld
[root@centos8stream etc]# systemctl disable firewalld

journaldの設定変更

syslogの設定を変更し、ディスクに永続化するようにします。

[root@centos8stream ~]# vim /etc/systemd/journald.conf 
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See journald.conf(5) for details.

[Journal]
Storage=persistent
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
RateLimitIntervalSec=0
RateLimitBurst=0
#SystemMaxUse=
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=100
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=no
#ForwardToKMsg=no
#ForwardToConsole=no
#ForwardToWall=yes
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info
#MaxLevelWall=emerg
#LineMax=48K
SystemMaxUse=1G

[root@centos8stream ~]# systemctl restart systemd-journald

NTPサーバー設定

NTPサーバーを指定し、時刻同期設定をslewモードに変更します。
今回は、NTPサーバーにjp.pool.ntp.orgを指定しました。

[root@centos8stream ~]# vim /etc/chrony.conf 
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool 2.centos.pool.ntp.org iburst
server jp.pool.ntp.org prefer iburst

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# Allow NTP client access from local network.
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys

# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking

leapsecmode slew

[root@centos8stream ~]# systemctl restart chronyd

OSのタイムゾーンの確認と変更(必要に応じて)

OSインストール時にGUIでOSのタイムゾーンを「Asia/Tokyo」に指定していたのですが、何故か「America/New_York (EDT)」になっていたので、OSのタイムゾーンを変更します。

[root@centos8stream ~]# timedatectl status
               Local time: 火 2023-05-16 07:38:20 EDT
           Universal time: 火 2023-05-16 11:38:20 UTC
                 RTC time: 火 2023-05-16 11:38:21
                Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[root@centos8stream ~]# 
[root@centos8stream ~]# timedatectl set-timezone Asia/Tokyo
[root@centos8stream ~]# 
[root@centos8stream ~]# timedatectl status
               Local time: 火 2023-05-16 20:39:19 JST
           Universal time: 火 2023-05-16 11:39:19 UTC
                 RTC time: 火 2023-05-16 11:39:20
                Time zone: Asia/Tokyo (JST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[root@centos8stream ~]# 

hostsの設定

/etc/hostsの設定をします。

[root@centos8stream etc]# vim /etc/hosts
192.168.XXX.XXX  centos8stream
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

23cFreeのインストール

正式版のOracleをLinuxにインストールする場合、oracleユーザー、oinstallなどのグループ作成、カーネルパラメータの設定など、事前に色々とする必要がありますが、23cFreeの場合、2つのrpmパッケージをインストールする事で、ほぼお任せでインストールができます。

インストール用のRPMは、以下のサイトからダウンロード可能です。

上記サイトから以下2つのRPMをダウンロードし、サーバーに配置しておきます。
【Preinstall RPMs for RHEL and CentOS】
oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm

【Oracle Database 23c Free Developer-Release for Linux x64 (OL8 or RHEL8)】
oracle-database-free-23c-1.0-1.el8.x86_64.rpm

23cFreeのインストールおよびデータベースの作成は、以下を参照して実施しました。

oracle-database-preinstall-23cのインストール

Oracleのインストールに必要となるパッケージをよしなに入れたり、更新してくれます。

[root@centos8stream ~]# dnf localinstall oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm 
メタデータの期限切れの最終確認: 0:22:46 時間前の 2023年05月15日 04時41分12秒 に実施しました。
依存関係が解決しました。
======================================================================================================================================================================================
 パッケージ                                            アーキテクチャー              バージョン                                             リポジトリー                        サイズ
======================================================================================================================================================================================
インストール:
 oracle-database-preinstall-23c                        x86_64                        1.0-0.5.el8                                            @commandline                         30 k
依存関係のインストール:
 compat-openssl10                                      x86_64                        1:1.0.2o-4.el8                                         appstream                           1.1 M
 glibc-devel                                           x86_64                        2.28-225.el8                                           baseos                               83 k
 glibc-headers                                         x86_64                        2.28-225.el8                                           baseos                              488 k
 kernel-headers                                        x86_64                        4.18.0-490.el8                                         baseos                               11 M
 ksh                                                   x86_64                        20120801-257.el8                                       appstream                           929 k
 libnsl                                                x86_64                        2.28-225.el8                                           baseos                              105 k
 libxcrypt-devel                                       x86_64                        4.1.1-6.el8                                            baseos                               25 k
 lm_sensors-libs                                       x86_64                        3.4.0-23.20180522git70f7e08.el8                        baseos                               59 k
 make                                                  x86_64                        1:4.2.1-11.el8                                         baseos                              498 k
 sysstat                                               x86_64                        11.7.3-9.el8                                           appstream                           426 k

トランザクションの概要
======================================================================================================================================================================================
インストール  11 パッケージ

合計サイズ: 15 M
ダウンロードサイズの合計: 15 M
インストール後のサイズ: 17 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/10): sysstat-11.7.3-9.el8.x86_64.rpm                                                                                                               485 kB/s | 426 kB     00:00    
(2/10): ksh-20120801-257.el8.x86_64.rpm                                                                                                               902 kB/s | 929 kB     00:01    
(3/10): compat-openssl10-1.0.2o-4.el8.x86_64.rpm                                                                                                      1.1 MB/s | 1.1 MB     00:01    
(4/10): glibc-devel-2.28-225.el8.x86_64.rpm                                                                                                           228 kB/s |  83 kB     00:00    
(5/10): libnsl-2.28-225.el8.x86_64.rpm                                                                                                                1.2 MB/s | 105 kB     00:00    
(6/10): libxcrypt-devel-4.1.1-6.el8.x86_64.rpm                                                                                                        492 kB/s |  25 kB     00:00    
(7/10): lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64.rpm                                                                                    1.1 MB/s |  59 kB     00:00    
(8/10): glibc-headers-2.28-225.el8.x86_64.rpm                                                                                                         721 kB/s | 488 kB     00:00    
(9/10): make-4.2.1-11.el8.x86_64.rpm                                                                                                                  1.1 MB/s | 498 kB     00:00    
(10/10): kernel-headers-4.18.0-490.el8.x86_64.rpm                                                                                                     8.4 MB/s |  11 MB     00:01    
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                                                  2.5 MB/s |  15 MB     00:05     
CentOS Stream 8 - AppStream                                                                                                                           1.5 MB/s | 1.6 kB     00:00    
GPG 鍵 XXXXXXXXXX をインポート中:
 Userid     : "CentOS (CentOS Official Signing Key) <security@centos.org>"
 Fingerprint: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
これでよろしいですか? [y/N]: y
鍵のインポートに成功しました
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                                                                                                                              1/1 
  インストール中   : make-1:4.2.1-11.el8.x86_64                                                                                                                                  1/11 
  scriptletの実行中: make-1:4.2.1-11.el8.x86_64                                                                                                                                  1/11 
  インストール中   : compat-openssl10-1:1.0.2o-4.el8.x86_64                                                                                                                      2/11 
  scriptletの実行中: compat-openssl10-1:1.0.2o-4.el8.x86_64                                                                                                                      2/11 
  インストール中   : lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64                                                                                                      3/11 
  scriptletの実行中: lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64                                                                                                      3/11 
  インストール中   : sysstat-11.7.3-9.el8.x86_64                                                                                                                                 4/11 
  scriptletの実行中: sysstat-11.7.3-9.el8.x86_64                                                                                                                                 4/11 
  インストール中   : libnsl-2.28-225.el8.x86_64                                                                                                                                  5/11 
  インストール中   : kernel-headers-4.18.0-490.el8.x86_64                                                                                                                        6/11 
  scriptletの実行中: glibc-headers-2.28-225.el8.x86_64                                                                                                                           7/11 
  インストール中   : glibc-headers-2.28-225.el8.x86_64                                                                                                                           7/11 
  インストール中   : libxcrypt-devel-4.1.1-6.el8.x86_64                                                                                                                          8/11 
  インストール中   : glibc-devel-2.28-225.el8.x86_64                                                                                                                             9/11 
  scriptletの実行中: glibc-devel-2.28-225.el8.x86_64                                                                                                                             9/11 
  インストール中   : ksh-20120801-257.el8.x86_64                                                                                                                                10/11 
  scriptletの実行中: ksh-20120801-257.el8.x86_64                                                                                                                                10/11 
  インストール中   : oracle-database-preinstall-23c-1.0-0.5.el8.x86_64                                                                                                          11/11 
  scriptletの実行中: oracle-database-preinstall-23c-1.0-0.5.el8.x86_64                                                                                                          11/11 
  検証             : compat-openssl10-1:1.0.2o-4.el8.x86_64                                                                                                                      1/11 
  検証             : ksh-20120801-257.el8.x86_64                                                                                                                                 2/11 
  検証             : sysstat-11.7.3-9.el8.x86_64                                                                                                                                 3/11 
  検証             : glibc-devel-2.28-225.el8.x86_64                                                                                                                             4/11 
  検証             : glibc-headers-2.28-225.el8.x86_64                                                                                                                           5/11 
  検証             : kernel-headers-4.18.0-490.el8.x86_64                                                                                                                        6/11 
  検証             : libnsl-2.28-225.el8.x86_64                                                                                                                                  7/11 
  検証             : libxcrypt-devel-4.1.1-6.el8.x86_64                                                                                                                          8/11 
  検証             : lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64                                                                                                      9/11 
  検証             : make-1:4.2.1-11.el8.x86_64                                                                                                                                 10/11 
  検証             : oracle-database-preinstall-23c-1.0-0.5.el8.x86_64                                                                                                          11/11 

インストール済み:
  compat-openssl10-1:1.0.2o-4.el8.x86_64 glibc-devel-2.28-225.el8.x86_64                   glibc-headers-2.28-225.el8.x86_64  kernel-headers-4.18.0-490.el8.x86_64                  
  ksh-20120801-257.el8.x86_64            libnsl-2.28-225.el8.x86_64                        libxcrypt-devel-4.1.1-6.el8.x86_64 lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64
  make-1:4.2.1-11.el8.x86_64             oracle-database-preinstall-23c-1.0-0.5.el8.x86_64 sysstat-11.7.3-9.el8.x86_64       

完了しました!

Oracle Database Free 23cのインストール

23cFreeのインストールも、パッケージをインストールするだけです。

[root@centos8stream ~]# dnf localinstall oracle-database-free-23c-1.0-1.el8.x86_64.rpm 
メタデータの期限切れの最終確認: 0:24:11 時間前の 2023年05月15日 04時41分12秒 に実施しました。
依存関係が解決しました。
======================================================================================================================================================================================
 パッケージ                                              アーキテクチャー                      バージョン                           リポジトリー                                サイズ
======================================================================================================================================================================================
インストール:
 oracle-database-free-23c                                x86_64                                1.0-1                                @commandline                                1.6 G

トランザクションの概要
======================================================================================================================================================================================
インストール  1 パッケージ

合計サイズ: 1.6 G
インストール後のサイズ: 5.2 G
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                                                                                                                              1/1 
  scriptletの実行中: oracle-database-free-23c-1.0-1.x86_64                                                                                                                        1/1 
  インストール中   : oracle-database-free-23c-1.0-1.x86_64                                                                                                                        1/1 
  scriptletの実行中: oracle-database-free-23c-1.0-1.x86_64                                                                                                                        1/1 
[INFO] Executing post installation scripts...
[INFO] Oracle home installed successfully and ready to be configured.
To configure Oracle Database Free, optionally modify the parameters in '/etc/sysconfig/oracle-free-23c.conf' and then run '/etc/init.d/oracle-free-23c configure' as root.

  検証             : oracle-database-free-23c-1.0-1.x86_64                                                                                                                        1/1 

インストール済み:
  oracle-database-free-23c-1.0-1.x86_64                                                                                                                                               

完了しました!

インストール後の状態を確認してみます。

oracleユーザー、グループの確認

oracleユーザーおよびグループもよしなに作成されています。

[root@centos8stream etc]# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)

カーネルパラメータの確認

HugePageの設定以外は、よしなに設定されています。

[root@centos8stream etc]# cat sysctl.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-preinstall-23c setting for fs.file-max is 6815744
fs.file-max = 6815744

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

# oracle-database-preinstall-23c setting for kernel.shmmni is 4096
kernel.shmmni = 4096

# oracle-database-preinstall-23c setting for kernel.shmall is 1073741824 on x86_64
kernel.shmall = 1073741824

# oracle-database-preinstall-23c setting for kernel.shmmax is 4398046511104 on x86_64
kernel.shmmax = 4398046511104

# oracle-database-preinstall-23c setting for kernel.panic_on_oops is 1 per Orabug 19212317
kernel.panic_on_oops = 1

# oracle-database-preinstall-23c setting for net.core.rmem_default is 262144
net.core.rmem_default = 262144

# oracle-database-preinstall-23c setting for net.core.rmem_max is 4194304
net.core.rmem_max = 4194304

# oracle-database-preinstall-23c setting for net.core.wmem_default is 262144
net.core.wmem_default = 262144

# oracle-database-preinstall-23c setting for net.core.wmem_max is 1048576
net.core.wmem_max = 1048576

# oracle-database-preinstall-23c setting for net.ipv4.conf.all.rp_filter is 2
net.ipv4.conf.all.rp_filter = 2

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

# oracle-database-preinstall-23c setting for net.ipv4.ip_local_port_range is 9000 65500
net.ipv4.ip_local_port_range = 9000 65500

[root@centos8stream etc]#

23cFreeでは、デフォルトではSGA_TARGET、PGA_AGGREGATE_TARGET指定でメモリ設定がされるので、データベース作成後、必要に応じてHugePagesの設定を行います(必須ではない)。

HugePagesを指定する場合、/etc/sysctl.confに「vm.nr_hugepages」の値を指定して追加します。
指定する値は、SGA_TARGETに指定した値により変動します。
(計算式)
vm.nr_hugepages = (SGA_TARGETの値(MB) + 50MB) / hugepagesize = (SGA_TARGETの値(MB) + 50MB) / 2

23cFreeでは、SGA_TARGETに536Mが指定されているので、HugePages設定をする場合、vm.nr_hugepagesには、(536+50)/2=293を指定します。

vm.nr_hugepages = 293

またこの他に、/etc/security/limits.conf にmemlock(soft、hard両方)の値も指定して追加する必要があります。
(計算式)
memlock = (SGA_TARGETの値(MB) + 50MB + 10MB) * 1024 (KB)

23cFreeの場合は、memlockに、(536+50+10)*1024=610304を指定します。

oracle           soft    memlock         610304
oracle           hard    memlock         610304

/etc/security/limits.confの設定

19cでは、HugePages関連の設定以外に、以下のような設定が必要でしたが、23cFreeインストール後も設定は追加されていませんでした。

oracle           soft    nproc           2047
oracle           hard    nproc           16384
oracle           soft    nofile          1024
oracle           hard    nofile          65536
oracle           soft    stack           10240
oracle           hard    stack           32768

/etc/pam.d/loginの設定

19cでは、以下の設定を追加していましたが、23cFreeインストール後も設定は追加されていませんでした。

session    required     pam_limits.so

/etc/profileの設定

19cでは、以下の設定を追加していましたが、23cFreeインストール後も設定は追加されていませんでした。

if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
        ulimit -p 16384
        ulimit -n 65536
    else
        ulimit -u 16384 -n 65536
    fi
    umask 022
fi

Transparent HugePagesの設定

Transparent HugePagesは、よしなに設定がされていました。

[root@centos8stream etc]# cat /sys/kernel/mm/transparent_hugepage/enabled 
always madvise [never]
[root@centos8stream etc]# 
[root@centos8stream etc]# cat /sys/kernel/mm/transparent_hugepage/defrag 
always defer defer+madvise madvise [never]

RHELの場合、Transparent HugePages設定を確認する際のパスが異なるため注意です。
(RHELの場合)
/sys/kernel/mm/redhat_transparent_hugepage/enabled
/sys/kernel/mm/redhat_transparent_hugepage/defrag

上記OS設定周りについては、正式版リリース後に改めて確認してみたいと思います。

データベースの作成

23cFreeのインストール後、rootユーザーで/etc/init.d/oracle-free-23c configureコマンドを実行すると、データベースが作成されます。

基本デフォルト設定でよいと思いますが、リスナーポートやDBのキャラクタセットを変えたいなどがある場合は、/etc/sysconfig/oracle-free-23c.confを編集してから/etc/init.d/oracle-free-23c configureコマンドを実行します。

[root@centos8stream etc]# cat /etc/sysconfig/oracle-free-23c.conf
#This is a configuration file to setup the Oracle Database. 
#It is used when running '/etc/init.d/oracle-free-23c configure'.

# LISTENER PORT used Database listener, Leave empty for automatic port assignment
LISTENER_PORT=

# Character set of the database
CHARSET=AL32UTF8

# Database file directory
# If not specified, database files are stored under Oracle base/oradata
DBFILE_DEST=

# DB Domain name
DB_DOMAIN=

# SKIP Validations, memory, space
SKIP_VALIDATIONS=false

データベースの作成

rootユーザーで/etc/init.d/oracle-free-23c configureコマンドを実行すると、SYS、SYSTEM、PDBADMINユーザーのパスワードを聞かれるので、設定するとCDBおよびPDB(1つ)の作成が始まります。

[root@centos8stream ~]# /etc/init.d/oracle-free-23c configure
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database FREE.
SYSユーザー・パスワードを入力してください: 
************
SYSTEMユーザー・パスワードを入力してください: 
************
PDBADMINユーザー・パスワードを入力してください: 
***************
DB操作の準備
7%完了
データベース・ファイルのコピー中
29%完了
Oracleインスタンスの作成および起動中
30%完了
33%完了
36%完了
39%完了
43%完了
データベース作成の完了
47%完了
49%完了
50%完了
プラガブル・データベースの作成
54%完了
71%完了
構成後アクションの実行
93%完了
カスタム・スクリプトを実行中
100%完了
データベースの作成が完了しました。詳細は、次の場所にあるログ・ファイルを参照してください:
/opt/oracle/cfgtoollogs/dbca/FREE
データベース情報:
グローバル・データベース名:FREE
システム識別子(SID):FREE
詳細はログ・ファイル"/opt/oracle/cfgtoollogs/dbca/FREE/FREE.log"を参照してください。

Connect to Oracle Database using one of the connect strings:
     Pluggable database: centos8stream/FREEPDB1
     Multitenant container database: centos8stream
[root@centos8stream ~]#

作成が終わると、SID(CDB):FREE、PDB:FREEPDB1が作成されます。

rlwrapのインストール

SQL*Plusでヒストリー機能を利用したいので、rlwrapをインストールします。
rlwrapのインストールにはEPELリポジトリが必要になるので、まずEPELリポジトリをインストールします。

# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

続いてrlwrapをインストールします。

# dnf install rlwrap

環境変数設定

oracleユーザーにスイッチし、環境変数を以下のように設定します。

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/23c/dbhomeFree
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=FREE
export NLS_LANG=Japanese_Japan.AL32UTF8
#export ORAENV_ASK=NO
alias sqlplus='rlwrap sqlplus'

SYSユーザーでCDBにログインし、初期設定

CDBおよびPDBに接続し、監査設定およびデフォルトプロファイルの設定を変更します。
また、PDBが自動起動するよう設定(save state)します。

[oracle@centos8stream ~]$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on  5 15 05:47:18 2023
Version 23.2.0.0.0
Copyright (c) 1982, 2023, Oracle.  All rights reserved.

Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
に接続されました。
SQL> 
SQL> noaudit all;
noaudit all privileges;
noaudit exempt access policy;

ALTER PROFILE DEFAULT LIMIT
FAILED_LOGIN_ATTEMPTS 10
PASSWORD_LIFE_TIME UNLIMITED
PASSWORD_GRACE_TIME UNLIMITED
PASSWORD_LOCK_TIME UNLIMITED
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_REUSE_MAX UNLIMITED;

監査取消しが成功しました。

SQL>
SQL> sho pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 FREEPDB1                       READ WRITE NO
SQL> 
SQL> alter session set container=FREEPDB1;

セッションが変更されました。

SQL> 
SQL> show con_name

CON_NAME
------------------------------
FREEPDB1
SQL> 

SQL> alter pluggable database FREEPDB1 save state;

プラガブル・データベースが変更されました。

SQL> 
SQL> noaudit all;
noaudit all privileges;
noaudit exempt access policy;

ALTER PROFILE DEFAULT LIMIT
FAILED_LOGIN_ATTEMPTS 10
PASSWORD_LIFE_TIME UNLIMITED
PASSWORD_GRACE_TIME UNLIMITED
PASSWORD_LOCK_TIME UNLIMITED
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_REUSE_MAX UNLIMITED;

監査取消しが成功しました。

リスナーのステータス確認

[oracle@centos8stream ~]$ lsnrctl status

LSNRCTL for Linux: Version 23.0.0.0.0 - Developer-Release on 15-5月 -2023 06:57:30

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

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=centos8stream)(PORT=1521)))に接続中
リスナーのステータス
------------------------
別名                      LISTENER
バージョン                TNSLSNR for Linux: Version 23.0.0.0.0 - Developer-Release
開始日                    15-5月 -2023 05:19:22
稼働時間                  0 日 1 時間 38 分 8 秒
トレース・レベル          off
セキュリティ              ON: Local OS Authentication
SNMP                      OFF
デフォルト・サービス           FREE
パラメータ・ファイル      /opt/oracle/product/23c/dbhomeFree/network/admin/listener.ora
ログ・ファイル            /opt/oracle/diag/tnslsnr/centos8stream/listener/alert/log.xml
リスニング・エンドポイントのサマリー...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos8stream)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
サービスのサマリー...
サービス"FREE"には、1件のインスタンスがあります。
  インスタンス"FREE"、状態READYには、このサービスに対する1件のハンドラがあります...
サービス"FREEXDB"には、1件のインスタンスがあります。
  インスタンス"FREE"、状態READYには、このサービスに対する1件のハンドラがあります...
サービス"fbb91781d7412d32e053750aa8c0ea4a"には、1件のインスタンスがあります。
  インスタンス"FREE"、状態READYには、このサービスに対する1件のハンドラがあります...
サービス"freepdb1"には、1件のインスタンスがあります。
  インスタンス"FREE"、状態READYには、このサービスに対する1件のハンドラがあります...
コマンドは正常に終了しました。

SQL*Plusの設定

SQL*Plusで利用するエディターなどを設定します。※以下、設定例

[oracle@centos8stream ~]$ cat $ORACLE_HOME/sqlplus/admin/glogin.sql
--
-- Copyright (c) 1988, 2005, Oracle.  All Rights Reserved.
--
-- NAME
--   glogin.sql
--
-- DESCRIPTION
--   SQL*Plus global login "site profile" file
--
--   Add any SQL*Plus commands here that are to be executed when a
--   user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
--
-- USAGE
--   This script is automatically run
--
show con_name
set pages 100
set lines 200

define _EDITOR = vim

tnsnames.oraの設定

PDB用の設定を追記します。※以下、設定例

# tnsnames.ora Network Configuration File: /opt/oracle/product/23c/dbhomeFree/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

FREE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = centos8stream)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = FREE)
    )
  )

LISTENER_FREE =
  (ADDRESS = (PROTOCOL = TCP)(HOST = centos8stream)(PORT = 1521))


FREEPDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = centos8stream)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = FREEPDB1)
    )
  )

tnsnames.oraの設定後、以下のようにPDBに接続できればOKです。

[oracle@centos8stream ~]$ sqlplus sys@freepdb1 as sysdba

SQL*Plus: Release 23.0.0.0.0 - Developer-Release on  5 16 07:18:30 2023
Version 23.2.0.0.0

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

パスワードを入力してください: 


Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
に接続されました。

CON_NAME
------------------------------
FREEPDB1
SQL>

自動起動・停止設定

rootユーザーで/etc/oratabファイルを編集し、末尾が「N」になっている箇所を「Y」に変更します。

[root@centos8stream etc]# vim /etc/oratab
#
# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
FREE:/opt/oracle/product/23c/dbhomeFree:Y ←ここをNからYに変更

続いて以下のようなUnitファイルを作成し、/etc/systemd/systemに配置します。

[root@centos8stream system]# cat oracle.service 
[Unit]
Description=Oracle Database Server
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/opt/oracle/product/23c/dbhomeFree/bin/dbstart /opt/oracle/product/23c/dbhomeFree
ExecStop=/opt/oracle/product/23c/dbhomeFree/bin/dbshut /opt/oracle/product/23c/dbhomeFree
User=oracle
Group=oinstall

[Install]
WantedBy=multi-user.target

その後、oracle.serviceを有効化します。

[root@centos8stream system]# systemctl enable oracle
Created symlink /etc/systemd/system/multi-user.target.wants/oracle.service → /etc/systemd/system/oracle.service.
[root@centos8stream system]#
[root@centos8stream system]# systemctl is-enabled oracle
enabled

アラートログ、リスナーログ

デフォルトでは以下に出力されています。

アラートログ:/opt/oracle/diag/rdbms/free/FREE/trace/alert_FREE.log
リスナーログ:/opt/oracle/diag/tnslsnr/(host名)/listener/trace/listener.log

データファイルの作成場所

デフォルトでは以下に作成されています。

CDBのデータベースファイル
[oracle@centos8stream FREE]$ pwd
/opt/oracle/oradata/FREE
[oracle@centos8stream FREE]$ ll
合計 2486340
drwxr-x--- 2 oracle oinstall        104  5月 15 18:30 FREEPDB1
-rw-r----- 1 oracle oinstall   18759680  5月 17 16:21 control01.ctl
-rw-r----- 1 oracle oinstall   18759680  5月 17 16:21 control02.ctl
drwxr-x--- 2 oracle oinstall         85  5月 15 18:22 pdbseed
-rw-r----- 1 oracle oinstall  209715712  5月 17 10:59 redo01.log
-rw-r----- 1 oracle oinstall  209715712  5月 17 16:20 redo02.log
-rw-r----- 1 oracle oinstall  209715712  5月 17 10:59 redo03.log
-rw-r----- 1 oracle oinstall  618668032  5月 17 16:19 sysaux01.dbf
-rw-r----- 1 oracle oinstall 1216356352  5月 17 16:19 system01.dbf
-rw-r----- 1 oracle oinstall   20979712  5月 17 11:02 temp01.dbf
-rw-r----- 1 oracle oinstall   36708352  5月 17 16:19 undotbs01.dbf
-rw-r----- 1 oracle oinstall    5251072  5月 17 10:59 users01.dbf
[oracle@centos8stream FREE]$
PDBのデータベースファイル
[oracle@centos8stream FREEPDB1]$ pwd
/opt/oracle/oradata/FREE/FREEPDB1
[oracle@centos8stream FREEPDB1]$ ll
合計 744728
-rw-r----- 1 oracle oinstall 346038272  5月 17 16:19 sysaux01.dbf
-rw-r----- 1 oracle oinstall 304095232  5月 17 16:19 system01.dbf
-rw-r----- 1 oracle oinstall  20979712  5月 17 11:00 temp01.dbf
-rw-r----- 1 oracle oinstall 104865792  5月 17 16:19 undotbs01.dbf
-rw-r----- 1 oracle oinstall   5251072  5月 17 10:59 users01.dbf
[oracle@centos8stream FREEPDB1]$

その他

23cの新機能で、dualを指定するSQL文でfrom句を書かずにselect文を実行できるようになっているようです。

SQL> select dbtimezone;

DBTIME
------
+00:00

SQL> select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS');

TO_CHAR(SYSDATE,'YY
-------------------
2023/05/17 16:28:15

SQL>

23cでの機能の変更点、初期化パラメータの変更点などについては、正式版が出た後などで別途確認してみたいと思います。

おわりに

CentOS Stream 8にOracle Database 23c Freeをインストールし、OS設定などの差異をざっと確認してみました。

11
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
5