S-JIS[2012-03-17/2012-06-18] 変更履歴

CentOSにOracleをインストール

CentOSにOracleをインストールするメモ。


Oracle11g

Oracle11gをインストールする。

ダウンロード

  1. Oracleのデータベースのところから アーカイブをダウンロードする。
    1. 上部のメニューっぽいところから「ダウンロード」→「Oracle 11g」をクリックするか、本文内の「Oracle Database 11g Release 2」をクリックして、Oracle Database ソフトウェア・ダウンロードページを開く。
    2. 「ライセンスに同意する」を選ぶ。
    3. 環境に合った選択肢(Linux x86-64とか)のFile1をクリックする。(後でFile2も同様にダウンロードする)
    4. オラクルのアカウントでサインインする。
  2. CentOS上でOracleをインストールする為のユーザーとグループを作成する。
    # groupadd oinstall
    # groupadd dba
    # useradd -g oinstall -G dba oracle
    # passwd oracle
  3. ダウンロードしてきたファイルをoracleユーザーで解凍する。
    $ unzip linux.x64_11gR2_database_1of2.zip
    $ unzip linux.x64_11gR2_database_2of2.zip
    $ cd database

インストール

Oracle11gを対話モードでインストールする方法。

  1. インストーラーを起動する。(Oracle Universal Installer(OUI)のウィンドウが開く)
    $ ./runInstaller
  2. 各ウィンドウの設定値を記入・選択する。
  3. 「終了」ボタンを押すとインストールが実行される。

インストーラーによる指定の例と、たぶんその設定値に該当するレスポンスファイルの設定。

インストーラーによる指定 レスポンスファイル
ステップ 設定 設定値 設定 設定値
1/9 セキュリティ・アップデートの構成 電子メール 空欄 oracle.install.db.config.starterdb.dbcontrol.emailAddress  
セキュリティ・アップデートをMy Oracle Support経由で受け取ります チェックを外す oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification false
2/9 インストール・オプションの選択 インストール・オプション 「データベースの作成および構成」を選択 oracle.install.option INSTALL_DB_AND_CONFIG
3/8 システム・クラス   「デスクトップ・クラス」を選択    
4/8 標準インストール構成 Oracleベース /home/oracle/app/oracle ORACLE_BASE 同左
ソフトウェアの場所 /home/oracle/app/oracle/product/11.2.0/dbhome_1 ORACLE_HOME 同左
データベース・ファイルの位置 /home/oracle/app/oracle/oradata    
データベースのエディション 「Enterprise Edition」を選択 oracle.install.db.InstallEdition EE
キャラクタ・セット 「Unicode(AL32UTF8)」を選択 oracle.install.db.config.starterdb.characterSet AL32UTF8
OSDBAグループ 「dba」を選択 oracle.install.db.DBA_GROUP dba
oracle.install.db.OPER_GROUP dba
グローバル・データベース名 orcl.localdomain oracle.install.db.config.starterdb.globalDBName orcl.localdomain
oracle.install.db.config.starterdb.SID orcl
管理パスワード manager11    
5/9 インベントリの作成 インベントリ・ディレクトリ /home/oracle/app/oraInventory INVENTORY_LOCATION 同左
oraInventoryグループ名 「osintall」を選択 UNIX_GROUP_NAME oinstall
6/9 前提条件チェックの実行   「すべて無視」にチェックを入れる
※ただし、gcc等のパッケージは該当バージョン以上のものが入っていないとインストールに失敗する。
   
7/9 サマリー   ※「レスポンス・ファイルの保存」ボタンを押すと、レスポンスファイルが保存できる。    

途中で前提条件(マシンスペックや必要なライブラリー類のバージョン)のチェックが行われる。

スペックについては、(Oracleを試用する目的なら)多少は無視しても大丈夫だが、ライブラリーが無いとインストールが失敗する。
自分が試した環境では、別途以下の様なパッケージをインストールする必要があった。

yum install -y gcc
yum install -y compat-libstdc++-33
yum install -y elfutils-libelf-devel
yum install -y gcc-c++
yum install -y libaio-devel
yum install -y sysstat
yum install -y unixODBC
yum install -y unixODBC-devel
yum install -y pdksh

サイレントモードでのインストール

Oracleのインストールでは、対話型のインストール方法の他に、設定ファイルを用意しておいて自動的にインストールする方法がある。

  1. アーカイブをダウンロード・解凍するところまでは対話型と同じ。
  2. インストーラーの起動を行うコマンドに「-silent」と設定ファイル(レスポンスファイルと呼ばれる)を指定する。
    (レスポンスファイルはフルパスで指定する必要がある)
    $ ./runInstaller -silent -responseFile /home/oracle/db.rsp
  3. コマンドを実行するとすぐに終了するように見えるが、バックグラウンドで処理が進む。
    何かあるとコンソールにメッセージが表示されるので、しばらく放っておこう。
  4. インストールが順調に進むと、最後に「rootユーザーで実行すべきシェル」が表示されるので、その通りに実行する。

レスポンスファイルの雛形は、解凍したディレクトリーの中(database/response/db_install.rsp)にある。

文法は単純に「設定名=設定値」なのだが、設定するものが多いので、何を設定すればいいかよく分からない。
ドキュメントもそこに関して詳しいことが載っていない(苦笑)

ただ、対話モードで実行すると、最後にレスポンスファイルを出力することが出来るので、それを使うのが良さそう。
(つまり、もしGUIの使えないサーバーにOracleをインストールするのなら、別のマシンでレスポンスファイルだけ作り、それを使う)

レスポンスファイルの例:

#-------------------------------------------------------------------------------
# Do not change the following system generated value. 
#-------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0

#-------------------------------------------------------------------------------
# The installation option can be one of the following
# 1. INSTALL_DB_SWONLY
# 2. INSTALL_DB_AND_CONFIG
# 3. UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_AND_CONFIG

#-------------------------------------------------------------------------------
# This variable holds the hostname of the system as set by the user. 
# It can be used to force the installation to use an alternative   
# hostname rather than using the first hostname found on the system
# (e.g., for systems with multiple hostnames and network interfaces).
#-------------------------------------------------------------------------------
ORACLE_HOSTNAME=localhost

#-------------------------------------------------------------------------------
# Unix group to be set for the inventory directory.  
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=oinstall

#-------------------------------------------------------------------------------
# Inventory location.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/home/oracle/app/oraInventory

#-------------------------------------------------------------------------------
# Specify the languages in which the components will be installed.             
#
# en   : English                  ja   : Japanese                  
# fr   : French                   ko   : Korean                    
# ar   : Arabic                   es   : Latin American Spanish    
# bn   : Bengali                  lv   : Latvian                   
# pt_BR: Brazilian Portuguese     lt   : Lithuanian                
# bg   : Bulgarian                ms   : Malay                     
# fr_CA: Canadian French          es_MX: Mexican Spanish           
# ca   : Catalan                  no   : Norwegian                 
# hr   : Croatian                 pl   : Polish                    
# cs   : Czech                    pt   : Portuguese                
# da   : Danish                   ro   : Romanian                  
# nl   : Dutch                    ru   : Russian                   
# ar_EG: Egyptian                 zh_CN: Simplified Chinese        
# en_GB: English (Great Britain)  sk   : Slovak                    
# et   : Estonian                 sl   : Slovenian                 
# fi   : Finnish                  es_ES: Spanish                   
# de   : German                   sv   : Swedish                   
# el   : Greek                    th   : Thai                      
# iw   : Hebrew                   zh_TW: Traditional Chinese       
# hu   : Hungarian                tr   : Turkish                   
# is   : Icelandic                uk   : Ukrainian                 
# in   : Indonesian               vi   : Vietnamese                
# it   : Italian                                                   
#
# Example : SELECTED_LANGUAGES=en,fr,ja
#-------------------------------------------------------------------------------
SELECTED_LANGUAGES=en,ja

#-------------------------------------------------------------------------------
# Complete path of the Oracle Home  
#-------------------------------------------------------------------------------
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1

