無償版Oracle: Oracle Express Edition をインストールする

Oracle の勉強のため、無償版の Oracle Express Edition( Oracle XE )をインストールしてみたところ、若干ハマってしまったので記録のために記事にしておく。

環境

Conoha VPS でサーバを立ててインストールする。

  • OS:CentOS Stream 8
  • CPU:3コア
  • メモリ:2GB
  • ディスク:100GB (SSD)

ハマったポイント

先に書いておくと、インストール中にハマったポイントは以下の2つ。

  1. 手順に記載のあるrpmファイルのダウンロードURLが違っていた。
  2. セットアップ時に、メモリが1GB以上ないとエラーが発生する*1

手順

以下のページの内容に従い、最新版である Oracle Database 21c Express Edition をインストールしていく。インストール→セットアップ→環境変数設定の順に実施する。今回は CentOS Steram 8 にインストールするため、For Red Hat Enterprise Linux 8 もしくは For Oracle Linux 8 の記載のある方のコマンドを実行していく。

docs.oracle.com

インストール

1. rootユーザで実行する

rootユーザになっていない場合は、sudo -u で切り替える。

# whoami
root
2. プレインストール用rpmをダウンロード、インストールする

ここが第1のハマりポイント。手順通りに For Red Hat Enterprise Linux 8 のコマンドを実行しても、ダウンロードされたファイルの中身がNot foundになってしまっている。

# curl -o oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL8/latest/x86_64/getPackage/oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    10  100    10    0     0      4      0  0:00:02  0:00:02 --:--:--     4

# less oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm 
Not found

Linux 8 向けのrpmファイルは以下のURLからダウンロードすることができる。latestappstream に書き換えると良い*2

# curl -o oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 30772  100 30772    0     0  1669k      0 --:--:-- --:--:-- --:--:-- 1669k

# less oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm 

Name        : oracle-database-preinstall-21c
Version     : 1.0
Release     : 1.el8
Architecture: x86_64
Install Date: (not installed)
Group       : Unspecified
Size        : 77830
License     : GPLv2
( ... 以下略 )

ダウンロードした rpm ファイルを使ってインストールする。色々インストールされるが、oracle-database-preinstall-21c-1.0.1.el8.x86_64 が含まれていればOK。

# dnf -y localinstall oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm

( ...中略... )

Installed:
  compat-openssl10-1:1.0.2o-3.el8.x86_64       glibc-devel-2.28-164.el8.x86_64         glibc-headers-2.28-164.el8.x86_64                     gssproxy-0.8.0-20.el8.x86_64                                
  kernel-headers-4.18.0-365.el8.x86_64         keyutils-1.5.10-9.el8.x86_64            ksh-20120801-254.el8.x86_64                           libICE-1.0.9-15.el8.x86_64                                  
  libSM-1.2.3-1.el8.x86_64                     libX11-1.6.8-5.el8.x86_64               libX11-common-1.6.8-5.el8.noarch                      libX11-xcb-1.6.8-5.el8.x86_64                               
  libXau-1.0.9-3.el8.x86_64                    libXcomposite-0.4.4-14.el8.x86_64       libXext-1.3.4-1.el8.x86_64                            libXi-1.7.10-1.el8.x86_64                                   
  libXinerama-1.1.4-1.el8.x86_64               libXmu-1.1.3-1.el8.x86_64               libXrandr-1.5.2-1.el8.x86_64                          libXrender-0.9.10-7.el8.x86_64                              
  libXt-1.1.5-12.el8.x86_64                    libXtst-1.2.3-7.el8.x86_64              libXv-1.0.11-7.el8.x86_64                             libXxf86dga-1.1.5-1.el8.x86_64                              
  libXxf86misc-1.0.4-1.el8.x86_64              libXxf86vm-1.1.4-9.el8.x86_64           libdmx-1.1.4-3.el8.x86_64                             libnsl-2.28-164.el8.x86_64                                  
  libverto-libevent-0.3.0-5.el8.x86_64         libxcb-1.13.1-1.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                   nfs-utils-1:2.3.3-50.el8.x86_64         oracle-database-preinstall-21c-1.0-1.el8.x86_64       policycoreutils-python-utils-2.9-15.el8.noarch              
  rpcbind-1.2.5-8.el8.x86_64                   sysstat-11.7.3-7.el8.x86_64             xorg-x11-utils-7.5-28.el8.x86_64                      xorg-x11-xauth-1:1.0.9-12.el8.x86_64                                                                                                                                                             

