Oracle 11g R2靜默安裝



2015年1月6日

測試安裝Oracle 11g R2靜默安裝安裝,環境是vmware平臺虛擬機。做個記錄。
CentOS 6.5_x64安裝Oracle 11g R2
一,下載地址
 
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
Oracle 11g 聯機文檔:
 
http://www.oracle.com/pls/db112/homepage

二,系統要求
內存:1G(官方最低要求1G)
硬盤:40G(企業版安裝所需4.29G和1.7G數據文件)

檢查的命令
內存
# grep MemTotal /proc/meminfo
交換空間
# grep SwapTotal /proc/meminfo
磁盤空間
# df -ah

三,安裝前系統準備
1、修改主機名
# sed -i "s/HOSTNAME=localhost.localdomain/HOSTNAME=oracledb/" /etc/sysconfig/network
# hostname oracledb

2、添加主機名與IP對應記錄
 #vi /etc/hosts
10.10.0.48    oracledb

3、關閉Selinux
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config 
# setenforce 0

4、創建用戶和組(root用戶:創建Oracle安裝組oinstall,數據庫管理員組dba,及oracle用戶)

# groupadd -g 200 oinstall
# groupadd -g 201 dba
# useradd -u 440 -g oinstall -G dba oracle (主組oinstall,其它組:dba)
# passwd oracle   #(P)

5、修改內核參數(root用戶:修改 /etc/sysctl.conf 文件,加上如下參數)
# vi/etc/sysctl.conf  #末尾添加如下
net.ipv4.ip_local_port_range= 9000 65500
fs.file-max = 6815744
kernel.shmall = 10523004
kernel.shmmax = 6465333657
kernel.shmmni = 4096
kernel.sem = 250 32000 100128
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_max=1048576
fs.aio-max-nr = 1048576
# sysctl -p  #使配置生效

6、修改系統資源限制(root用戶:修改 /etc/security/limits.conf 文件,加上下面的參數)
# vi/etc/security/limits.conf #末尾添加如下
oracle  soft  nproc  2047
oracle  hard  nproc  16384
oracle  soft  nofile  1024
oracle  hard  nofile  65536
7、修改用戶驗證選項(root用戶下:修改/etc/pam.d/login文件加上如下參數)
# vi/etc/pam.d/login
session    required    pam_namespace.so  #下面添加一條pam_limits.so
session    required    pam_limits.so
8、修改用戶配置文件(root用戶下:修改/etc/profile文件加入如下參數)
# vi/etc/profile    #(如果做了第6步的limits.conf設置,這個設置就不需要了)
if [ $USER ="oracle" ]; then
      if [ $SHELL = "/bin/ksh" ];then
          ulimit -p 16384
          ulimit -n 65536
      else
          ulimit -u 16384 -n 65536
      fi
fi

9、創建安裝目錄及設置權限

# mkdir -p /opt/app/oracle/ 
# chmod 755 /opt/app/oracle/ 
# chown oracle.oinstall -R /opt/app/oracle/

10、設置oracle環境變量
使用oracle賬戶
#su - oracle
$ vi ~/.bash_profile
#設置oracle
export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
#export PATH=$PATH:$ORACLE_HOME/bin
export ROACLE_PID=ora11g
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

完成後執行:
$ env | grep ORA #查看環境變量是否完成
oracle@oracledb ~]$ env | grep ORA
ORACLE_BASE=/opt/app/oracle
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1

四、安裝Oracle
1、安裝依賴包
# yum -y install  gcc gcc-c++ make binutilscompat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-commonglibc-devel
libaio libaio-devel libgcclibstdc++ libstdc++-devel unixODBC unixODBC-devel
2, 安裝oracle
 # unzip linux.x64_11gR2_database_1of2.zip
 # unzip linux.x64_11gR2_database_1of2.zip
3, 圖形界面安裝(略,通常的生產環境是不安裝圖形界面的)
# xhost +  #使所有用戶都能訪問圖形桌面
# su –oracle
#.~/database/runInstaller
輸入接受一些安全問題的郵件地址

4,字符界面下安裝oracle
  在/opt目錄下 解壓oracle軟件
 $ unzip linux.x64_11gR2_database_1of2.zip
 $ unzip linux.x64_11gR2_database_2of2.zip

解壓後得到database目錄,其中包含response目錄,該目錄中有三個rsp文件,用來作爲靜默安裝時的應答文件的模板。

 三個文件作用分別是:
db_install.rsp:安裝應答
dbca.rsp:創建數據庫應答
netca.rsp:建立監聽、本地服務名等網絡設置的應答

將db_install.rsp備份一份,在其基礎上修改內容, 將create database段中內容設置好即可。
修改靜默安裝的配置文件
$ less /opt/database/response/db_install.rsp |grep -v "#"|grep -v "^$"
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oracledb
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/opt/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=ora11g
oracle.install.db.config.starterdb.SID=ora11g
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1500
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
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=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
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=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true    //一定要設爲 true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=

開始靜默安裝
$ /opt/database/runInstaller -silent -force -responseFile /opt/database/response/db_install.rsp
[oracle@oracledb database]$ ./runInstaller -silent -force -responseFile /opt/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 165908 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 16383 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-01-29_03-35-32PM. Please wait ...[oracle@oracledb database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
   CAUSE: The Central Inventory is located in the Oracle base.
   ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-13014] Target environment do not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. /tmp/OraInstall2015-01-29_03-35-32PM/installActions2015-01-29_03-35-32PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2015-01-29_03-35-32PM/installActions2015-01-29_03-35-32PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
   CAUSE: The Central Inventory is located in the Oracle base.
   ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-13014] Target environment do not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. /tmp/OraInstall2015-01-29_03-35-32PM/installActions2015-01-29_03-35-32PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2015-01-29_03-35-32PM/installActions2015-01-29_03-35-32PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
You can find the log of this install session at:
 /opt/app/oracle/oraInventory/logs/installActions2015-01-29_03-35-32PM.log
The following configuration scripts need to be executed as the "root" user.
 #!/bin/sh
 #Root scripts to run

/opt/app/oracle/oraInventory/orainstRoot.sh
/opt/app/oracle/product/11.2.0/db_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.
安裝完畢後會提示上述的信息,按照要求執行上述腳本即可
備註:[WARNING] 是需要安裝一些i386 的包。查看log安裝即可

五,配置監聽程序
$ $ORACLE_HOME/bin/netca /silent /responseFile /opt/database/response/netca.rsp
[oracle@oracledb bin]$ $ORACLE_HOME/bin/netca /silent /responseFile /opt/database/response/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /opt/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Listener "LISTENER" already exists.
Oracle Net Services configuration successful. The exit code is 0
啓動監控程序
$  /opt/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
或$ORACLE_BADE//opt/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 30-JAN-2015 13:23:46

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

Starting /opt/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /opt/app/oracle/diag/tnslsnr/oracledb/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                30-JAN-2015 13:23:47
Uptime                    0 days 0 hr. 1 min. 3 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /opt/app/oracle/diag/tnslsnr/oracledb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(PORT=1521)))
The listener supports no services
The command completed successfully

啓動成功


靜默dbca建庫
oracle@oracledb]$ vim /opt/database/response/dbca.rsp
 GDBNAME = "ora11g.dg01"78 行 全局數據庫的名字=SID+主機域名
SID="orcl" //149行 SID
 CHARACTERSET="AL32UTF8" //415行 編碼
NATIONALCHARACTERSET="UTF8" //425行 編碼

[oracle@oracledb response]$ $ORACLE_HOME/bin/dbca -silent -responseFile /opt/database/response/dbca.rsp
Enter SYS user password:
 
Enter SYSTEM user password:
 
sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
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
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete
100% complete
Look at the log file "/opt/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log" for further details.

啓動數據庫
$ sqlplus / as sysdba  //as前有個空格

[oracle@oracledb ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 16 14:26:57 2015

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

Connected to an idle instance.

SQL> start
SP2-1506: START, @ or @@ command has no arguments
SQL> startup
ORACLE instance started.

Total System Global Area 3290345472 bytes
Fixed Size                  2217832 bytes
Variable Size            1795164312 bytes
Database Buffers         1476395008 bytes
Redo Buffers               16568320 bytes
Database mounted.
Database opened.
SQL>
使用show parameter;或者select table_name from dba_tables看看是否正常


啓動監聽
啓動監聽:lsnrctl start
查看監聽:lsnrctl status
停止監聽:lsnrctl stop

  
[oracle@oracledb ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 16-FEB-2015 14:45:01

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

Starting /opt/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /opt/app/oracle/diag/tnslsnr/oracledb/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                16-FEB-2015 14:45:02
Uptime                    0 days 0 hr. 1 min. 3 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /opt/app/oracle/diag/tnslsnr/oracledb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(PORT=1521)))
The listener supports no services
The command completed successfully