#-------------------------------------------------------------------------------
# Complete path of the Oracle Base. 
#-------------------------------------------------------------------------------
ORACLE_BASE=/home/oracle/app/oracle

#-------------------------------------------------------------------------------
# Installation Edition of the component.                        
#                                                             
# The value should contain only one of these choices.        
# EE     : Enterprise Edition                                
# SE     : Standard Edition                                  
# SEONE  : Standard Edition One
# PE     : Personal Edition (WINDOWS ONLY)
#-------------------------------------------------------------------------------
oracle.install.db.InstallEdition=EE

#-------------------------------------------------------------------------------
# This property is considered only if InstallEdition is EE.
#
# true  : Components mentioned as part of 'customComponents' property
#         are considered for install.
# false : Value for 'customComponents' is not considered.
#-------------------------------------------------------------------------------
oracle.install.db.isCustomInstall=false

#-------------------------------------------------------------------------------
# This property is considered only if 'IsCustomInstall' is set to true 
#
# Description: List of Enterprise Edition Options you would like to install.
#
#              The following choices are available. You may specify any
#              combination of these choices.  The components you choose should
#              be specified in the form "internal-component-name:version"
#              Below is a list of components you may specify to install.
#        
#              oracle.oraolap:11.2.0.0.2 - Oracle OLAP
#              oracle.rdbms.dm:11.2.0.0.2 - Oracle Data Mining RDBMS Files
#              oracle.rdbms.dv:11.2.0.0.2 - Oracle Database Vault option
#              oracle.rdbms.lbac:11.2.0.0.2 - Oracle Label Security
#              oracle.rdbms.partitioning:11.2.0.0.2 - Oracle Partitioning
#              oracle.rdbms.rat:11.2.0.0.2 - Oracle Real Application Testing
#              oracle.clrintg.ode_net:11.2.0.0.2 - Oracle Database Extensions for .NET 1.x (Windows)
#              oracle.clrintg.ode_net_2:11.2.0.0.2 - Oracle Database Extensions for .NET 2.0 (Windows)
#-------------------------------------------------------------------------------
oracle.install.db.customComponents=

#-------------------------------------------------------------------------------
oracle.install.db.DBA_GROUP=dba

#-------------------------------------------------------------------------------
oracle.install.db.OPER_GROUP=dba

#-------------------------------------------------------------------------------
# This variable represents the cluster node names selected by the .  
# user for installation                                      
#-------------------------------------------------------------------------------
oracle.install.db.CLUSTER_NODES=

#-------------------------------------------------------------------------------
# One of the following
# - GENERAL_PURPOSE                              
# - TRANSACTION_PROCESSING                       
# - DATAWAREHOUSE                                
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE

#-------------------------------------------------------------------------------
# Global Database Name 
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.globalDBName=orcl.localdomain

#-------------------------------------------------------------------------------
# The Starter Database SID 
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.SID=orcl

#-------------------------------------------------------------------------------
# Database character set
#                                               
#  One of the following
#  AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2,
#  EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257,
#  BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6,
#  AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8,
#  IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE,
#  KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950,
#  ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.characterSet=AL32UTF8
#-------------------------------------------------------------------------------
# Specify the total memory allocation for the database. (in MB)
# Value should be at least 256 MB, and should not exceed the  
# total physical memory available on the system.
# Example: oracle.install.db.config.starterdb.memoryLimit=40
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.memoryLimit=804
oracle.install.db.config.starterdb.memoryOption=true

#-------------------------------------------------------------------------------
# This variable controls whether to load Example Schemas onto
# the starter database or not.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.installExampleSchemas=true

#-------------------------------------------------------------------------------
# This include enabling audit settings, configuring password  
# profiles and revoking some grants to public. These settings 
# are provided by default.  You may choose to disable all.    
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.enableSecuritySettings=true

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.ALL=

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYS=

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYSTEM=

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYSMAN=

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.DBSNMP=

