Linux下Oracle 11g靜默安裝

perfychi發表於2013-07-24

LinuxOracle 11g靜默安裝

1 作業系統及Oracle版本

Linux版本:Red Hat Enterprise Linux 5 update 3

Oracle版本:Oracle Database 11g Release 2 (11.2.0.1.0) for Linux x86-64

2 硬體環境檢查

2.1 記憶體要求

實體記憶體要求:

至少4G,檢視實體記憶體命令:

# grep MemTotal /proc/meminfo

 

虛擬記憶體要求:

實體記憶體4-8G,要求虛擬記憶體為2倍實體記憶體;

實體記憶體8-32G,要求虛擬記憶體為1.5倍實體記憶體;

實體記憶體32G,要求虛擬記憶體為32G

 

檢視虛擬記憶體命令:

# grep SwapTotal /proc/meminfo

 

增加虛擬記憶體示例:

# dd if=/dev/zero f=/swapadd bs=1024 count=2006424

# mkswap /swapadd

# swapon /swapadd

2.2 儲存空間要求

/tmp目錄下需至少1G空間

# df -h /tmp

 

如果不足1G需設定oracle使用者的TMPTMPDIR環境變數。

 

對資料庫安裝目錄,需至少4.35G空間,對資料檔案目錄,需至少1.68G空間。

3 軟體環境檢查

2.1 核心版本要求

需滿足:2.6.18 or later

 

檢查命令:

# uname -r

2.2 系統包要求

以下系統包或以上版本(32)必須滿足:

binutils-2.17.50.0.6

compat-libstdc++-33-3.2.3

compat-libstdc++-33-3.2.3 (32 bit)

elfutils-libelf-0.125

elfutils-libelf-devel-0.125

gcc-4.1.2

gcc-c++-4.1.2

glibc-2.5-24

glibc-2.5-24 (32 bit)

glibc-common-2.5

glibc-devel-2.5

glibc-devel-2.5 (32 bit)

glibc-headers-2.5

ksh-20060214

libaio-0.3.106

libaio-0.3.106 (32 bit)

libaio-devel-0.3.106

libaio-devel-0.3.106 (32 bit)

libgcc-4.1.2

libgcc-4.1.2 (32 bit)

libstdc++-4.1.2

libstdc++-4.1.2 (32 bit)

libstdc++-devel 4.1.2

make-3.81

numactl-devel-0.9.8.x86_64

sysstat-7.0.2

unixODBC-2.2.11

unixODBC-2.2.11 (32 bit)

unixODBC-devel-2.2.11

elfutils-libelf-devel-static-0.125

kernel-headers-2.6.18

libgomp-4.1.2

 

檢查命令:

# rpm -q package_name

 

安裝包目錄:

 

安裝命令示例:

# rpm -ivh unixODBC-devel-2.2.11-7.1.i386.rpm

 

SCB UPRR check情況如下:

命令

結果

是否滿足

rpm -q binutils

binutils-2.17.50.0.6-8.el5

滿足

rpm -q compat-libstdc++-33

not installed

 

rpm -q compat-libstdc++-33

not installed

 

rpm -q elfutils-libelf

elfutils-libelf-0.137-3.el5

滿足

rpm -q elfutils-libelf-devel

not installed

 

rpm -q gcc

not installed

 

rpm -q gcc-c++

not installed

 

rpm -q glibc

glibc-2.5-31

滿足

rpm -q glibc

glibc-2.5-31

滿足

rpm -q glibc-common

glibc-common-2.5-31

滿足

rpm -q glibc-devel

not installed

 

rpm -q glibc-devel

not installed

 

rpm -q glibc-headers

not installed

 

rpm -q ksh

ksh-20080202-2.el5

滿足

rpm -q libaio

libaio-0.3.106-3.2

滿足

rpm -q libaio

libaio-0.3.106-3.2

滿足

rpm -q libaio-devel

not installed

 

rpm -q libaio-devel

not installed

 

rpm -q libgcc

