ksaitoの日記

日々試したことの覚え書き

UbuntuへのOracleインストール

移転しました。

自動的にリダイレクトします。

OTNで公開されているOracle 10gのdebパッケージをインストールしました。
ダウンロードには、OTNのユーザ登録が必要です。
ダウンロード先のURLと最新バージョンです。
無償でLinux+Oracle環境が作れます。

http://www.oracle.com/technology/software/products/database/xe/htdocs/102xelinsoft.html


Oracle Database 10g Release 2 (10.2.0.1)
Express Edition for Linux x86

Ubuntu 9.04 Serverの64ビット版は、アーキテクチャamdなのでインストールできません。
Ubuntu 9.04のServerとDesktopに、それぞれインストールすることができました。
Webブラウザからのインタフェースが準備されていますが初期状態では、127.0.0.1からのアクセスしか許可されてないため、Ubuntu Serverでは使えません。
(修正する設定ファイルが分かれば、何とかなると思うのですが...)

aptのリポジトリ修正

aptのリポジトリに以下を追加します。

$  tail -2 /etc/apt/sources.list
# oracle
deb http://oss.oracle.com/debian unstable main non-free
$

swapfileの追加

Oracle 10g Exは、1GBのスワップが必要なので、条件を満たしていないと下記のエラーでインストールが失敗します。

$ sudo apt-get install oracle-xe
...
未選択パッケージ oracle-xe を選択しています。
(.../oracle-xe_10.2.0.1-1.1_i386.deb から) oracle-xe を展開しています...
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 1024 MB of swap space. This system has 400 MB 
of swap space.  Configure more swap space on the system and retry the installation.
dpkg: /var/cache/apt/archives/oracle-xe_10.2.0.1-1.1_i386.deb の処理中にエラーが発生しました (--unpack):
 サブプロセス pre-installation script はエラー終了ステータス 1 を返しました
以下のパッケージの処理中にエラーが発生しました:
 /var/cache/apt/archives/oracle-xe_10.2.0.1-1.1_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
パッケージをインストールできませんでした。復旧を試みています:
...

以下の要領でスワップファイルを追加します。

$ sudo dd if=/dev/zero of=/swap0 bs=1M count=1000
1000+0 記録始め
1000+0 記録終わり
1048576000 バイト (1.0 GB) コピー終了, 34.4273 s, 30.5 MB/s
$ sudo mkswap /swap0 
スワップ空間バージョン 1 を設定します、サイズ = 1023996 KiB
no label, UUID=2eb2cb14-2062-41b9-926d-783652db0746
$ free
             total       used       free     shared    buffers     cached
Mem:       1026680     997400      29280          0      17432     770080
 -/+ buffers/cache:     209888     816792
Swap:       409616          0     409616
$ swapon /swap0 
swapon: /swap0: Operation not permitted
$ sudo swapon /swap0 
$ free
             total       used       free     shared    buffers     cached
Mem:       1026680     997912      28768          0      17472     770160
 -/+ buffers/cache:     210280     816400
Swap:      1433608          0    1433608
$

Oracle 10gのインストール

いつも通りoracle-xeというパッケージをインストールするだけです。
oracle-xeが依存しているlibaioとdcの3パッケージがインストールされます。
ダウンロードには、結構時間がかかります。

$ sudo apt-get update
$ sudo aptitude install oracle-xe
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
拡張状態情報を読み込んでいます       
パッケージの状態を初期化しています... 完了
以下の新規パッケージがインストールされます:
  oracle-xe 
0 個のパッケージを更新、 1 個を新たにインストール、 0 個を削除予定、0 個が更新されていない。
アーカイブ 221MB 中 0B を取得する必要があります。 展開後に 405MB のディスク領域が新たに消費されます。
拡張状態情報を書き込んでいます... 完了
(データベースを読み込んでいます ... 現在 103121 個のファイルとディレクトリがインストールされています。)
(.../oracle-xe_10.2.0.1-1.1_i386.deb から) oracle-xe を展開しています...
man-db のトリガを処理しています ...
oracle-xe (10.2.0.1-1.1) を設定しています ...
update-rc.d: warning: /etc/init.d/oracle-xe missing LSB information
update-rc.d: see http://wiki.debian.org/lsbinitscripts
Executing Post-install steps...
 -e You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.


パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
拡張状態情報を読み込んでいます       
パッケージの状態を初期化しています... 完了
$

データベースの設定

インストール時のメッセージに従って/etc/init.d/oracle-xeでHTTPポート、Listenerポート、管理者パスワード、OS起動時のサービスの自動起動を設定します。

$ sudo /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 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: Password can't be null. Enter password: Confirm the password: Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [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" $

クライアント環境の設定

Webブラウザでアクセスできますが、コマンドラインの環境も必要です。
.bashrcに1行追加してログインし直すだけでOKです。
XEというインスタンスが立ち上がっていてsqlplusで接続することができます。

$ tail -2 ~/.bashrc
# oracle
. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh
$ sqlplus system@XE

SQL*Plus: Release 10.2.0.1.0 - Production on Sat May 30 20:43:56 2009

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

Enter password: 

Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL>