天天看點

RedHat 6 靜默安裝Oracle 11gR2

之前看了網上很多篇Linux靜默安裝Oracle的文章,但安裝測試時老覺得有問題,後來直接找來Oracle官方英文文檔并仔細閱讀研究rsp檔案的内容說明,經過自己在虛拟機中的安裝測試,使用RedHat 6.5(核心版本:2.6.32-431.el6.x86_64)上靜默安裝Oracle 11gR2(版本:11.2.0.3),整理出了本文,主要包括了環境要求與準備、靜默安裝Oracle軟體與監聽、靜默安裝Oracle資料庫、安裝完成後檢查、設定Oracle開機自動啟動等部分。

一、 環境要求與準備

1、硬體要求

(1)記憶體

Minimum: 1 GB of RAM

Recommended: 2 GB of RAM or more

To determine the RAM size, enter the following command:

# grep MemTotal /proc/meminfo

(2)SWAP

Available RAM Swap Space Required

Between 1 GB and 2 GB 1.5   ——times the size of the RAM

Between 2 GB and 16 GB ——Equal to the size of the RAM

More than 16 GB ——16 GB

# grep SwapTotal /proc/meminfo

(3)ASM

Automatic Memory Management feature  requires more shared memory ( /dev/shm) and file descriptors

#df -h /dev/shm/

Note: MEMORY_MAX_TARGET and  MEMORY_TARGET cannot be used when LOCK_SGA is enabled or with HugePages on Linux.

(4)磁盤空間

At least 1 GB of disk space in the  /tmp directory

Enterprise Edition ——At least 4.7 GB for Software Files and 1.7 GB  for Data Files

Standard Edition ——At least 4.6 GB for Software Files and 1.5 GB  for Data Files

2、軟體要求

(1)作業系統要求

■ Asianux Server 3 SP2

■ Asianux Server 4 SP3

■ Oracle Linux 4 Update 7

■ Oracle Linux 5 Update 2 (with Red Hat Compatible Kernel)

■ Oracle Linux 5 Update 5

■ Oracle Linux 6

■ Oracle Linux 6 (with Red Hat Compatible Kernel)

■ Oracle Linux 7

■ Oracle Linux 7 (with the Red Hat Compatible Kernel)

■ Red Hat Enterprise Linux 4 Update 7

■ Red Hat Enterprise Linux 5 Update 2

■ Red Hat Enterprise Linux 6

■ Red Hat Enterprise Linux 7

■ SUSE Linux Enterprise Server 10 SP2

■ SUSE Linux Enterprise Server 11

(2)核心要求

■On Red Hat Enterprise Linux 5 Update 5

2.6.18 or later

■On Red Hat Enterprise Linux 6

2.6.32-71.el6.x86_64 or later

■ On Red Hat Enterprise Linux 7

3.10.0-54.0.1.el7.x86_64 or later

(3)依賴包要求

Note: Starting with Oracle Database 11g Release 2 (11.2.0.2), all the 32-bit packages, except for  gcc-32bit-4.3 , listed in the following table are no longer required for installing a database on Linux x86-64. Only the 64-bit packages are required. However, for any Oracle Database 11g release before 11.2.0.2, both the 32-bit and 64-bit packages listed in the following table are required.

 The following or later version of packages for Oracle Linux 6, Red Hat Enterprise Linux 6, and Asianux Server 4 must be installed:

binutils-2.20.51.0.2-5.11.el6 (x86_64)

compat-libcap1-1.10-1 (x86_64)

compat-libstdc++-33-3.2.3-69.el6 (x86_64)

compat-libstdc++-33-3.2.3-69.el6.i686

gcc-4.4.4-13.el6 (x86_64)

gcc-c++-4.4.4-13.el6 (x86_64)

glibc-2.12-1.7.el6 (i686)

glibc-2.12-1.7.el6 (x86_64)

glibc-devel-2.12-1.7.el6 (x86_64)

glibc-devel-2.12-1.7.el6.i686

ksh

libgcc-4.4.4-13.el6 (i686)

libgcc-4.4.4-13.el6 (x86_64)

libstdc++-4.4.4-13.el6 (x86_64)

