前回のあらすじ

こんにちは!

前回はOCI上に21cのデータベースを作成しました。

今回は作成したデータベースへの接続確認と、
データベース、OSの設定確認を行っていきます。

今回はコマンドでの確認がメインです。
宜しくお願いします!

 

 

 

SQL*Plusを利用したデータベースへの接続

TeraTermを起動して、パブリックIPアドレスを入力し、SSH接続でログインします。

初回接続時に以下の警告が表示されますが、[続行]を押下します。

OCIではrootユーザで直接アクセスすることは出来ないため、opcユーザで接続します。
ユーザ名にopcユーザを入力し、パスフレーズは入力せず、[RSA/DSA/ECDSA/ED25519鍵を使う]を選択し、[…]を押下します。

保存した秘密キーを選択し、[開く]を押下します。

秘密鍵が選択されたことを確認し、[OK]を押下します。

 

opcユーザでログイン後、oracleユーザにスイッチして、SQL*Plusでデータベースに接続します。
データベースが起動していることを確認してから、接続することをお勧めします。

[opc@host21c ~]$ sudo -s
[root@host21c opc]#
[root@host21c opc]# su - oracle
Last login: Wed May 12 13:22:17 UTC 2021
[oracle@host21c ~]$
[oracle@host21c ~]$ ps -ef | grep smon
root     32998     1  1 May01 ?        05:17:56 /u01/app/21.0.0.0/grid/bin/osysd.bin
grid     44964     1  0 May01 ?        00:00:22 asm_smon_+ASM1
oracle   87315     1  0 May01 ?        00:00:14 ora_smon_db21c
oracle   96029 95871  0 13:22 pts/0    00:00:00 grep --color=auto smon
[oracle@host21c ~]$
[oracle@host21c ~]$ sqlplus / as sysdba

SQL*Plus: Release 21.0.0.0.0 - Production on Wed May 12 13:23:13 2021
Version 21.1.0.0.0

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


Connected to:
Oracle Database 21c EE High Perf Release 21.0.0.0.0 - Production
Version 21.1.0.0.0

SQL>

 

データベース確認

データベースに接続したので、少し見ていきたいと思います。
データベースバージョンは21cであることが確認できました。

SQL> select * from v$version ;

BANNER
--------------------------------------------------------------------------------
BANNER_FULL
--------------------------------------------------------------------------------
BANNER_LEGACY
--------------------------------------------------------------------------------
CON_ID
----------
Oracle Database 21c EE High Perf Release 21.0.0.0.0 - Production
Oracle Database 21c EE High Perf Release 21.0.0.0.0 - Production
Version 21.1.0.0.0
Oracle Database 21c EE High Perf Release 21.0.0.0.0 - Production
0

BANNER
--------------------------------------------------------------------------------
BANNER_FULL
--------------------------------------------------------------------------------
BANNER_LEGACY
--------------------------------------------------------------------------------
CON_ID
----------


SQL>

 

PDBはデータベース作成時に敢えて指定しませんでしたが、自動で作成されていました(<CDB_NAME>_PDBn)。
21c以降ではNon-CDB構成がサポートされなくなったことで、マルチテナント構成で作成されることになったようです。

SQL> sho pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 DB21C_PDB1 READ WRITE NO
SQL>

 

ユーザ一覧は、OCIの19c環境と比較したところ、[DGPDB_INT]ユーザが新しく追加されていました。
マニュアルを確認すると、Oracle Data Guardがプラガブルデータベース機能(DGPDB)に使用する内部アカウントと記載されています。

SQL> select username from dba_users order by 1 ;

USERNAME
--------------------------------------------------------------------------------------------------------------------------------
ANONYMOUS
APPQOSSYS
AUDSYS
CTXSYS
DBSFWUSER
DBSNMP
DGPDB_INT
DIP
DVF
DVSYS
GGSYS
GSMADMIN_INTERNAL
GSMCATUSER
GSMROOTUSER
GSMUSER
LBACSYS
MDDATA
MDSYS
OJVMSYS
OLAPSYS
ORACLE_OCM
ORDDATA
ORDPLUGINS
ORDSYS
OUTLN
REMOTE_SCHEDULER_AGENT
SI_INFORMTN_SCHEMA
SYS
SYS$UMF
SYSBACKUP
SYSDG
SYSKM
SYSRAC
SYSTEM
WMSYS
XDB
XS$NULL

