1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Oracle Database 23ai FreeをUbuntuにインストールしてみた

Posted at

とあるきっかけでWSL2に建っているUbuntuにOracleをインストールすることになりました。
備忘録を兼ねて、記事に残します。

# lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       noble

下記コマンドでホスト名を変更しておく。rootユーザで実行します。

hostnamectl set-hostname localhost

下記コマンドでOracleのパッケージを取得します。rootユーザで実行します。

wget https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinstall-23ai-1.0-2.el8.x86_64.rpm
wget https://download.oracle.com/otn-pub/otn_software/db-free/oracle-database-free-23ai-1.0-1.el8.x86_64.rpm

取得したRPMパッケージをDEB形式に変換します。rootユーザで実行します。

apt update
apt upgrade
apt install alien
alien oracle-database-preinstall-23ai-1.0-2.el8.x86_64.rpm
alien oracle-database-free-23ai-1.0-1.el8.x86_64.rpm

変換したDEBパッケージを用いてインストールします。rootユーザで実行します。

dpkg -i ./oracle-database-preinstall-23ai_1.0-3_amd64.deb
dpkg -i ./oracle-database-free-23ai_1.0-2_amd64.deb

グループを作成します。rootユーザで実行します。

groupadd oinstall
groupadd dba
groupadd oper
groupadd backupdba
groupadd dgdba
groupadd kmdba

ユーザを作成します。rootユーザで実行します。

useradd -g oinstall -G dba,oper,backupdba,dgdba,kmdba -s /bin/bash oracle

oracleユーザの.bashrcに下記環境変数を定義する。rootユーザで実行します。

# mkdir /home/oracle
# cd /home/oracle
# cp /root/.bashrc .
# chown -R oracle /home/oracle

# view ./.bashrc
↓↓↓↓↓↓↓↓以下の内容をファイル末尾に追加する
export ORACLE_SID=FREE
export ORACLE_HOME=/opt/oracle/product/23ai/dbhomeFree
export NLS_LANG=Japanese_Japan.AL32UTF8
export PATH=$ORACLE_HOME/bin:$PATH
export LANG=ja_JP.UTF-8
export LD_LIBRARY_PATH=/var/home/lib/aio/lib:$LD_LIBRARY_PATH

ファイルパーミッションの変更。rootユーザで実行します。

# chown -R oracle:oinstall /opt/oracle
# chown root:root /opt/oracle/product/23ai/dbhomeFree/bin/oradism
# chmod 4755 /opt/oracle/product/23ai/dbhomeFree/bin/oradism

libaioをインストールする。rootユーザで実行します。

# mkdir /var/home
# mkdir /var/home/lib
# mkdir /var/home/lib/aio
# wget https://src.fedoraproject.org/lookaside/pkgs/libaio/libaio-0.3.110.tar.gz/2a35602e43778383e2f4907a4ca39ab8/libaio-0.3.110.tar.gz
# tar xvfz libaio-0.3.110.tar.gz
# cd libaio-0.3.110/
# make prefix=/var/home/lib/aio install

環境変数を設定する。
# export LD_LIBRARY_PATH=/var/home/lib/aio/lib:$LD_LIBRARY_PATH

構成スクリプトを実行する。デフォルトデータベースの作成、その他諸々設定している模様。rootユーザで実行します。

/etc/init.d/oracle-free-23ai 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:←再度パスワードを入力する。

/etc/oratabを作成。rootユーザで実行します。

# view /etc/oratab
下記内容をファイル内に記述する。
FREE:/opt/oracle/product/23ai/dbhomeFree:Y

sqlplusで接続できるか試してみる。oracleユーザで実行します。

# su oracle
$ sqlplus sys@localhost/FREEPDB1 as sysdba
SQL*Plus: Release 23.0.0.0.0 - Production on 火 2月 11 20:26:41 2025
Version 23.7.0.25.01

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

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

Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.7.0.25.01
に接続されました。
SQL>

Oracleの自動起動設定を行います。rootユーザで実行します。

# view /etc/init.d/oracle-free-23ai
↓↓↓↓↓↓↓↓↓↓ファイルの先頭を以下の通り修正する。
#!/bin/bash
### BEGIN INIT INFO
# Provides:          Oracle
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Oracle init.d
### END INIT INFO
export LD_LIBRARY_PATH=/var/home/lib/aio/lib
# change log:
(省略)
# /usr/lib/systemd/systemd-sysv-install enable oracle-free-23ai
# systemctl daemon-reload
# systemctl start oracle-free-23ai

以上です。お疲れ様でした!

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?