libstdc++-4.4.4-13.el6.i686

libstdc++-devel-4.4.4-13.el6 (x86_64)

libstdc++-devel-4.4.4-13.el6.i686

libaio-0.3.107-10.el6 (x86_64)

libaio-0.3.107-10.el6.i686

libaio-devel-0.3.107-10.el6 (x86_64)

libaio-devel-0.3.107-10.el6.i686

make-3.81-19.el6

sysstat-9.0.4-11.el6 (x86_64)

(4)ODBC要求

On Oracle Linux 6, Red Hat Enterprise Linux 6:

unixODBC-2.2.14-11.el6 (x86_64) or later

unixODBC-2.2.14-11.el6.i686 or later

unixODBC-devel-2.2.14-11.el6 (x86_64) or later

unixODBC-devel-2.2.14-11.el6.i686 or later

3、使用者群組要求

The following local operating system groups and users are required if you are installing Oracle Database:

■ The Oracle Inventory group (typically,  oinstall )

■ The OSDBA group (typically,  dba )

■ The Oracle software owner (typically,  oracle )

■ The OSOPER group (optional. Typically,  oper )

# grep dba /etc/group

# id oracle

#groupadd dba

#groupadd oinstall

If the oracle user exists:

# /usr/sbin/usermod -g oinstall -G dba oracle

If the oracle user does not exist:

# /usr/sbin/useradd -g oinstall -G dba oracle

set the password: 

# passwd oracle

4、核心參數要求

<a href="http://s1.51cto.com/wyfs02/M00/85/45/wKioL1ee6iSgMBtvAAGKwYdMbok535.png" target="_blank"></a>

Note: If the current value of any parameter is higher than the value listed in this table, then do not change the value of that parameter.本文原始出處:江健龍的技術部落格http://jiangjianlong.blog.51cto.com/3735273/1832986

修改方法:

create or edit the  /etc/sysctl.conf file, and add or edit lines similar to the following:

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

Note: if any of the current values are larger than the

minimum value, then specify the larger value。

使生效:

# /sbin/sysctl -p或reboot

如果運作 #sysctl  -p 指令報錯

error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key

error: "net.bridge.bridge-nf-call-iptables" is an unknown key

error: "net.bridge.bridge-nf-call-arptables" is an unknown key

則解決方法為執行如下指令:

#modprobe  bridge

檢視:

# /sbin/sysctl -a

5、資源限制要求

修改好後必須使用Oracle使用者登出再登入才生效

$ ulimit -Sn

4096

$ ulimit -Hn

65536

$ ulimit -Su

2047

$ ulimit -Hu

16384

$ ulimit -Ss

10240

$ ulimit -Hs

32768

vi /etc/security/limits.conf

末尾加入以下内容:

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 4096

oracle hard nofile 65536

oracle hard stack 32768

6、建立安裝目錄

Oracle_Base目錄:/u01/app/oracle/

Oracle_Home目錄:/u01/app/oracle/11gr2

Oracle清單目錄:/u01/app/oracle/oraInventory

<a href="http://s1.51cto.com/wyfs02/M00/85/45/wKiom1ee6iTQ8phhAAAfn20lPpQ290.png" target="_blank"></a>

7、配置Oracle使用者環境變量

vi /home/oracle/.bash_profile

export EDITOR=vi

export ORACLE_SID=orcl

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/11gr2

export nls_date_format="yyyy-mm-dd hh24:mi:ss"

export PATH=/u01/app/oracle/11gr2/bin:$PATH

執行指令ource .bash_profile 使配置生效  

8、編輯/etc/profile

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

本文原始出處:江健龍的技術部落格http://jiangjianlong.blog.51cto.com/3735273/1832986

二、 靜默安裝Oracle 軟體和監聽

1、靜默安裝指令

$ /directory_path/runInstaller [-silent] [-noconfig] -responseFile responsefilename

■-noconfig suppresses running the configuration assistants during installation,

and a software-only installation is performed instead.

■ responsefilename is the full path and file name of the installation response

file that you configured.

2、編輯應答檔案db_install.rsp

更改以下内容,其他不需要改,标橙色的需注意要結合實際環境更改。Oracle版本:11.2.0.3

oracle.install.option=INSTALL_DB_SWONLY

ORACLE_HOSTNAME=rh6

UNIX_GROUP_NAME=oinstall

SELECTED_LANGUAGES=en,zh_CN

ORACLE_HOME=/u01/app/oracle/11gr2

ORACLE_BASE=/u01/app/oracle/

INVENTORY_LOCATION=/u01/app/oraInventory

oracle.install.db.InstallEdition=EE

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=oinstall

DECLINE_SECURITY_UPDATES=true

oracle.install.db.EEOptionsSelection=false

./runInstaller -silent -noconfig -ignorePrereq -responseFile /oracle11gr2zip/db_install.rsp

<a href="http://s1.51cto.com/wyfs02/M00/85/45/wKioL1ee6iSzVoTPAAB1LWVin2A037.png" target="_blank"></a>

4、使用root登入執行腳本

<a href="http://s2.51cto.com/wyfs02/M01/85/45/wKioL1ee6iyDJDi8AAAym2J33gA775.png" target="_blank"></a>

5、執行靜默安裝監聽指令

不需要修改應答檔案内容,直接使用媒體中的netca.rsp檔案

[oracle@rh6 database]$ netca /silent /responseFile /oracle11gr2zip/database/resp

onse/netca.rsp

<a href="http://s1.51cto.com/wyfs02/M01/85/45/wKioL1ee6i3ijNIlAAA9ETJTSyw880.png" target="_blank"></a>

三、 靜默安裝Oracle資料庫

1、編輯dbca.rsp

更改以下内容,其他不需要改,标橙色的内容需結合自己實際環境修改

RESPONSEFILE_VERSION = "11.2.0"

OPERATION_TYPE = "createDatabase"

GDBNAME = "orcl"

SID = "orcl"

TEMPLATENAME = "General_Purpose.dbc"

SYSPASSWORD = "p@ssw0rd"

SYSTEMPASSWORD = "p@ssw0rd"

EMCONFIGURATION = "LOCAL"

SYSMANPASSWORD = "p@ssw0rd"

DBSNMPPASSWORD = "p@ssw0rd"

STORAGETYPE=FS

CHARACTERSET = "ZHS16GBK"

NATIONALCHARACTERSET= "AL16UTF16"

MEMORYPERCENTAGE = "40"

TOTALMEMORY = "1024"

 2、執行靜默安裝資料庫指令

 $dbca -silent -responseFile /oracle11gr2zip/dbca.rsp

<a href="http://s1.51cto.com/wyfs02/M02/85/45/wKiom1ee6i2g3dFAAABpPLYhOjs747.png" target="_blank"></a>

四、安裝完成後檢查

1、檢查監聽狀态

$ lsnrctl status

<a href="http://s4.51cto.com/wyfs02/M02/85/45/wKioL1ee6i7Arq1DAABsGeiMVqk618.png" target="_blank"></a>

$ ps -ef |grep ora_ |grep -v grep

<a href="http://s4.51cto.com/wyfs02/M02/85/45/wKiom1ee6i6ABU8WAABaU6fTZI4976.png" target="_blank"></a>

<a href="http://s5.51cto.com/wyfs02/M02/85/45/wKioL1ee6i_gaQ3JAACBx4GtKsk359.png" target="_blank"></a>

<a href="http://s5.51cto.com/wyfs02/M00/85/45/wKiom1ee6i_DJnWWAAAWf0UFwDw600.png" target="_blank"></a>

<a href="http://s5.51cto.com/wyfs02/M00/85/45/wKiom1ee6jDR00quAAA1YkzddB0486.png" target="_blank"></a>

<a href="http://s5.51cto.com/wyfs02/M00/85/45/wKioL1ee6jDQc55pAAAVP7AB--c101.png" target="_blank"></a>

<a href="http://s5.51cto.com/wyfs02/M01/85/45/wKiom1ee6jHDcguqAAAhe-VYwZg945.png" target="_blank"></a>

<a href="http://s4.51cto.com/wyfs02/M01/85/45/wKioL1ee6jHzT4X_AACBW46EpUE363.png" target="_blank"></a>