37 rows selected.

SQL>

 

表領域一覧には、特に追加された表領域はありませんでした。

SQL> select tablespace_name,file_name,bytes/1024/1024 MB from dba_data_files order by 1 ;

TABLESPACE_NAME FILE_NAME MB
-------------------- ------------------------------------------------------------ ----------
SYSAUX +DATA/DB21C_NRT1FP/DATAFILE/sysaux.262.1071399879 1380
SYSTEM +DATA/DB21C_NRT1FP/DATAFILE/system.261.1071399813 1370
UNDOTBS1 +DATA/DB21C_NRT1FP/DATAFILE/undotbs1.263.1071399893 135
USERS +DATA/DB21C_NRT1FP/DATAFILE/users.276.1071401089 5

 

初期化パラメータ一覧では、OCIの19c環境と比較したところ、21c追加されているパラメータおよび廃止されている(21cでは存在しない)パラメータがいくつかありました。
パラメータ一覧は量が多いため、差分のみを記載しています。
見慣れていた[cluster_database_instances]や[sec_case_sensitive_logon]がなくなり、[native_blockchain_features ]のような21cからの新機能に関するパラメータも追加されているようです。

パラメータ 設定値 21cで追加/廃止 説明
追加 廃止
allow_deprecated_rpcs YES 非推奨のrpcsを許可する
cluster_database_instances 1 クラスターDBのSGA構造のサイズ設定に使用するインスタンスの数
dbnest_enable NONE データベースネストの有効化
dbnest_pdb_fs_conf NULL PDBファイルシステムの構成
diagnostics_control IGNORE ‘enabling diagnostics’の特権がない場合のレスポンスを制御
drcp_connection_limit 0 DRCP接続制限
drcp_dedicated_opt YES DRCP専用最適化のon/offを切替
enable_per_pdb_drcp FALSE PDB DRCPごとにon/offを切替
heartbeat_batch_size 5 バッチで送信されるハートビートの数
inmemory_deep_vectorization TRUE In-Memoryディープベクトルの有効化
kafka_config_file NULL KSR pub/sub外部メッセージバス(KSRPS)構成ファイル
native_blockchain_features NONE ネイティブブロックチェーンの有効化/無効化
optimizer_capture_sql_quarantine FALSE SQL検疫構成の自動作成/更新の有効化
optimizer_cross_shard_resiliency FALSE クロスシャードクエリの復元力のある実行を可能にする
optimizer_use_sql_quarantine TRUE SQL検疫の使用を有効化
pkcs11_library_location NONE 透過的データ暗号化のためのPKCS#11ライブラリの場所
pmem_filestore NULL 永続メモリファイルストアリスト
remote_os_authent FALSE 安全でないリモートクライアントが自動ログオンアカウントを使用可能にする
resource_manager_cpu_scope INSTANCE_ONLY CPUリソース管理の範囲
result_cache_execution_threshold 2 PL/SQL関数がキャッシュされる前の最小実行数
result_cache_max_temp_result 5 リザルトキャッシュの合計温度のパーセントとしての結果ごとの最大温度
result_cache_max_temp_size 322122540 使用する一時スペースの最大量
sec_case_sensitive_logon TRUE 大文字と小文字を区別するパスワードのログオンを有効化
shard_queries_restricted_by_key FALSE シャードキー述語をクエリに追加
tablespace_encryption_default_algorithm AES128 デフォルト表領域暗号化のブロック暗号モード
tde_key_cache FALSE TDE中間キーキャッシュの有効化
timezone_version_upgrade_online FALSE オンラインでタイムゾーンバージョンのアップグレードを有効/無効化
unified_audit_sga_queue_size 1048576 統合監査SGAキューのサイズ

 

デフォルト値から変更されているパラメータもいくつかありましたので、主なものを記載します。
隠しパラメータ含め各種パラメータがデフォルトから明示的に変更されていることから、OCIでデータベースを作成するとすぐに最適な状態で使えるようです。

