CentOS 6.6系統上命令列靜默安裝安裝Oracle 11G R2(11.2.0.3)

abraham_dba_2013發表於2016-02-14
本文件是Oracle Database 11.2.0.3 for CentOS 6.6 Server(x86_64平臺)的靜默安裝指南。所有操作無需使用圖形介面。靜默安裝能減少安裝出錯的可能性,也能大大加快安裝速度。
# 後跟命令表示以作業系統下root使用者操作;
$ 後跟命令表示以作業系統下oracle使用者操作;
1.0 安裝前檢查
記憶體大小要求
Oracle 11.2 建議記憶體是在2GB或者更多。 執行以下命令:
#  grep MemTotal /proc/meminfo
MemTotal:        8193660 kB

交換分割槽要求
實體記憶體與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
SwapTotal:       8388604 kB

作業系統版本
通過命令檢視系統架構:
# uname -m
x86_64
檢視作業系統版本命令:
#cat /etc/redhat-release
CentOS release 6.6 (Final)

檢查防火牆是否開啟
# service iptables status
關閉防火牆
# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
# chkconfig iptables off
# chkconfig iptables --list
iptables        0:off   1:off   2:off   3:off   4:off   5:off   6:off

selinux設定“SELINUX=disabled ”
# vi /etc/sysconfig/selinux

1.1 上傳軟體
將資料庫安裝介質上傳到伺服器。

1.2 Package安裝檢查
# rpm -q \
binutils \
compat-libstdc++-33 \
compat-libcap1 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
rpm -q pdksh-5.2.14-1.i386.rpm \
unixODBC \
unixODBC-devel | grep "not installed"
如果系統沒有存在相關的RPM包,則通以下命令進行安裝
# yum –y install