<a href="http://s4.51cto.com/wyfs02/M02/85/45/wKiom1ee6jKxznmLAAFAdJHFNO8621.png" target="_blank"></a>

五、配置Oracle開機自動啟動

1、以Oracle登入,編輯oratab

vi /etc/oratab,将N改為Y

本文原始出處:江健龍的技術部落格 http://jiangjianlong.blog.51cto.com/3735273/1832986

<a href="http://s2.51cto.com/wyfs02/M02/85/45/wKioL1ee6jLRqIgUAABDfu_MBiQ028.png" target="_blank"></a>

2、 root登入,建立腳本

vi /etc/init.d/oracle,建立oracle檔案,内容如下:

#!/bin/sh

# chkconfig: 35 80 10

# description: Oracle auto start-stop script. 

#

# Set ORACLE_HOME to be equivalent to the $ORACLE_HOME

# from which you wish to execute dbstart and dbshut;

# Set ORACLE_OWNER to the user id of the owner of the

# Oracle database in ORACLE_HOME.

ORACLE_OWNER=oracle

if [ ! -f $ORACLE_HOME/bin/dbstart ]

then

 echo "Oracle startup: cannot start"

 exit

case "$1" in

'start')

# Start the Oracle databases:

echo "Starting Oracle Databases ... "

echo "-------------------------------------------------" &gt;&gt; /var/log/oracle

date +" %T %a %D : Starting Oracle Databases as part of system up." &gt;&gt; /var/log/oracle

su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart" &gt;&gt;/var/log/oracle

echo "Done" 

# Start the Listener:

echo "Starting Oracle Listeners ... "

date +" %T %a %D : Starting Oracle Listeners as part of system up." &gt;&gt; /var/log/oracle

su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start" &gt;&gt;/var/log/oracle

echo "Done."

date +" %T %a %D : Finished." &gt;&gt; /var/log/oracle

touch /var/lock/subsys/oracle

;;

'stop')

# Stop the Oracle Listener:

echo "Stoping Oracle Listeners ... "

date +" %T %a %D : Stoping Oracle Listener as part of system down." &gt;&gt; /var/log/oracle

su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop" &gt;&gt;/var/log/oracle

rm -f /var/lock/subsys/oracle 

# Stop the Oracle Database:

echo "Stoping Oracle Databases ... "

date +" %T %a %D : Stoping Oracle Databases as part of system down." &gt;&gt; /var/log/oracle

su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut" &gt;&gt;/var/log/oracle

echo ""

;; 

'restart')

$0 stop

$0 start

esac

3、賦予腳本權限

<a href="http://s2.51cto.com/wyfs02/M00/85/45/wKioL1ee6jLhHqKEAAANImRWWto877.png" target="_blank"></a>

<a href="http://s2.51cto.com/wyfs02/M01/85/45/wKiom1ee6jLzMXGTAAAKOdL-0P0601.png" target="_blank"></a>

5、測試腳本效果

(1)關閉資料庫

<a href="http://s2.51cto.com/wyfs02/M01/85/45/wKioL1ee6jKiHRc_AAAJ8DQjFzo223.png" target="_blank"></a>

(2)使用root登入,執行指令service oracle start

<a href="http://s2.51cto.com/wyfs02/M00/85/45/wKiom1ee6jPSNkndAAAObcJjZ3o380.png" target="_blank"></a>

(3)登入資料庫檢查,資料庫已在運作,監聽也正常

<a href="http://s2.51cto.com/wyfs02/M00/85/45/wKioL1ee6jOivUYfAABs1qyhHEY034.png" target="_blank"></a>

(4)執行service oracle stop

<a href="http://s2.51cto.com/wyfs02/M02/85/45/wKiom1ee6jOCdbKCAAAKKpanu6s904.png" target="_blank"></a>

(5)檢查監聽和資料庫都已關閉

<a href="http://s1.51cto.com/wyfs02/M02/85/45/wKioL1ee6jSwl2l0AAB4m2xo9Jg869.png" target="_blank"></a>

本文轉自jianlong1990 部落格,原文連結:  http://blog.51cto.com/jiangjianlong/1832986  如需轉載請自行聯系原作者