パラメータ 設定値 デフォルト値
_datafile_write_errors_crash_instance FALSE TRUE
_db_writer_coalesce_area_size 16777216 0
_disable_interface_checking TRUE FALSE
_file_size_increase_increment 2143289344 0
_fix_control 18960760:on NULL
_gc_policy_time 20 0
audit_trail DB none
connection_brokers ((TYPE=DEDICATED)(BROKERS=1)), ((TYPE=EMON)(BROKERS=1))
control_file_record_keep_time 3 7
db_block_checksum FULL TYPICAL
db_cache_advice ON OFF
db_file_multiblock_read_count 128 0
db_files 1024 200
db_writer_processes 1 0
dml_locks 1416 NULL
enable_ddl_logging TRUE FALSE
fast_start_mttr_target 300 0
filesystemio_options setall asynch
inmemory_max_populate_servers 0 65535
log_buffer 16777216 0
multishard_query_partial_results no allowed
parallel_servers_target 80 0
plsql_warnings DISABLE:ALL NONE
session_cached_cursors 100 50
use_dedicated_broker FALSE TRUE
use_large_pages only TRUE

OS設定確認

オンプレミスでデータベースをインストールおよび使用する際に必要な、OS要件として設定する項目についても確認してみましたが、すでに各種設定済みの状況でした。

OSバージョンは7.9です。

