CentOS / Oracle9
Oracle 9.2.0.4 Evaluation Install for CentOS-4.4
定数
ORACLE_HOME | /home/oracle/product/9.2.0 |
GDN(グローバルデータベース名) | ora92.localdomain |
SID | ora92 |
全体的に参考にしたサイト
- http://www.valumo.com/storage/archives/data_base/oracle/
- http://www.unix-power.jp/linux/oracle.html
- http://www.linux.or.jp/JF/JFdocs/Oracle-8-HOWTO.html
そのほか google 先生経由で参考にしたサイト多数
oracle ユーザーの作成
# groupadd -g 1000 oinstall # groupadd -g 1001 dba # useradd -g oinstall -G dba oracle # passwd oracle (oracle)
gcc のバージョンを下げる
これをしないと、ins_plsql.mk のターゲット install 起動中にエラーが発生する
(from http://d.hatena.ne.jp/ocs/20060716#1153022945)
# cd /tmp # wget http://ftp.kddilabs.jp/Linux/packages/fedora/core/2/i386/os/Fedora/RPMS/compat-gcc-7.3-2.96.126.i386.rpm # rpm -ivh compat-gcc-7.3-2.96.126.i386.rpm # cd /usr/bin # mv gcc gcc343 # mv gcc296 gcc
カーネル・パラメータの設定
SHMMAXは物理メモリの半分にする。
/etc/sysctl.conf に追加 ( 追加後、# sysctl -p で動的に変更する )
#for oracle kernel.shmmax = 268435456 kernel.sem=100 32000 100 100 fs.file-max=65536 net.ipv4.ip_local_port_range=1024 65000
/etc/security/limits.conf に追加
* hard nproc 16384 * soft nofile 2048 * hard nofile 65536
libstdc++ のバージョンを下げる
compat-libstdc++-7.3-2.96.118.i386.rpm を、http://rpmfind.net/linux/RPM/index.html から入手
# rpm -ivh compat-libstdc++-7.3-2.96.118.i386.rpm 警告: compat-libstdc++-7.3-2.96.118.i386.rpm: V3 DSA signature: NOKEY, key ID db 42a60e Preparing... ########################################### [100%] 1:compat-libstdc++ ########################################### [100%] #
パッチ 3006854 を適用する
これを行わないと、以下のエラーが出る
Error occurred during initialization of VM Unable to load native library: /tmp/OraInstall2003-10-25_03-14-57PM/jre/lib/i386/libjava.so: symbol __libc_wait, version GLIBC_2.0 not defined in file libc.so.6 with link time reference
# unzip p3006854_9204_LINUX.zip Archive: p3006854_9204_LINUX.zip creating: 3006854/ inflating: 3006854/rhel3_pre_install.sh inflating: 3006854/README.txt # cd 3006854 # sh rhel3_pre_install.sh Applying patch... Patch successfully applied #
TCP 経由での X サーバ接続を許可する
デフォルトのログインマネージャとして使用している GDM が標準の設定で X サーバーへの TCP 接続を許可していないため
- root で gdmsetup コマンドを実行し、GDM の設定画面を表示
- セキュリティタブを表示して、"常に TCP 接続を禁止する"の選択を解除
- [閉じる]ボタンをクリック
.bash_profile に環境変数を設定
export DISPLAY=localhost:0.0 export ORACLE_BASE=/home/oracle export ORACLE_HOME=$ORACLE_BASE/product/9.2.0 export ORACLE_SID=ora92 export NLS_LANG=Japanese_Japan.JA16EUC export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data export PATH=$PATH:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib export TNS_ADMIN=$ORACLE_HOME/network/admin export LD_ASSUME_KERNEL=2.4.19
インストーラの解凍
- 以下のファイルを転送
ship_9204_linux_disk1.cpio.gz ship_9204_linux_disk2.cpio.gz ship_9204_linux_disk3.cpio.gz
- ファイルを解凍(./Diskn/も作られる)
$ gzip -dc ship_9204_linux_disk1.cpio.gz | cpio -idmv $ gzip -dc ship_9204_linux_disk2.cpio.gz | cpio -idmv $ gzip -dc ship_9204_linux_disk3.cpio.gz | cpio -idmv
- 元ファイルを削除
$ rm ship_9204_linux_disk*gz
インストーラの起動
$ cd /home/oracle/Disk1 $ ./runInstaller
入力内容
UNIXグループ名では、「oinstall」を指定
(rootでの実施)
# cd /tmp # ./orainstRoot.sh
インストールする製品は、「Oracle9i Database 0.2.0.4.0 - Enterprise Edition」
(rootでの実施)
一箇所、ユーザーによる入力を待つので注意
Enter the full pathname of the local bin directory: [/usr/local/bin] では、Enter のみを入力
# cd /home/oracle/product/9.2.0 # ./root.sh Running Oracle9 root.sh script... \nThe following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /home/oracle/product/9.2.0 Enter the full pathname of the local bin directory: [/usr/local/bin]: Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ... \nCreating /etc/oratab file... Adding entry to /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root.sh script. Now product-specific root actions will be performed. #
構成ツール
Database Configuration Assistant は、非常に待たされるが根気強く待つ。
sys および system のパスワードは、仮に oracle とした
Agent Configuration Assistant が異常終了するが、後で対応するためここでは無視する
$ /home/oracle/product/9.2.0/JRE/bin/jre -classpath /home/oracl e/product/9.2.0/JRE/lib/rt.jar:/home/oracle/product/9.2.0/jlib/srvm.jar:/home/or acle/product/9.2.0/network/agent/agentca.jar oracle.agent.AgentCA /orahome /hom e/oracle/product/9.2.0 /nodeinfo NO_VALUE Parameter "orahome" = /home/oracle/product/9.2.0 Parameter "nodeinfo" = NO_VALUE Agent Service Failed $
セットアップ完了
The following information is available in: /home/oracle/product/9.2.0/Apache/Apache/setupinfo.txt ----------------------------------------- The HTTP Server can be accessed using the following URLs: Non SSL Mode: http://centos:7777 SSL mode (executed at install time): http://centos:7778 https://centos:4443
/etc/oratab の対象フラグを立てる(N→Y)
dbshutの修正
dbshut の中身を、shutdowm (normal)からimmediateに変更。
$ diff dbshut.060903 dbshut 80c80 < shutdown --- > shutdown immediate 85c85 < shutdown --- > shutdown immediate $
Agent Configuration Assistant 対応
- 最初に dbshut および lsnrctl stop しておく
- http://ivan.kartik.sk/oracle/install_ora9_suse.html を参考にして対処
$ unzip p2617419_220_GENERIC.zip Archive: p2617419_220_GENERIC.zip creating: OPatch/ (略) inflating: README.txt $ unzip p3238244_9204_LINUX.zip Archive: p3238244_9204_LINUX.zip creating: 3238244/ (略) inflating: 3238244/README.txt $ cd 3238244 $ export PATH=$PATH:/sbin:/home/oracle/OPatch $ opatch apply PERL5LIB=/home/oracle/product/9.2.0/Apache/perl/lib/5.00503:/home/oracle/OPatch/ perl_modules; export PERL5LIB /home/oracle/product/9.2.0/Apache/perl/bin/perl /home/oracle/OPatch/opatch.pl ap ply OPatch Version 1.0.0.0.48 Perl Version 5.00503 Oracle Home = /home/oracle/product/9.2.0 Location of Oracle Inventory = /home/oracle/oraInventory Oracle Universal Installer shared library = /home/oracle/oui/bin/linux/liboraIns taller.so Path to Java = /home/oracle/jre/1.3.1/bin/java Location of Oracle Inventory Pointer = /etc/oraInst.loc Location of Oracle Universal Installer components = /home/oracle/oui Required Jar File under Oracle Universal Installer = jlib/OraInstaller.jar Please shut down Oracle instances running out of this ORACLE_HOME (Oracle Home = /home/oracle/product/9.2.0) Is this system ready for updating? Please respond Y|N > Y Patching... Updating inventory... /home/oracle/OPatch/opatch.pl version: 1.0.0.0.48 Copyright (c) 2001,2002,2003 Oracle Corporation. All Rights Reserved. OPatch succeeded. $ cd $ORACLE_HOME/network/lib $ make -f ins_oemagent.mk install (略) $ /home/oracle/product/9.2.0/JRE/bin/jre -classpath /home/ora cle/product/9.2.0/JRE/lib/rt.jar:/home/oracle/product/9.2.0/jlib/srvm.jar:/home/ oracle/product/9.2.0/network/agent/agentca.jar oracle.agent.AgentCA /orahome /h ome/oracle/product/9.2.0 /nodeinfo NO_VALUE Parameter "orahome" = /home/oracle/product/9.2.0 Parameter "nodeinfo" = NO_VALUE Agent Service started successfully $
gccのバージョンを戻す
# cd /usr/bin # mv gcc gcc296 # mv gcc343 gcc
データベースを開始(dbstart)しようとすると、
Can’t find init file for Database "ora92". Database "ora92" NOT started.
ダミーのinitファイル(/home/oracle/product/9.2.0/dbs/initora92.ora)を作る
$ touch /home/oracle/product/9.2.0/dbs/initora92.ora
rcで自動起動できるようにする
以下のスクリプトを/etc/rc.d/init.d/dboraとして保存
#!/bin/sh # # chkconfig: 345 99 10 # description: Oracle 9i Database Server R2 # processname: ora_ # # dbora This shell script takes care of starting and stopping # Oracle 9i Database Server R2. ORA_HOME=/home/oracle/product/9.2.0 ORA_OWNER=oracle export ORACLE_HOME=$ORA_HOME if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ] then echo "Oracle startup: cannot start" exit fi case "$1" in start) # Start the Oracle databases: su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" # Start Oracle Net su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" touch /var/lock/subsys/dbora ;; stop) # Stop Oracle Net su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" # Stop the Oracle databases: su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" rm -f /var/lock/subsys/dbora ;; restart) $0 stop $0 start ;; status) if [ -f /var/lock/subsys/dbora ]; then echo $0 started. else echo $0 stopped. fi ;; *) echo "usage: dbora {start|stop|restart|status}" exit 1 esac exit 0
実行属性を与え、自動起動の設定を行う
# chmod 755 /etc/rc.d/init.d/dbora # chkconfig --add dbora # chkconfig dbora on # chkconfig --list dbora dbora 0:off 1:off 2:on 3:on 4:on 5:on 6:off
以下、メモ
データベースを構築せずインストールした場合で、後からデータベースを作成する
$ dbca
リスナーの起動・停止
lsnrctl [start|stop]
データベースの起動・停止
- dbstart (起動用スクリプト)
- dbshut (停止用スクリプト)
これらは、/etc/oratab に設定してあるインスタンスのみに作用する。
/etc/oratab には、ORACLE_SID、ORACLE_HOME、対象とするかの Y/N を記述する。
WWWサーバー(Apache)の起動・停止
$ORACLE_HOME/Apache/Apache/bin/apachectl [start|stop]
http://{サーバー名}:7777/isqlplus 等が可能になる
rcに入れても良いと思う
データベースの削除
- データベースを停止する
- コントロールファイル・データファイル・REDOログファイルを消す
$ rm $ORACLE_BASE/oradata/{$SID}/*.ctl $ rm $ORACLE_BASE/oradata/{$SID}/*.log $ rm $ORACLE_BASE/oradata/{$SID}/*.dbf
oracleの削除
「Oracle9i Database Release 2 (9.2.0) for Linux スタートガイド」による 正しい削除方法はこんな感じみたいです(※rootユーザにて実行)
http://otn.oracle.co.jp/tech/linux/oracle9i/index.html
$ORACLE_BASE ディレクトリを削除
$ rm -rf $ORACLE_BASE
/usr/bin にインストールした Oracle 関連ファイルを削除
$ rm /usr/bin/dbhome $ rm /usr/bin/oraenv $ rm /usr/bin/coraenv
/etc/oratab を削除
$ rm /etc/oratab
/etc/oraInst.loc を削除
$ rm /etc/oraInst.loc
oracle ユーザーを削除
$ userdel -r oracle
oinstall, dba グループを削除
$ groupdel oinstall $ groupdel dba
起動時サービスリストから dbora を削除
$ chkconfig --del dbora