CentOS 5.3 に Oracle10g XE をインストールする

Pocket

ここでは、CentOS 5.3 に rpm ファイルで配布されている Oracle10g XE をインストールする方法を掲載しています。

スポンサーリンク

Oracle10g XE を rpm コマンドでインストール

Oracle10g XE とは、無償で利用可能な Oracle データベースであり、( リンク切れ ) Oracle Database 10g Release 2 (10.2.0.1) Express Edition for Linux x86 からダウンロードできます。rpm ファイルで配布されており、インストールも非常に簡単です。 まずは、ダウンロードした rpm ファイルを適当な場所に配置して、rpm コマンドでインストールします。

現在 ( 2016年3月末 )、ダウンロードできる無償利用可能な Oracle は Oracle Database 11g Express Edition です。本記事の内容が参考となるかどうかは、検証できていません。

[root@host rpm] pwd
/usr/local/rpm
[root@host rpm] ls
oracle-xe-univ-10.2.0.1-1.0.i386.rpm
[root@host rpm] rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm
準備中...         ########################################### [100%]
   1:oracle-xe-univ   ########################################### [100%]
Executing Post-install steps...
You must run '/etc/init.d/oracle-xe configure' as the root user to
configure the database.

インストールは以上です。無償利用可能であることから制約はありますが、学習用や社内(学内)利用程度であれば特に問題なく使用できることも多いと思います。

インストールに失敗する

Oracle をインストールするためには、最低限必要となる swap 領域が確保されている必要があります。 swap 領域が不足する場合は、以下のようにインストールに失敗します。

エラー: %pre(oracle-xe-univ-10.2.0.1-1.0.i386) スクリプトの実行に失敗しました。終了ステー タス 1

[root@host rpm] rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm
準備中...                ########################################### [100%]
This system does not meet the minimum requirements for swap space.  Based on
the amount of physical memory available on the system, Oracle Database 10g
Express Edition requires 1506 MB of swap space. This system has 1009 MB
of swap space.  Configure more swap space on the system and retry the installation.
エラー: %pre(oracle-xe-univ-10.2.0.1-1.0.i386) スクリプトの実行に失敗しました。終了ステー タス 1

OS から再インストールし、swap 領域を十分に与えることが確実ですが、swap 領域を dd コマンドで追加してみます。再インストールできない場合や、 一時的な開発環境であればこの対応で十分だと思います。

スワップ領域の追加

[root@host rpm] dd if=/dev/zero of=/swap bs=1024 count=1048576
1048576+0 records in
1048576+0 records out
1073741824 bytes (1.1 GB) copied, 17.6374 seconds, 60.9 MB/s
[root@host rpm] swapon /swap
[root@host rpm] cat /proc/swaps
Filename              Type            Size      Used    Priority
/dev/sda5             partition       1022072  128     -1
/swap                 file            1048568  0       -2

スワップ領域の有効化

次に、OS 再起動時に追加した swap 領域を有効にするための設定を /etc/fstab に行います。

[root@host rpm] vi /etc/fstab
/swap swap swap defaults 0 0  # ← 追加

Oracle データベースの初期設定

/etc/init.d/oracle-xe configure で Oracle データベースの初期設定を行います。 sys および system ユーザーのパスワードは任意で与え、その他の設定はデフォルトのままとしています。

[root@host rpm] /etc/init.d/oracle-xe configure

Oracle Database 10g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 10g Express
Edition.  The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts.  Press <Enter> to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:

Specify a port that will be used for the database listener [1521]:

Specify a password to be used for database accounts.  Note that the same
password will be used for SYS and SYSTEM.  Oracle recommends the use of
different passwords for each database account.  This can be done after
initial configuration:
Confirm the password:

Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]:y

Starting Oracle Net Listener...Done
Configuring Database...Done
Starting Oracle Database 10g Express Edition Instance...Done
Installation Completed Successfully.
To access the Database Home Page go to "http://127.0.0.1:8080/apex"

Oracle の環境変数設定

sqlplus などで oracle に接続する場合、$ORACLE_HOME などの環境変数が設定されている必要があります。 各ユーザーごとに環境変数設定するほうがセキュリティ的にも良いと思いますが、ここでは、全てのユーザーに対して Oracle 環境変数の設定をしています。設定するファイルは /etc/profile です。

[root@host rpm] vi /etc/profile
. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh ← 追加

# source コマンドで変更を有効とする
[root@host rpm] source /etc/profile

ファイアーウォールの設定

Oracle データベースが接続を受け付ける 1521 番ポートを開放します。設定ファイルは /etc/sysconfig/iptables です。

※ インストール時に指定したポート番号
※ すでに解放されている場合は、この処理はもちろん不要

[root@host rpm] vi /etc/sysconfig/iptables 
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT ← 追加

[root@host rpm] service iptables restart
ファイアウォールルールを適用中:                            [  OK  ]
チェインポリシーを ACCEPT に設定中filter                   [  OK  ]
・・・
スポンサーリンク


Pocket

Leave a Comment

Your email address will not be published. Required fields are marked *