libgcc-4.1.2-44.el5

滿足

rpm -q libgcc

libgcc-4.1.2-44.el5

滿足

rpm -q libstdc++

libstdc++-4.1.2-44.el5

滿足

rpm -q libstdc++

libstdc++-4.1.2-44.el5

滿足

rpm -q libstdc++-devel

not installed

 

rpm -q make

make-3.81-3.el5

滿足

rpm -q numactl-devel

not installed

 

rpm -q sysstat

not installed

 

rpm -q unixODBC

not installed

 

rpm -q unixODBC

not installed

 

rpm -q unixODBC-devel

not installed

 

rpm -q elfutils-libelf-devel-static

not installed

 

rpm -q kernel-headers

kernel-headers-2.6.18-120.el5

滿足

rpm -q libgomp

not installed

 

 

經檢查,SCB UPRR生產環境需安裝以下補丁包:

# rpm -ivh compat-libstdc++-33-3.2.3-61.x86_64.rpm

# rpm -ivh compat-libstdc++-33-3.2.3-61.i386.rpm

# rpm -ivh elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm elfutils-libelf-devel-0.137-3.el5.x86_64.rpm

# rpm -ivh glibc-headers-2.5-34.x86_64.rpm  --nodeps --force

# rpm -ivh glibc-devel-2.5-34.x86_64.rpm --nodeps --force

# rpm -ivh glibc-devel-2.5-34.i386.rpm --nodeps --force

# rpm -ivh gcc-4.1.2-44.el5.x86_64.rpm libgomp-4.3.2-7.el5.x86_64.rpm

# rpm -ivh libaio-devel-0.3.106-3.2.x86_64.rpm

# rpm -ivh libaio-devel-0.3.106-3.2.i386.rpm

# rpm -ivh libstdc++-devel-4.1.2-44.el5.x86_64.rpm

# rpm -ivh numactl-devel-0.9.8-7.el5.x86_64.rpm

# rpm -ivh sysstat-7.0.2-3.el5.x86_64.rpm

# rpm -ivh unixODBC-2.2.11-7.1.x86_64.rpm

# rpm -ivh unixODBC-2.2.11-7.1.i386.rpm

# rpm -ivh unixODBC-devel-2.2.11-7.1.x86_64.rpm

# rpm -ivh gcc-c++-4.1.2-48.el5.x86_64.rpm --nodeps --force

4  建立組及使用者

# /usr/sbin/groupadd oinstall

# /usr/sbin/groupadd dba

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

# passwd oracle

5 配置核心引數

5.1 檢查核心引數

下表為需要檢查的核心引數、最小值、檢查命令、及引數檔案路徑:


 

 

引數

最小值

檢查命令

檔案路徑

semmsl

250

# /sbin/sysctl -a | grep sem

/proc/sys/kernel/sem

semmns

32000

semopm

100

semmni

128

shmall

2097152

# /sbin/sysctl -a | grep shm

/proc/sys/kernel/shmall

shmmax

4GB-1byte或實體記憶體的一半,兩者最小值.

Default: 536870912

/proc/sys/kernel/shmmax

shmmni

4096

/proc/sys/kernel/shmmni

file-max

6815744

# /sbin/sysctl -a | grep file-max

/proc/sys/fs/file-max

ip_local_port_range

Minimum: 9000

Maximum: 65500

# /sbin/sysctl -a | grep ip_local_port_range

/proc/sys/net/ipv4/ip_local_port_range

rmem_default

262144

# /sbin/sysctl -a | grep rmem_default

/proc/sys/net/core/rmem_default

rmem_max

4194304

# /sbin/sysctl -a | grep rmem_max

/proc/sys/net/core/rmem_max

wmem_default

262144

# /sbin/sysctl -a | grep wmem_default

/proc/sys/net/core/wmem_default

wmem_max

1048576

# /sbin/sysctl -a | grep wmem_max

/proc/sys/net/core/wmem_max

aio-max-nr

Maximum: 1048576

# cat /proc/sys/fs/aio-max-nr

/proc/sys/fs/aio-max-nr

 

對於需要修改的引數,要在/etc/sysctl.conf(如果沒有該檔案則建立)中修改。如果該檔案中存在引數配置,直接修改,否則增加新行。

 

以下是對SCB UPRR生產環境的分析:

Oracle推薦設定                            /etc/sysctl.conf是否需修改,如何修改

kernel.sem = 250 32000 100 128              ##修改,增加本行

kernel.shmall = 2097152                     ##滿足,無需增加或修改

kernel.shmmax = 536870912                   ##滿足,無需增加或修改

kernel.shmmni = 4096                        ##滿足,無需增加或修改

fs.file-max = 6815744                       ##修改,增加本行

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 = 1048586                 ##修改,增加本行

fs.aio-max-nr = 1048576                     ##修改,增加本行

5.2 修改核心引數

經上述分析,SCB UPRR生產環境在/etc/sysctl.conf中無引數修改,但有引數增加,增加內容如下:

# vi /etc/sysctl.conf

kernel.sem = 250 32000 100 128

fs.file-max = 6815744

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 = 1048586

fs.aio-max-nr = 1048576

 

修改後,使設定生效:

# /sbin/sysctl -p

 

執行生效命令後,再次檢查確認引數設定:

# /sbin/sysctl -a

6 使用者限制設定

6.1使用者檔案限制檢查

切換到安裝使用者oracle

# su - oracle

 

檢查以下引數是否在推薦的範圍內

 

Type

Item

Recommended Ranges

Command

soft

nofile

at least 1024

$ ulimit -Sn

hard

nofile

at least 65536

$ ulimit -Hn

soft

nproc

at least 2047

$ ulimit -Su

hard

nproc

at least 16384

$ ulimit -Hu

soft

stack

at least 10240 KB

$ ulimit -Ss

hard

stack

at least 10240 KB

at most 32768 KB

$ ulimit -Hs

 

6.2修改使用者限制

$ su - root

 

在檔案/etc/security/limits.conf中加入以下內容:

# vi /etc/security/limits.conf

oracle    soft    nofile    1024

oracle    hard    nofile    65536

oracle    soft    nproc     2047

oracle    hard    nproc     16384

 

/etc/pam.d/login中增加以下內容:

vi /etc/pam.d/login

session    required    /lib/security/pam_limits.so

session    required    pam_limits.so

 

/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

fi

7 關閉SELinux

# vi /etc/sysconfig/selinux

#SELINUX=enforcing

SELINUX=disabled

8 建立安裝目錄

# mkdir -p /u01/app/

# chown -R oracle:oinstall /u01/app/

# chmod -R 775 /u01/app/

9 設定環境變數

# su - oracle

 

$ vi ~/.bash_profile

umask 022

export ORACLE_BASE=

export ORACLE_SID=uprr

 

$ source /home/oracle/.bash_profile

 

$ unset ORACLE_HOME

$ unset TNS_ADMIN

 

注意,除了ORACLE_BASEORACLE_SID,( /etc/profile.bash_profile)不設定任何oracle相關環境變數(ORACLE_HOME, PATH, LD_LIBRARY_PATH)

 

檢查環境變數:

$ env | more

 

檢查使用者檔案許可權掩碼:

$ umask

10 靜默安裝軟體

10.1 建立oraInst.loc

$ su - root

# vi /etc/oraInst.loc

inventory_loc=/u01/app/oracle/oraInventory

inst_group=oinstall

 

# chown oracle:oinstall /etc/oraInst.loc

# chmod 664 /etc/oraInst.loc

10.2 建立響應檔案

# su - oracle

 

僅安裝Oracle軟體的響應檔案UPRR_INSTALL_DB_SWONLY.rsp

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0

oracle.install.option=INSTALL_DB_SWONLY

ORACLE_HOSTNAME=build001

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/u01/app/oracle/oraInventory

SELECTED_LANGUAGES=en,zh_CN,zh_TW

ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

ORACLE_BASE=/u01/app/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.isCustomInstall=false

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=dba

DECLINE_SECURITY_UPDATES=true

 

建立資料庫的響應檔案UPRR_DBCA.rsp

[GENERAL]

RESPONSEFILE_VERSION = "11.2.0"

OPERATION_TYPE = "createDatabase"

[CREATEDATABASE]

GDBNAME = "uprr"

SID = "uprr"

TEMPLATENAME = "General_Purpose.dbc"

SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"

DATAFILEDESTINATION = "/u01/app/oracle/oradata"

RECOVERYAREADESTINATION= "/u01/app/oracle/flash_recovery_area"

CHARACTERSET = "ZHS16GBK"

NATIONALCHARACTERSET= "AL16UTF16"

 

NET配置的響應檔案使用Oracle預設即可,無需修改,該檔案在Oracle安裝包的路徑:

$cp database/response/netca.rsp /home/oracle/UPRR_NETCA.rsp

 

$ su - root

# chmod 700 /home/oracle/UPRR_INSTALL_DB_SWONLY.rsp

10.3 安裝Oracle

安裝:

# su - oracle

$ cd database

$ ./runInstaller -silent -debug -force -responseFile /home/oracle/UPRR_INSTALL_DB_SWONLY.rsp

 

備註:(可選引數-noconfig -IgnoreSysPreReqs)

 

出現類似如下提示表示安裝完成:

#-------------------------------------------------------------------

...

/u01/app/oracle/oraInventory/orainstRoot.sh

/u01/app/oracle/product/11.2.0/dbhome_1/root.sh

To execute the configuration scripts:

         1. Open a terminal window

         2. Log in as "root"

         3. Run the scripts

         4. Return to this window and hit "Enter" key to continue 

 

Successfully Setup Software.

#-------------------------------------------------------------------

 

安裝期間檢視安裝日誌資訊瞭解安裝進度

$ cd $ORACLE_BASE/oraInventory/logs

$ tail -100f installActions*.log

 

root執行$ORACLE_HOME下的root.sh來建立oratab,dbhome,oraenv,coraenv檔案, 如果提示則一直回車:

$ su - root

# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

# more /etc/oratab

 

設定環境變數

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

export TNS_ADMIN=$ORACLE_HOME/network/admin

export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin

export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/lib

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib

export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE

export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE/lib

export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib

export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib

export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib

export LIBPATH=${CLASSPATH}:$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib

export ORACLE_OWNER=oracle

export SPFILE_PATH=$ORACLE_HOME/dbs

export ORA_NLS10=$ORACLE_HOME/nls/data

 

source /home/oracle/.bash_profile

 

Sqlplus測試

$ sqlplus /nolog

11 靜默配置網路

$ $ORACLE_HOME/bin/netca /silent /responseFile /home/oracle/UPRR_NETCA.rsp

 

/u01/app/oracle/product/11.2.0/dbhome_6/srvm/admin/getcrshome 沒有可執行許可權?

12 靜默安裝資料庫

# su - oracle

$

 

安裝期間檢視日誌資訊瞭解進度:

$ tail -100f $ORACLE_BASE/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log

 

建庫後例項檢查

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

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

 

建庫後監聽檢查

$ lsnrctl status

 

如果使用歸檔日誌

$ sqlplus / as sysdba

SQL> shutdown immediate;

SQL> startup mount;

SQL> alter database archivelog;

SQL> alter database flashback on; (如果要啟用資料庫閃回功能則執行)

SQL> alter database open;

SQL> execute utl_recomp.recomp_serial(); (重新編譯所有可能失效物件)

SQL> alter system archive log current; (手工歸檔測試)

 

預設安裝的資料庫使用者檢查

SQL> set lines 256 pages 500

SQL> select USER_ID,USERNAME,ACCOUNT_STATUS,DEFAULT_TABLESPACE from dba_users order by 1;

Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE

相關文章