本地YUM安裝(此步驟非必須
配置yum本地安裝源:
建立載入目錄
# mkdir -p /mnt/cdrom
載入安裝光碟
# mount /dev/cdrom /mnt/cdrom
建立一個repo檔案
# mkdir backup
# mv *.repo backup/
# vi /etc/yum.repos.d/oracle.repo
新增以下以下內容到oracle.repo。
[LOCAL]
name=local
baseurl=file:///mnt/cdrom
enable=1
gpgcheck=0
按Esc退出並儲存(:wq!)
# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: LOCAL base extras updates
Cleaning up Everything

建立交換分割槽 (此步驟非必須
1.建立交換分割槽的檔案:增加1G大小的交換分割槽,則命令寫法如下,其中的 count 等於想要的塊大小。
# dd if=/dev/zero of=/home/swapfile bs=1M count=16384
16384+0 records in
16384+0 records out
17179869184 bytes (17 GB) copied, 305.584 s, 56.2 MB/s

2.設定交換分割槽檔案:
# mkswap /home/swapfile  #建立swap的檔案系統
mkswap: /home/swapfile: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 16777212 KiB
no label, UUID=8649e904-dd30-4ecf-bbc9-65cc29134579

3.立即啟用交換分割槽檔案:
# swapon /home/swapfile   #啟用swap檔案
4.使系統開機時自啟用,在檔案/etc/fstab中新增一行:
/home/swapfile swap swap defaults 0 0
5.完成

1.3 增加資料庫組和使用者
# id oracle (確認oracle使用者是否存在)
# /usr/sbin/groupadd oinstall (建立產品清單管理組)
# /usr/sbin/groupadd dba (建立資料庫安裝組)
# /usr/sbin/groupadd asmadmin (建立ASM管理組)
# /usr/sbin/groupadd asmdba (建立Grid管理組)
# /usr/sbin/useradd -g oinstall -G dba,asmdba oracle -d /home/oracle (oinstall為主要組,確保/home/oracle原不存在)
# id oracle (記住oracle使用者的uid和gid)
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),504(asmdba)
# passwd oracle

1.4 調整OS核心引數
設定原則:
kernel.shmmax 為 4GB-1byte或一半的實體記憶體, 哪個值更低用哪個;
fs.file-max 為512 * PROCESSES.
修改/etc/sysctl.conf檔案
輸入命令: vi  /etc/sysctl.conf ,按i鍵進入編輯模式,將下列內容加入該檔案
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
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
將以下兩項備註掉
#kernel.shmmax
#kernel.shmall
最後執行sysctl –p使配置生效。
# modprobe bridge
# sysctl -p (設定引數立即生效)

1.5 增加shell限制
修改/etc/security/limits.conf使用者限制資訊
輸入命令:vi /etc/security/limits.conf,按i鍵進入編輯模式,將下列內容加入該檔案。
oracle   soft    nproc    2047
oracle   hard    nproc    16384
oracle   soft    nofile     1024
oracle   hard    nofile    65536
oracle   soft    stack    10240
oracle   hard   stack    10240

修改/etc/pam.d/login檔案
輸入命令:vi  /etc/pam.d/login,按i鍵進入編輯模式,將下列內容加入該檔案。
session   required    /lib/security/pam_limits.so
session   required    pam_limits.so

修改/etc/profile檔案
輸入命令:vi  /etc/profile,按i鍵進入編輯模式,將下列內容加入該檔案.
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
     ulimit -p 16384
     ulimit -n 65536
  else
     ulimit -u 16384 -n 65536
  fi
fi

1.6 建立必需目錄
建立目錄、所屬關係和許可權
目錄的位置,根據自己的情況來定,注意磁碟空間即可。
輸入命令:
# mkdir -p /u01/app

更改目錄屬主為Oracle使用者所有,輸入命令:
# chown -R oracle:oinstall /u01/app/
# chmod -R 775 /u01/app/

如果伺服器有多網路卡, 注意設定ORACLE_HOSTNAME為某網路卡IP對應的主機名, 參照/etc/hosts檔案.
對/etc/hosts進行配置
在/etc/hosts檔案中加入主機IP與主機名。
192.168.0.54 dbbackup

1.7 設定oracle使用者環境變數
配置Oracle使用者的環境變數
首先,切換到新建立的oracle使用者下,
輸入:su - oracle  ,然後在/home/oracle目錄輸入 : vi .bash_profile
按i編輯 .bash_profile,進入編輯模式,增加以下內容:
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.3/dbhome_1; export ORACLE_HOME
ORACLE_SID=ora11g; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH;export PATH
NLS_LANG=AMERICAN_AMERICA.AL32UTF8; export NLS_LANG
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
TEMP=/tmp;export TEMP
TMPDIR=/tmp;export TMPDIR
alias sqld='sqlplus / as sysdba'
umask 022

$ . ~/.bash_profile

1.8 解壓Oracle安裝檔案
準備安裝軟體
將下載的Oracle安裝包上傳到linux中目錄(/home/oracle)。
在目錄/home/oracle下輸入命令:
unzip p10404530_112030_Linux-x86-64_1of7.zip
unzip p10404530_112030_Linux-x86-64_2of7.zip
解壓完成後 cd 進入其解壓後的目錄database

1.9 生成響應檔案模板
生成響應檔案模板,將database/response資料夾下的db_install.rsp檔案複製一份出來,對裡面的引數進行修改。
$ vi /home/oracle/db_install.rsp
#--------------------------------------------------------------------
#以下引數根據實際情況更改,一般也無需更改
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=dbbackup
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
DECLINE_SECURITY_UPDATES=true
#--------------------------------------------------------------------
各引數含義如下:
-silent 表示以靜默方式安裝,不會有任何提示
-force 允許安裝到一個非空目錄
-noconfig 表示不執行配置助手netca
-responseFile 表示使用哪個響應檔案,必需使用絕對路徑
oracle.install.responseFileVersion 響應檔案模板的版本,該引數不要更改
oracle.install.option 安裝選項,本例只安裝oracle軟體,該引數不要更改
DECLINE_SECURITY_UPDATES 是否需要線上安全更新,設定為false,該引數不要更改
ORACLE_HOSTNAME 安裝主機名
UNIX_GROUP_NAME oracle使用者用於安裝軟體的組名
INVENTORY_LOCATION oracle產品清單目錄
SELECTED_LANGUAGES oracle執行語言環境,一般包括引文和簡繁體中文
ORACLE_HOME Oracle安裝目錄
ORACLE_BASE oracle基礎目錄
oracle.install.db.InstallEdition 安裝版本型別,一般是企業版
oracle.install.db.isCustomInstall 是否定製安裝,預設Partitioning,OLAP,RAT都選上了
oracle.install.db.customComponents 定製安裝元件列表:除了以上預設的,可加上Label Security和Database Vault
oracle.install.db.DBA_GROUP oracle使用者用於授予OSDBA許可權的組名
oracle.install.db.OPER_GROUP oracle使用者用於授予OSOPER許可權的組名

1.10 開始安裝oracle軟體
1) 通過response檔案靜默安裝, 大概2-3分鐘:
開始安裝軟體
首先按db.rsp配置好引數資訊。

執行以下指令碼進行靜默資料庫安裝:

$ ./runInstaller -silent -noconfig -ignorePrereq -responseFile /home/oracle/db_install.rsp
控制檯直到出現以下提示則表示安裝完成:
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 261424 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 8191 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-02-14_03-31-16PM. Please wait ...[oracle@dbbackup database]$ You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2016-02-14_03-31-16PM.log
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2016-02-14_03-31-16PM.log' for more details.

As a root user, execute the following script(s):
        1. /u01/app/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/11.2.0.3/dbhome_1/root.sh


Successfully Setup Software.

