■Debian LennyにOracle11gXEを導入する
参考:Oracle 11g XEをUbuntuにインストール
http://blog.liris.org/2011/09/oracle-11g-xeubuntu.html
■必要なパッケージをインストール
$ sudo apt-get install alien libaio1 unixodbc
■Debianにはzipを展開するパッケージがデフォルトで入っていなかった。
$ sudo apt-get install unzip
$ unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
Archive: iso_system/Oracle11gR2Express/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
creating: Disk1/
creating: Disk1/upgrade/
inflating: Disk1/upgrade/gen_inst.sql
creating: Disk1/response/
inflating: Disk1/response/xe.rsp
inflating: Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm
■alienでrpmからdebパッケージに変換します。
※仮想マシン内での変換で、5分程度
$ cd Disk1;time sudo alien --to-deb --scripts oracle-xe-11.2.0-1.0.x86_64.rpm
oracle-xe_11.2.0-2_amd64.deb generated
real 4m55.891s
user 1m17.553s
sys 2m46.474s
■「/sbin/chkconfig」はdebianのパッケージであるけど?
$ dpkg -L chkconfig | grep bin
/sbin
/sbin/chkconfig
/sbin/service
■「chkconfig」自体はperlで書かれていて、awkは場所が異なります。
$ head -1 /sbin/chkconfig
$ whereis -b awk
awk: /usr/bin/awk
■awkの差異はシンボリックで対応する
$ sudo ln -s /usr/bin/awk /bin/awk
■とりあえず実行してみます。
$ sudo dpkg --install ./oracle-xe_11.2.0-2_amd64.deb
未選択パッケージ oracle-xe を選択しています。
(データベースを読み込んでいます ... 現在 42966 個のファイルとディレクトリがインストールされています。)
(./oracle-xe_11.2.0-2_amd64.deb から) oracle-xe を展開しています...
oracle-xe (11.2.0-2) を設定しています ...
Executing post-install steps...
Usage: useradd [options] LOGIN
Options:
-b, --base-dir BASE_DIR base directory for the new user account
home directory
-c, --comment COMMENT set the GECOS field for the new user account
-d, --home-dir HOME_DIR home directory for the new user account
-D, --defaults print or save modified default useradd
configuration
-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-g, --gid GROUP force use GROUP for the new user account
-G, --groups GROUPS list of supplementary groups for the new
user account
-h, --help display this help message and exit
-k, --skel SKEL_DIR specify an alternative skel directory
-K, --key KEY=VALUE overrides /etc/login.defs defaults
-l, do not add the user to the lastlog and
faillog databases
-m, --create-home create home directory for the new user
account
-N, --no-user-group do not create a group with the same name as
the user
-o, --non-unique allow create user with duplicate
(non-unique) UID
-p, --password PASSWORD use encrypted password for the new user
account
-r, --system create a system account
-s, --shell SHELL the login shell for the new user account
-u, --uid UID force use the UID for the new user account
-U, --user-group create a group with the same name as the user
/bin/chown: ユーザ指定が不正: `oracle:dba'
/bin/chown: ユーザ指定が不正: `oracle:dba'
/bin/chown: ユーザ指定が不正: `oracle:dba'
/bin/chown: ユーザ指定が不正: `oracle:dba'
insserv: warning: script 'oracle-xe' missing LSB tags and overrides
insserv: warning: current start runlevel(s) (0) of script `halt' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (0 6) of script `umountroot' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (0 6) of script `sendsigs' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (0 6) of script `umountfs' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (6) of script `reboot' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (0 6) of script `umountnfs.sh' overwrites defaults (empty).
oracle-xe 0:off 1:off 2:on 3:on 4:on 5:on 6:off
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
■ユーザの作成に失敗しているので、
その後のchownに失敗しているようです。
$ grep dba /etc/passwd
$ grep dba /etc/group
dba:x:1001:
$ whereis -b useradd
useradd: /usr/sbin/useradd
■chkconfigについては問題なさそうです。
$ ls /etc/init.d/oracle-xe
/etc/init.d/oracle-xe
■debパッケージ内のファイルを確認する
$ ar -t oracle-xe_11.2.0-2_amd64.deb
debian-binary
control.tar.gz
data.tar.gz
■debパッケージからファイルを取り出す
$ ar -x oracle-xe_11.2.0-2_amd64.deb
■「control.tar.gz」に「postinst」が見つかった。
$ tar ztvf control.tar.gz | grep post
-rwxr-xr-x root/root 11418 2011-12-17 17:59 ./postinst
■「control.tar.gz」の展開
$ tar zxvf control.tar.gz
./
./control
./preinst
./conffiles
./shlibs
./postinst
./md5sums
./postrm
./prerm
■エラーの原因を探る
debianのuseraddには「-M」オプションが存在しない。
「-M」はホームディレクトリを作成しないオプション。
参考:Red Hat Linux 9: Red Hat Linux カスタマイズガイド(第 25章ユーザーとグループの設定)
http://www.jp.redhat.com/manual/Doc9/rhl-cg-ja-9/s1-users-cmd-line.html
★該当箇所
$ grep useradd postinst
/usr/sbin/useradd -M -g dba -d /u01/app/oracle -s /bin/bash oracle
★上記は「id oracle」が失敗したときだけ実行される
$ grep -A 2 "id oracle" postinst
id oracle > /dev/null 2>&1
status=$?
if test $status -eq 0
★先に作成しておけば問題なし。
$ sudo /usr/sbin/useradd -g dba -d /u01/app/oracle -s /bin/bash oracle
$ grep oracle /etc/passwd
oracle:x:1001:1001::/u01/app/oracle:/bin/bash
$ id oracle >/dev/null && echo $?
0
■一旦、アンインストールする
★インストールされた情報を確認
$ grep oracle-xe /var/lib/dpkg/status
Package: oracle-xe
/etc/init.d/oracle-xe e54a92692eecde35f8c52a0b67d5d687
★全削除
$ sudo dpkg -P oracle-xe
★削除出来なかったディレクトリ以下を手動で削除
$ sudo rm -fr /u01/
■再度インストールを行う
$ sudo dpkg -i oracle-xe_11.2.0-2_amd64.deb
未選択パッケージ oracle-xe を選択しています。
(データベースを読み込んでいます ... 現在 42966 個のファイルとディレクトリがインストールされています。)
(oracle-xe_11.2.0-2_amd64.deb から) oracle-xe を展開しています...
oracle-xe (11.2.0-2) を設定しています ...
Executing post-install steps...
insserv: warning: script 'K01oracle-xe' missing LSB tags and overrides
insserv: warning: script 'oracle-xe' missing LSB tags and overrides
insserv: warning: current start runlevel(s) (0) of script `halt' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (0 6) of script `umountroot' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (0 6) of script `sendsigs' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (0 6) of script `umountfs' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (6) of script `reboot' overwrites defaults (empty).
insserv: warning: current start runlevel(s) (0 6) of script `umountnfs.sh' overwrites defaults (empty).
oracle-xe 0:off 1:off 2:on 3:on 4:on 5:on 6:off
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
■後は普通に設定をしてあげれば良い。
パスワードの設定以外は基本的にデフォルトのまま[Enter]だけでも通る。
データベースの作成には時間がかかる。
$ sudo /etc/init.d/oracle-xe configure
■まとめ
oracleユーザを先に作成し、chkconfigパッケージを導入しておけば、
Ubuntuと変わらない手順でインストールできる。
■おまけ
★サービス(デーモン)の確認
$ ps aux | grep oracle | grep -v grep | cut -c 66- | head -1
/u01/app/oracle/product/11.2.0/xe/bin/tnslsnr LISTENER -inherit
$ ps aux | grep oracle | grep -v "grep\|tnslsnr" | awk '{print $11}' | column
xe_pmon_XE xe_dbrm_XE xe_ckpt_XE xe_d000_XE xe_vkrm_XE
xe_psp0_XE xe_dia0_XE xe_smon_XE xe_s000_XE xe_qmnc_XE
xe_vktm_XE xe_mman_XE xe_reco_XE xe_s001_XE xe_cjq0_XE
xe_gen0_XE xe_dbw0_XE xe_mmon_XE xe_s002_XE xe_q000_XE
xe_diag_XE xe_lgwr_XE xe_mmnl_XE xe_s003_XE xe_q001_XE
★oracleユーザのパスワードを設定
$ sudo passwd oracle
新しいUNIXパスワードを入力してください:
新しいUNIX パスワードを再入力してください:
passwd: パスワードは正しく更新されました
★ホームディレクトリもshellも問題なし。
$ su - oracle
パスワード:
$ pwd;echo $SHELL
/u01/app/oracle
/bin/bash
★起動/停止スクリプトも問題なし。
$ sudo find /etc | grep oracle-xe
/etc/rc4.d/S19oracle-xe
/etc/rc1.d/K01oracle-xe
/etc/init.d/oracle-xe
/etc/rc0.d/K01oracle-xe
/etc/default/oracle-xe
/etc/rc3.d/S19oracle-xe
/etc/rc5.d/S19oracle-xe
/etc/rc2.d/S19oracle-xe
/etc/rc6.d/K01oracle-xe
■ログインチェック
$ source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
$ sqlplus system/*****
SQL*Plus: Release 11.2.0.2.0 Production on 土 12月 17 19:26:20 2011
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
に接続されました。
SQL> exit
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Productionとの接続が切断されました。
■後片付け
$ sudo rm /bin/awk
$ echo './control
./preinst
./conffiles
./shlibs
./postinst
./md5sums
./postrm
./prerm' | xargs rm
$ echo 'debian-binary
> control.tar.gz
> data.tar.gz' | xargs rm
■追記
squeezeへの導入時に気づいたが、「/etc/init.d/oracle-xe」で使う
ロックファイル用のディレクトリが無かったので、作成。
oracle-xeが起動中は、「listener」と「oracle-xe」の空のファイルがある。
$ sudo mkdir /var/lock/subsys
■追記2(initスクリプトの修正)
oracle-xeのLSB tagを修正する(debian lenny / squeeze)
http://ameblo.jp/labunix/entry-11116145732.html