Linuxサーバ>oracle DBサーバ
<パターン1 VMware環境 ゲストOS(CentOS)> oracle 11g インストール
※前提として、Xwindow(GUI)環境が必要のため、初期インストールでX Windowをインストールしなかった場合、
Xwindow 後からインストールが必要。
1. oracleサイトにユーザー登録し、download>Database 11gと選択し、自分の環境のFileをダウンロード
※ちなみに、我が家のVMwareでゲストOS(CentOS)環境だと、「Linux x86」
2. USBへ保存し、vmware server ゲストOS上でUSBデバイスを認識させる(Web管理画面上のボタンを押して)
3. USBデバイスが/dev/なにになったか確認。(ここでは例で/dev/sdc1と認識したと仮定)
less /var/log/messages
4. 適当にマウントポイントを作成
mkdir /mnt/usb
5. /mnt/usbにマウントする
mount /dev/sdc1 /mnt/usb
6. usb内のzipファイルを/tmp当りへコピーし、unzipコマンドで *.zipファイルを解凍
unzip ~~~~~.zip
自分の環境ではvmware server2.0を使っていますが、vmware toolsをインストールせず、
DISPLAY設定をしても失敗(unable to ~がでる)してしまうのでインストール後に以下を実施
※参考:http://d.hatena.ne.jp/yohei-a/20081214/1229237185
↓ふつうにX起動してインストールしようとしてもOUI起動に失敗するので・・・
xhost で X server access list にホストを追加してやると解決っ!
# export DISPLAY=ホスト名:0.0 # xhost + # su - oracle $ export DISPLAY=solarisdb01:0.0 $ /usr/openwin/bin/xdpyinfo name of display: solarisdb01:0.0 version number: 11.0 vendor string: Sun Microsystems, Inc. vendor release number: 10300000 maximum request size: 16777212 bytes motion buffer size: 256 ...
7.「runInstaller」を実行
./database/runInstaller
パターン2 oracle 11g 導入
概要
oracle 11gに関する技術情報を記載する。
インストール環境
- インストールOS: CentOS5
- OSインストール時に以下のパッケージを選択
インストール時のオプションは以下の通り。
※ディスク容量に要注意(以下、手順でインストールする場合3GB前後の空き容量が必要)。
[今すぐカスタマイズする]を選択して、以下をインストール
| デスクトップ環境 | GNOMEデスクトップ環境 |
| アプリケーション | エディタ、グラフィカルインターネット(firefox) |
| 開発 | 開発ツール |
| サーバー | 無し |
| ベースシステム | X Window System、ベース |
| クラスタリング | 無し |
| 言語 | 日本語 |
※今回の場合は、SELinuxやファイアーウォールは無効に設定。
getenforceコマンドで、SELinux状態確認が可能。
# getenforce Disabled #
インストール~1 必要パッケージをOSへ追加インストール
以下の5パッケージをリポジトリから追加インストール。
1.compat-libstdc++-33
以下、Fedora Core向けのcompat-libstdc++-33に関する説明。 Fedora Coreは、gcc(GNU Cコンパイラ)のバージョンに4系列を使用しています。 しかし、RealplayerやFirefox 2系やAcrobat Readerは、 gccのバージョンに3系列を 使用してコンパイルしています。 そこで、gccの互換性を保つライブラリを扱うパッケージの導入が必要です。 そのパッケージがcompat-libstdc++-33です。
2.elfutils-libelf-devel
3.libaio-devel
4.sysstat
sysstat は、Linux のシステムの状態を収集するためのツールです。 収集してくれる情報は、CPU、メモリ、プロセス、割込み、ネットワークや端末など、 非常に幅広いです。 そして、Ubuntu や Fedora には sysstat パッケージが存在しますので、 aptやyumで インストールすれば、すぐに使用することができます。
情報を収集するには、sar コマンドを使用します。 情報収集の際に必要な引数は、計測する間隔(単位は秒)と回数です。
# sar 間隔 回数
4.unixODBC unixODBCはUNIX/Linux用の完全でフリー/オープンなODBC(オープンデータベース接続性)ソリューションです。 ODBCはプログラムやプログラマがODBCドライバを備えた任意のデータベースと通信を行うためのインタフェースです。
5.unixODBC-devel
以下、コマンドにて一括インストール可。 # yum install compat-libstdc++-33 elfutils-libelf-devel libaio-devel sysstat unixODBC unixODBC-devel
インストール~2 Oracleユーザ、グループ作成
- ユーザグループ作成
# groupadd oinstall # groupadd dba # useradd -g oinstall -G dba oracle # # passwd oracle Changing password for user oracle. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully. #
- 作成結果を確認
# tail -2 /etc/group oinstall:x:501: dba:x:502:oracle # # tail -1 /etc/passwd oracle:x:501:501::/home/oracle:/bin/bash # # su - oracle $ id uid=501(oracle) gid=501(oinstall) 所属グループ=501(oinstall),502(dba) $ exit logout #
インストール~3 カーネルパラメータ追加
- カーネルパラメータファイルを編集前にバックアップ
# cp -p /etc/sysctl.conf /etc/sysctl.conf_20110604 # # ls -l /etc/sysctl.conf* -rw-r--r-- 1 root root 994 2月 1 10:14 /etc/sysctl.conf -rw-r--r-- 1 root root 994 2月 1 10:14 /etc/sysctl.conf_20110604 #
- カーネルパラメータファイルをviエディタで開き、末尾に以下パラメータを追加
# vi /etc/sysctl.conf
# Kernel parameters for Oracle 11g kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 262144
- 以下コマンドにて、カーネルパラメータを有効化
# sysctl -p net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 4294967295 kernel.shmall = 268435456 kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 262144 #
インストール~4 limits.confへのパラメータ追加
- limits.confを編集前にバックアップ
# cp -p /etc/security/limits.conf /etc/security/limits.conf_20110604 # # ls -l /etc/security/limits.conf* -rw-r--r-- 1 root root 1802 11月 2 2010 /etc/security/limits.conf -rw-r--r-- 1 root root 1802 11月 2 2010 /etc/security/limits.conf_20110604 #
- limits.confをviエディタで開き、末尾に以下パラメータを追加
# vi /etc/security/limits.conf
# Parameters for Oracle 11g oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
【limits.confについて】
システム全体で利用可能なプロセス数とファイルディスクリプタ(オープンできるファイルの値) の上限値は、カーネルパラメータで指定するが、ユーザごとの上限はカーネルパラメータでは 変更できない。この場合は/etc/security/limits.confに記述する。 1ユーザが実行できるプロセス数とオープンできるファイルディスクリプタの上限は標準では1024と なっています(「ulimit」コマンドで確認)。
/etc/security/limits.conf記述例 user01 soft nofile 1024 user01 hard nofile 12288 user01 soft noproc 4096 user01 hard noproc 4096
上の例ではnofileがファイルディスクリプタ、noprocが最大プロセス数を指している。 soft/hardの違いは、softが一般ユーザが変更できる上限値で、hardはrootが変更できる 上限値を意味する。ユーザ名を「*」とすればすべてのユーザに適用される。 「@グループ名」で、グループごとの指定も可能。設定したユーザでログインして ulimit -aコマンドを実行すれば反映が確認できる。
インストール~5 loginへのパラメータ追加
- loginを編集前にバックアップ
# cp -p /etc/pam.d/login /etc/pam.d/login_20110604 # # ls -l /etc/pam.d/logi* -rw-r--r-- 1 root root 747 6月 4 20:48 /etc/pam.d/login -rw-r--r-- 1 root root 644 3月 10 22:28 /etc/pam.d/login_20110604 #
- loginをviエディタで開き、末尾に以下パラメータを追加
# vi /etc/pam.d/login #
# parameters for Oracle 11g session required /lib/security/pam_limits.so session required pam_limits.so
【loginファイルの修正】について [#if72ced0]
session required /lib/security/pam_limits.so session required pam_limits.so
上記内容をloginファイルに追記する意味は、以下のとおり。
pam_limits.soは/etc/security/limits.confに書かれた制限を適用します。 ulimitで指定できる内容と同じです。
インストール~6 profileへのパラメータ追加
- profileを編集前にバックアップ
# cp -p /etc/profile /etc/profile_20110604 # # ls -l /etc/profile* -rw-r--r-- 1 root root 1161 6月 4 20:59 /etc/profile -rw-r--r-- 1 root root 1029 9月 22 2009 /etc/profile_20110604
- profileをviエディタで開き、末尾に以下パラメータを追加
# vi /etc/profile if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi
インストール~7 ORACLE_BASEディレクトリ作成
- ディレクトリ作成
# mkdir -p /opt/oracle/app # chown -R oracle:oinstall /opt/oracle # chmod -R 775 /opt/oracle/app #
- ディレクトリ作成確認
# cd /opt/oracle/app/ # pwd /opt/oracle/app # # ls -ld /opt/oracle/ drwxr-xr-x 3 oracle oinstall 4096 6月 4 21:05 /opt/oracle/ # # ls -ld /opt/oracle/app/ drwxrwxr-x 2 oracle oinstall 4096 6月 4 21:05 /opt/oracle/app/ #
インストール~8 データファイルディレクトリとリカバリファイルディレクトリの作成
[#if72ced0]
- ディレクトリ作成
# mkdir /opt/oracle/oradata # chown oracle:oinstall /opt/oracle/oradata # chmod 775 /opt/oracle/oradata #
- ディレクトリ作成確認
# cd /opt/oracle/oradata # pwd /opt/oracle/oradata # ls -ld /opt/oracle/oradata drwxrwxr-x 2 oracle oinstall 4096 6月 4 21:14 /opt/oracle/oradata #
インストール~9 oracleユーザのプロファイル編集
[#if72ced0]
- .bash_profileを編集前にバックアップ
# su - oracle $ cp -p /home/oracle/.bash_profile /home/oracle/.bash_profile_20110604 $ $ ls -l /home/oracle/.bash_profile* -rw-r--r-- 1 oracle oinstall 176 6月 4 19:25 /home/oracle/.bash_profile -rw-r--r-- 1 oracle oinstall 176 6月 4 19:25 /home/oracle/.bash_profile_20110604 $
- .bash_profileを編集
$ vi /home/oracle/.bash_profile umask 022 export ORACLE_BASE=/opt/oracle/app
インストール~10 oracleアプリケーションインストール
$ database/runInstaller
上記コマンドにて、oracleインストールをする場合、unzipにより解凍したフォルダ名を
「oracle」にリネームする必要がある。
そうしない場合、インストール時に上記コマンド実行時にエラーとなる。
<エラー発生時>
$ database/runInstaller database/runInstaller: line 84: [: too many arguments database/runInstaller: line 88: /home/oracle/oracle: そのようなファイルやディレクトリはあ りません
インストール~11 rootユーザからのスクリプト実行
Oracleインストール中、構成スクリプトの実行画面にて、rootユーザからのスクリプト実行を求められる。
その際、実行結果として、以下のような結果が出力される。
# /opt/oracle/oraInventory/orainstRoot.sh 権限の変更:/opt/oracle/oraInventory : 770. グループ名の変更:/opt/oracle/oraInventory : oinstall. スクリプトの実行が完了しました #
# /opt/oracle/app/product/11.1.0/db_1/root.sh Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/oracle/app/product/11.1.0/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]: (Enterキー押下) Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ...
Creating /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. Finished product-specific root actions. #
上記出力後、構成スクリプトの実行画面の「OK」ボタンをクリックする。
※以降も添付手順 ( Oracle Database 11g for Linux インストール.pdf ) に従って、インストールを実施する。
インストール~12 Oracleインストール及びデータベース作成後に要求される環境変数定義
- Oracle SID定義
Oracleのインストールが完了し、DBCAを使ってデータベースを作成した直後、 EMに対して操作を実施しようとしたところ、以下のようにSIDの環境変数定義を促す警告が表示される。 $ emctl status dbconsole Environment variable ORACLE_SID not defined. Please define it. $
上記のような場合、.bash_profileに環境変数を追加することにより、EMが起動できるようになる。 ※上記で追加した環境変数は、OS再起動後も適用される。
$ vi /home/oracle/.bash_profile ~以下を追加~ export ORACLE_SID=orcl [データベースに割り当てられたOracle SIDを入力] $ $ emctl status dbconsole Oracle Enterprise Manager 11g Database Control Release 11.1.0.6.0 Copyright (c) 1996, 2007 Oracle Corporation. All rights reserved. https://centos-26:1158/em/console/aboutApplication Oracle Enterprise Manager 11g is not running. ------------------------------------------------------------------ Logs are generated in directory /opt/oracle/app/product/11.1.0/db_1/centos-26_orcl/sysman/log $
- キャラセット定義
Oracleインストール直後、操作を実行した場合、以下のような文字化けが出力される。 その場合、.bash_profileへ利用しているキャラセットを環境変数として追加する。
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning and Real Application Testing options ????????? SQL>
以下のコマンドでOracleが利用しているキャラセットを確認。
SQL> select * from nls_database_parameters where parameter ='NLS_CHARACTERSET';
PARAMETER ------------------------------ VALUE -------------------------------------------------------------------------------- NLS_CHARACTERSET AL32UTF8
SQL>
キャラセットごとに、環境変数を追加する。 $ vi /home/oracle/.bash_profile export NLS_LANG=Japanese_Japan.AL32UTF8