[oracle@dbbackup database]$ exit
logout
[root@dbbackup Downloads]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@dbbackup Downloads]# /u01/app/oracle/product/11.2.0.3/dbhome_1/root.sh
Check /u01/app/oracle/product/11.2.0.3/dbhome_1/install/root_dbbackup_2016-02-14_15-34-35.log for the output of root script

2) 安裝期間檢視安裝日誌資訊瞭解安裝進度:
$ cd $ORACLE_BASE/oraInventory/logs
$ tail -100f installActions*.log
軟體安裝成功!

1.1 靜默配置監聽
生成響應檔案模板,將database/response資料夾下的netca.rsp檔案複製一份出來,對裡面的引數進行修改。
通過response檔案執行netca, 生成sqlnet.ora和listener.ora檔案, 位於$ORACLE_HOME/network/admin目錄下:
# su - oracle
$ORACLE_HOME/bin/netca /silent /responsefile /home/oracle/netca.rsp
Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /home/oracle/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control:
      /u01/app/oracle/product/11.2.0.3/dbhome_1/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

$ ll $ORACLE_HOME/network/admin/*.ora
$ lsnrctl status
執行完後, 監聽就已經啟動了, 預設埠是1521, 預設是動態監聽, 只要例項啟動了就會監聽到。可以在安裝之後,手工修改埠號為1601。
 
1.2 靜默建庫
1) 生成響應檔案模板:
生成響應檔案模板,將database/response資料夾下的dbca.rsp檔案複製一份出來,對裡面的引數進行修改。
$ vi /home/oracle/dbca.rsp
#--------------------------------------------------------------------
#以下引數不要更改
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
#以下引數必須設定
[CREATEDATABASE]
GDBNAME = "ora11g"
SID = "ora11g"
TEMPLATENAME = "General_Purpose.dbc"

#以下引數不設定則使用預設值,建議設定
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "3200"

--------------------------------------------------------------------
2) dbca靜默建庫, 大概3-4分鐘:
種子資料庫和控制檔案位於$ORACLE_HOME/assistants/dbca/templates/下, 即Seed_Database.dfb和Seed_Database.ctl檔案, 實際上建庫就是基於通過rman恢復種子資料庫和控制檔案來實現的.
定製資料庫DBCA

$ dbca -silent -responseFile /home/oracle/dbca.rsp
Enter SYS user password:
        
Enter SYSTEM user password:
        
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log" for further details.
庫安裝成功
各引數含義如下:
-silent 表示以靜默方式安裝
-responseFile 表示使用哪個響應檔案,必需使用絕對路徑
RESPONSEFILE_VERSION 響應檔案模板的版本,該引數不要更改
OPERATION_TYPE 安裝型別,該引數不要更改
GDBNAME 全域性資料庫名,點號前面預設是db_name,點號後面預設就是db_domain
TEMPLATENAME 建庫模板名,參考各模板定義:$ORACLE_HOME/assistants/dbca/templates/*.dbc
CHARACTERSET 字符集,預設是WE8MSWIN1252
TOTALMEMORY 例項記憶體,預設是伺服器實體記憶體的40%

3) 安裝期間檢視日誌資訊瞭解進度:
$ tail -100f $ORACLE_BASE/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log
$ tail -100f /u01/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
DBCA_PROGRESS : 37%
Creating and starting Oracle instance
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
Completing Database Creation
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/ora11g.
Database Information:
Global Database Name:ora11g
System Identifier(SID):ora11g

4) 建庫後例項檢查
$ ps -ef | grep ora_ | grep -v grep | wc -l
21
$ ps -ef | grep ora_ | grep -v grep

5) 建庫後監聽檢查
$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-FEB-2016 16:03:28

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                14-FEB-2016 15:42:23
Uptime                    0 days 0 hr. 21 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.3/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/dbbackup/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbbackup)(PORT=1521)))
Services Summary...
Service "ora11g" has 1 instance(s).
  Instance "ora11g", status READY, has 1 handler(s) for this service...
Service "ora11gXDB" has 1 instance(s).
  Instance "ora11g", status READY, has 1 handler(s) for this service...
The command completed successfully
例項應該被動態註冊到監聽程式了. 如果未被動態註冊到監聽程式, 則可以手工註冊:
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sun Feb 14 16:04:05 2016

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter system register;   
6) 改為歸檔模式並重啟
$ 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; (手工歸檔測試)
到此建庫完畢!

7) 預設安裝的元件:
SQL> col COMP_ID format a8
col COMP_NAME format a35
col VERSION format a12
col schema format a12
col OTHER_SCHEMAS format a45
SQL> select comp_id,comp_name,version,schema,other_schemas from dba_registry order by 1;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29439655/viewspace-1988530/,如需轉載,請註明出處,否則將追究法律責任。

相關文章