報錯排除
[oracle@oracledb database]$ ./runInstaller -silent -force -responseFile /opt/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 161383 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 16383 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-01-26_01-34-45PM. Please wait ...[oracle@oracledb database]$ [FATAL] [INS-32012] Unable to create directory.
   CAUSE: Either proper permissions were not granted to create the directory or there was no space left in the volume.
   ACTION: Check your permission on the selected directory or choose another directory.
[FATAL] [INS-32012] Unable to create directory.
   CAUSE: Either proper permissions were not granted to create the directory or there was no space left in the volume.
   ACTION: Check your permission on the selected directory or choose another directory.

error

[oracle@oracledb database]$ ./runInstaller -silent -force -responseFile /opt/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 165989 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 16383 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-01-26_03-18-11PM. Please wait ...[oracle@oracledb database]$ [FATAL] [INS-32015] The location specified for Oracle home Location is invalid.
   CAUSE: The specified location cannot be used for Oracle home Location. Either the specified location is not found on the system or is detected to be a file.
   ACTION: Specify a valid location for Oracle home Location.
[WARNING] [INS-32018] The selected Oracle home is outside of Oracle base.
   CAUSE: The Oracle home selected was outside of Oracle base.
   ACTION: Oracle recommends installing Oracle software within the Oracle base directory. Adjust the Oracle home or Oracle base accordingly.
[FATAL] [INS-32021] Insufficient disk space on this volume for the selected Oracle home.
   CAUSE: The selected Oracle home was on a volume without enough disk space.
   ACTION: Choose a location for Oracle home that has enough space (minimum of 4,397MB) or free up space on the existing volume.
  
   解決辦法:
   檢查了環境變量$ORACLE_BASE和$ORACLE_HOME發現兩個路徑均正常,沒有發現任何異常

逐步從頭排查,發現在文件./response/db_install.rsp中INVENTORY_LOCATION、ORACLE_BASE和ORACLE_HOME三個字段被配置成了相對路徑



umask 022
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export PATH=$ORACLE_HOME/bin :$PATH:$HOME/bin


-rw-r--r--  1 oracle oinstall 5402 Aug 18  2009 welcome.html
[oracle@oracledb database]$ ./runInstaller -silent -force -responseFile /opt/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 165989 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 16383 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-01-26_05-56-45PM. Please wait ...[oracle@oracledb database]$ [FATAL] [INS-32015] The location specified for Oracle home Location is invalid.
   CAUSE: The specified location cannot be used for Oracle home Location. Either the specified location is not found on the system or is detected to be a file.
   ACTION: Specify a valid location for Oracle home Location.
[WARNING] [INS-32018] The selected Oracle home is outside of Oracle base.
   CAUSE: The Oracle home selected was outside of Oracle base.
   ACTION: Oracle recommends installing Oracle software within the Oracle base directory. Adjust the Oracle home or Oracle base accordingly.
[FATAL] [INS-32021] Insufficient disk space on this volume for the selected Oracle home.
   CAUSE: The selected Oracle home was on a volume without enough disk space.
   ACTION: Choose a location for Oracle home that has enough space (minimum of 4,397MB) or free up space on the existing volume.
A log of this session is currently saved as: /tmp/OraInstall2015-01-26_05-56-45PM/installActions2015-01-26_05-56-45PM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.

報錯,解決
$ sqlplus / as sysdba  報錯如下:
[oracle@oracledb ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 16 14:21:24 2015
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
    *****解決辦法
    [oracle@oracledb ~]$ echo $ORACLE_HOME
             /opt/app/oracle/product/11.2.0/db_1
    [oracle@oracledb ~]$ echo $ORACLE_SID

oracle_SID 爲空
添加SID
[oracle@oracledb ~]$ export ORACLE_SID=ora11g
確認添加成功
[oracle@oracledb ~]$ echo $ORACLE_SID
ora11g

測試是否啓動
[oracle@oracledb ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 16 14:26:57 2015

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

Connected to an idle instance.

SQL> start
SP2-1506: START, @ or @@ command has no arguments
SQL> startup
ORACLE instance started.

Total System Global Area 3290345472 bytes
Fixed Size                  2217832 bytes
Variable Size            1795164312 bytes
Database Buffers         1476395008 bytes
Redo Buffers               16568320 bytes
Database mounted.
Database opened.
SQL>
正常,問題得到解決
還可以將ORACLE_SID等環境變量寫入到系統profile中,但需要確保系統profile文件內容的有效

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章