Complete!
3.インストール用rpmのダウンロード元を確認する

以下のサイトからダウンロードできる。今回は CentOS 8 にインストールするので、for Linux x64 ( OL8 ) のものを利用する。

www.oracle.com

4.インストール用rpmファイルのダウンロード

3.で確認したURLからダウンロードする。

# wget https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm

念のため、ダウンロードできているかを確認。

# ls -l
total 2284856
-rw-r--r-- 1 root root      30772 Oct 30 00:06 oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 2339651768 Sep  8 20:26 oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm
5.インストール
# dnf -y localinstall oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm

( ...中略... )

Installed:
  oracle-database-xe-21c-1.0-1.x86_64                                                                                                                                                                       

Complete!

(余談)2. の手順を飛ばしてしまっていると、こちらのコマンド実行時にエラーが発生する。

Error: 
 Problem: conflicting requests
  - nothing provides oracle-database-preinstall-21c needed by oracle-database-xe-21c-1.0-1.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

セットアップ

インストール作業が終わってもすぐに使うことはできず、最初にセットアップが必要となる。

1. rootユーザで実行

インストール時と同じく、rootユーザになっていない場合は sudo -u で切り替える。

# whoami
root
2. スクリプトを実行

ここが第2のハマりポイント。メモリが1GBない場合は、実行時にエラーが発生する。

[SEVERE] Oracle Database 21c Express Edition requires a minimum of 1GB of physical 
memory (RAM).  This system has 808 MB of RAM and does not meet minimum 
requirements.

error: %prein(oracle-database-xe-21c-1.0-1.x86_64) scriptlet failed, exit status 1

Error in PREIN scriptlet in rpm package oracle-database-xe-21c
  Verifying        : oracle-database-xe-21c-1.0-1.x86_64                                                                                                                                                1/1 

Failed:
  oracle-database-xe-21c-1.0-1.x86_64                                                                                                                                                                       

Error: Transaction failed

メモリが1GB以上ある場合は問題なく実行できる。実行時にSYS、SYSTEM、PDBADMINアカウントのパスワードを指定する必要がある。

# /etc/init.d/oracle-xe-21c 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:
The password you entered contains invalid characters. Enter password:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
Enter SYS user password: 
****************
Enter SYSTEM user password: 
***************
Enter PDBADMIN User Password: 
***************
Prepare for db operation

( ...中略... )

Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.

Connect to Oracle Database using one of the connect strings:
     Pluggable database: XXX-XXX-XXX-XXX/XEPDB1
     Multitenant container database: XXX-XXX-XXX-XXX
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE

環境変数設定

ここは手順中のコマンドをそのまま実行すればOK。

# export ORACLE_SID=XE
# export ORAENV_ASK=NO
# . /opt/oracle/product/21c/dbhomeXE/bin/oraenv
The Oracle base has been set to /opt/oracle

接続

sqlplusコマンドが使えるようになっているので、セットアップ時に指定したパスワードで接続してみる。

# sqlplus /nolog

SQL*Plus: Release 21.0.0.0.0 - Production on Sat Oct 30 01:42:15 2021
Version 21.3.0.0.0

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

SQL> CONNECT SYS AS SYSDBA
Enter password: 
Connected.

ここまでで接続できることまで確認できた。実際に使ってみるのはまた次回。。

*1:System Requirementsに記載があるかもしれないが見つけることができず、 とりあえずメモリが1GBのサーバで最初に試したところエラーに当たってしまった

*2:Linux 7 向けと Linux8 向けでは rpm ファイルが配置されているディレクトリ構成が違っているが、どちらも Linux 7 向けのディレクトリ構成でURLが記載されているのが原因