[oracle@host21c ~]$ cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="7.9"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.9"
PRETTY_NAME="Oracle Linux Server 7.9"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:7:9:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7"
ORACLE_BUGZILLA_PRODUCT_VERSION=7.9
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=7.9
[oracle@host21c ~]$
[oracle@host21c ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
[oracle@host21c ~]$

 

[.bash_profile]にはPATHのみ記載されていることを確認しました。
[oracle@host21c ~]$ cat .bash_profile
# .bash_profile

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

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
umask 022
[oracle@host21c ~]$

 

.bashrcにORACLE環境変数やPATHが設定済みです。

[oracle@host21c ~]$ cat .bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
ORACLE_HOME=/u01/app/oracle/product/21.0.0.0/dbhome_1; export ORACLE_HOME
PATH=$PATH:/u01/app/oracle/product/21.0.0.0/dbhome_1/bin; export PATH
LD_LIBRARY_PATH=/u01/app/oracle/product/21.0.0.0/dbhome_1/lib; export LD_LIBRARY_PATH
ORACLE_UNQNAME=db21c_nrt1fp;export ORACLE_UNQNAME
ORACLE_SID=db21c; export ORACLE_SID
## WARNING!! Modifying this file can cause failures in API/CLI provided by Cloud Tooling!!
[oracle@host21c ~]$

 

カーネルパラメータは各種設定済みです。
21cのインストレーションガイドが公開されていないので何とも言えませんが、19cのカーネルパラメータ確認と比較すると結構差分があるようです。
https://docs.oracle.com/cd/F19136_01/ladbi/configuring-kernel-parameters-for-linux.html#GUID-6127884D-FB27-45FA-9498-B2540632CBD5

[oracle@host21c ~]$ cat /etc/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-19c setting for fs.file-max is 6815744
fs.file-max = 6815744

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

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

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

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

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

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


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


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

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

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

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

fs.suid_dumpable=1
kernel.core_pattern=core.%e.%p
net.ipv4.conf.all.arp_announce=2
net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_filter=1
net.core.rmem_max=134217728
net.core.wmem_max=134217728
net.ipv4.tcp_rmem=4096 87380 134217728
net.ipv4.tcp_wmem=4096 65536 134217728
net.core.netdev_max_backlog=300000
net.ipv4.tcp_moderate_rcvbuf=1
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
fs.aio-max-nr=3145728
vm.min_free_kbytes=524288
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
kernel.pid_max = 99999
vm.nr_hugepages=3226
[oracle@host21c ~]$

 

oracle/gridユーザのシェル制限が設定済みです。

[oracle@host21c ~]$ cat /etc/security/limits.conf
# /etc/security/limits.conf
#
#This file sets the resource limits for the users logged in via PAM.
#It does not affect resource limits of the system services.
#
#Also note that configuration files in /etc/security/limits.d directory,
#which are read in alphabetical order, override the settings in this
#file in case the domain is the same or more specific.
#That means for example that setting a limit for wildcard domain here
#can be overriden with a wildcard setting in a config file in the
#subdirectory, but a user specific setting here can be overriden only
#with a user specific setting in the subdirectory.
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - a user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock 11000000
# - nofile - max number of open file descriptors
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
#
#<domain> <type> <item> <value>
#

#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4

# End of file
grid soft nofile 131072
grid hard nofile 131072
grid soft nproc 131072
grid hard nproc 131072
grid soft core unlimited
grid hard core unlimited
grid soft memlock unlimited
grid hard memlock unlimited

oracle soft nofile 131072
oracle hard nofile 131072
oracle soft nproc 131072
oracle hard nproc 131072
oracle soft core unlimited
oracle hard core unlimited
oracle soft memlock unlimited
oracle hard memlock unlimited

oracle soft stack 10240
oracle hard stack 32768
[oracle@host21c ~]$

 

PAM設定済みです。

[oracle@host21c ~]$ cat /etc/pam.d/login
#%PAM-1.0
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth substack system-auth
auth include postlogin
account required pam_nologin.so
account include system-auth
password include system-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
session optional pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open
session required pam_namespace.so
session optional pam_keyinit.so force revoke
session include system-auth
session include postlogin
-session optional pam_ck_connector.so
session required pam_limits.so
[oracle@host21c ~]$

 

ユーザ一覧にroot/opc/oracle/gridユーザが作成済みです。

[oracle@host21c ~]$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
polkitd:x:999:996:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
sssd:x:998:994:User for sssd:/:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
dhcpd:x:177:177:DHCP server:/:/sbin/nologin
saslauth:x:997:76:Saslauthd user:/run/saslauthd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
opc:x:54322:54323::/home/opc:/bin/bash
mysql:x:54323:54331::/home/mysql:/bin/bash
grid:x:102:1001::/home/grid:/bin/bash
oracle:x:101:1001::/home/oracle:/bin/bash
[oracle@host21c ~]$

 

グループ一覧にOracle関連のグループが作成済みです。

[oracle@host21c ~]$ cat /etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:
cdrom:x:11:
mail:x:12:
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:33:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
utempter:x:35:
input:x:999:
systemd-journal:x:190:
systemd-network:x:192:
dbus:x:81:
rpc:x:32:
printadmin:x:998:
ssh_keys:x:997:
polkitd:x:996:
cgred:x:995:
tss:x:59:
sssd:x:994:
ntp:x:38:
rpcuser:x:29:
nfsnobody:x:65534:
named:x:25:
sshd:x:74:
dhcpd:x:177:
saslauth:x:76:
slocate:x:21:
screen:x:84:
tcpdump:x:72:
backupdba:x:54324:
dgdba:x:54325:
kmdba:x:54326:
racdba:x:54330:
opc:x:54323:opc
mysql:x:54331:
asmdba:x:1006:grid,oracle
asmoper:x:1005:grid
asmadmin:x:1004:grid
dba:x:1003:oracle
dbaoper:x:1002:grid,oracle
oinstall:x:1001:oracle
[oracle@host21c ~]$

 

透過的HugePagesは無効化済みです。

[oracle@host21c ~]$ cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
[oracle@host21c ~]$

 

まとめ

今回、初めてOracle Cloudを使用して21cデータベースの作成を行ったのですが、簡単に作成できました。

今まで、オンプレミス環境でデータベースをインストールおよび作成する際に、事前にデータベースのOS要件を満たすために
LinuxであればOSの各種ファイルを設定したり
不足しているパッケージ(rpm)をインストールしたり
Oracleソフトウェアのインストールやデータベースを作成するためには、ウィザードで各種設定を行うなどとても多くの作業が必要でしたが

OCIでは必要最低限の情報を入力するだけで
わずか1時間以内にデータベースを作成するだけでなく、最適な設定で使用できる状態で提供されるということがわかりました。

お客様によっては、別途環境固有で必要なパラメータ設定のような作業はあるかと思いますが、
一般的なデータベースの設計や構築のコストはかなり削減できると思いました。

なお、Oracle社の21c紹介記事にもあるように、21cは革新(Innovation)リリース版であり、サポート期間も2023年6月迄で19cよりも短くなっており、選定するバージョンとしては不向きであると思われます。
今後、12c系(12.1.X/12.2.0.1/18c≒12.2.0.2/19c≒12.2.0.3)の後継である13c?系 (21c以降)を導入することを検討される場合は、Long Term(長期)バージョンがリリースされるまでは新機能の検証確認程度にとどめておく方がよさそうです。

・Oracle Databaseサポート・ライフサイクルロードマップ

 

最後に

最後になりますが、当社にはCloudの領域を含めデータベースに関わるエンジニアが
多数在籍しておりますので、何かご不明なことや、
ご興味を持たれたことがございましたら、お気軽に当社までお問合せ下さい🍀

お問い合わせはこちら📩