#-------------------------------------------------------------------------------
# Can be one of the following 
# 1. GRID_CONTROL
# 2. DB_CONTROL
# 
oracle.install.db.config.starterdb.control=DB_CONTROL

#-------------------------------------------------------------------------------
# Determines the Management Service to use if Grid Control   
# is selected to manage the database.      
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=

#-------------------------------------------------------------------------------
# Determines whether to receive email notification for       
# critical alerts when using DB control.   
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.dbcontrol.emailAddress=

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.enable=false

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.osuid=

#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.ospwd=

#-------------------------------------------------------------------------------
# Can be one of the following
# - FILE_SYSTEM_STORAGE
# - ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE

#-------------------------------------------------------------------------------
# Database file location:                  
# directory for datafiles, control files, redo logs.         
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE 
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/home/oracle/app/oracle/oradata

#-------------------------------------------------------------------------------
# Backup and recovery location 
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE 
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=

#-------------------------------------------------------------------------------
# Name of ASM disk group to be used for storage.
#
# Applicable only when oracle.install.db.config.starterdb.storageType=ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.diskGroup=

#-------------------------------------------------------------------------------
# Password for ASMSNMP user of the ASM instance.                  
#
# Applicable only when oracle.install.db.config.starterdb.storage=ASM_STORAGE 
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.ASMSNMPPassword=

#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username.
#
#  Example   : MYORACLESUPPORT_USERNAME=metalink
#------------------------------------------------------------------------------
MYORACLESUPPORT_USERNAME=

#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username password.
#
# Example    : MYORACLESUPPORT_PASSWORD=password
#------------------------------------------------------------------------------
MYORACLESUPPORT_PASSWORD=

#------------------------------------------------------------------------------
# Specify whether to enable the user to set the password for
# My Oracle Support credentials. The value can be either true or false.
# If left blank it will be assumed to be false.
#
# Example    : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
#------------------------------------------------------------------------------
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false

#------------------------------------------------------------------------------
# Specify whether user wants to give any proxy details for connection. 
# The value can be either true or false. If left blank it will be assumed
# to be false.
#
# Example    : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true

#------------------------------------------------------------------------------
# Specify the Proxy server name. Length should be greater than zero.
#
# Example    : PROXY_HOST=proxy.domain.com 
#------------------------------------------------------------------------------
PROXY_HOST=

#------------------------------------------------------------------------------
# Specify the proxy port number. Should be Numeric and atleast 2 chars.
#
# Example    : PROXY_PORT=25 
#------------------------------------------------------------------------------
PROXY_PORT=

OUIでは管理者のパスワードを登録することが出来て、レスポンスファイル上もSYSやSYSTEMのパスワードの設定はあるのだが、生成されたレスポンスファイルには何も書かれていなかった。
しかしここにパスワードを書けば、その内容で設定される。

あと、SIDは大文字と小文字の区別があるようなので、SIDの設定と(インストール後の)実行時の環境変数ORACLE_SIDとの差異に注意。


環境変数の設定

環境変数は自分で設定する必要がある。[2012-06-18]

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin

JDBCドライバー

JDBCドライバー(ojdbc〜.jar)は、Oracleをインストールしたら一緒に入る。[2012-06-18]

$ ls $ORACLE_HOME/jdbc/lib
ojdbc5.jar    ojdbc5dms.jar    ojdbc6.jar    ojdbc6dms.jar    simplefan.jar
ojdbc5_g.jar  ojdbc5dms_g.jar  ojdbc6_g.jar  ojdbc6dms_g.jar

トレースログの出力

実行されたSQLをログに出力するには、設定を変更する必要がある。[2012-06-18]

$ sqlplus sys as sysdba

SQL> alter system set SQL_TRACE=true;

すると、$ORACLE_BASE/diag/rdbms/orcl/orcl/traceの下のトレースファイルに実行したSQLが出力される。
トレースファイルはプロセスごとに別々になる。(orcl_ora_プロセスID.trc)

参考:みっちーさんのアラート・ファイル、トレース・ファイル


Oracle目次へ戻る / 技術メモへ戻る
メールの送信先:ひしだま