CentOS7.3靜默安裝Oracle11gR2

轉自:http://5e8ad817.wiz03.com/share/s/1uyJwn08jkc926WzwG0Ht31c237oy33wA4882P3yXf1GfX75

目錄


目錄
1. 安裝環境
1.1. 操作系統
1.2. Oracle版本
1.3. 硬件檢測
2. 安裝前準備
2.1. 安裝Oracle的依賴包
2.1.1. 通過yum安裝依賴包
2.1.2. 安裝軟件包pdksh-5.2.14-36.el5.i386.rpm
2.2. 創建運行oracle數據庫的系統用戶和用戶組
2.3. 創建Oracle數據庫安裝目錄
2.4. 修改OS系統標識
2.5. 關閉防火牆
2.6. 修改內核參數
2.7. 設置進程數和最大會話數
2.8. 關聯設置(好像11gR1有要求,R2沒有要求)
2.9. 配置環境變量
2.9.1. 系統環境變量(好像11gR1有要求,R2沒有要求)
2.9.2. oracle環境變量
3. 靜默安裝數據庫軟件和創建數據庫
3.1. 解壓安裝文件
3.2. 複製響應文件模板
3.3. 編輯響應文件
3.4. 靜默安裝
3.5. 靜默配置監聽
3.6. 檢查實例
3.7. 查看監聽狀態
3.8. 查看實例狀態
3.9. 查看默認安裝的用戶
3.10. 如果使用歸檔日誌,那麼設置爲歸檔模式
4. 設置開機自啓動
4.1. 修改/etc/oratab文件
4.2. 切換到root賬戶建立自啓動腳本
4.3. 修改/etc/init.d/oracle服務文件權限
4.4. 設置爲開機啓動
4.5. 進行service oracle start/stop/restart測試
4.6. 重啓查看Oracle監聽和實例進程是否能自動啓動



1. 安裝環境

1.1. 操作系統

CentOS release 7.3

1.2. Oracle版本

Oracle Database 11g Release 2 for Linux x86-64

  • linux.x64_11gR2_database_1of2.zip

  • linux.x64_11gR2_database_2of2.zip

1.3. 硬件檢測

  • 物理內存不少於1G

  • 硬盤可以空間不少於5G

  • swap分區空間不少於2G

  • 支持256色以上顯卡

  • cpu主頻不小於550mHZ


2. 安裝前準備

2.1. 安裝Oracle的依賴包

2.1.1. 通過yum安裝依賴包

yum -y install binutils compat-libcap1 compat-libstdc++-33.i686 compat-libstdc++-33.x86_64 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc.i686 glibc.x86_64 glibc-devel.i686 glibc-devel.x86_64 ksh libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 libXext libXtst libX11 libXau libxcb libXi make sysstat unixODBC-devel.i686 unixODBC-devel.x86_64 unixODBC.i686 unixODBC.x86_64

2.1.2. 安裝軟件包pdksh-5.2.14-36.el5.i386.rpm

這個包yum源裏沒有,所以要手動安裝,不裝安裝oracle時會有警告出現,但不影響最後的使用。 
下載這個包上傳到CentOS後使用如下命令安裝

[root@localhost public_root]# rpm -ivh pdksh-5.2.14-36.el5.i386.rpm

2.2. 創建運行oracle數據庫的系統用戶和用戶組

切換到root

[root@localhost ~]# su - root

創建用戶組oinstall

[root@localhost ~]# groupadd oinstall

創建用戶組dba

[root@localhost ~]# groupadd dba

創建oracle用戶,並加入到oinstall和dba用戶組

[root@localhost ~]# useradd -g oinstall -G dba -m oracle

設置用戶oracle的登陸密碼

[root@localhost ~]# passwd oracleChanging password for user oracle.New password: BAD PASSWORD: The password is shorter than 8 charactersRetype new password: passwd: all authentication tokens updated successfully.

查看是否創建成功

[root@localhost ~]# id oracle

爲什麼要創建oinstall用戶組及dba組? 
理論上單例安裝需要3種用戶組:

  • oracle清單組(一般爲oinstall): 
    OINSTALL組的成員被視爲 Oracle 軟件的“所有者”,擁有對 Oracle 中央清單 (oraInventory) 的寫入權限。 
    在一個 Linux 系統上首次安裝 Oracle 軟件時,會創建 /etc/oraInst.loc 文件,該文件指定 Oracle 清單組的名稱(默認爲 oinstall)以及 Oracle 中央清單目錄的路徑。

  • 數據庫管理員(OSDBA,一般爲 dba): 
    OSDBA 組的成員可通過操作系統身份驗證使用 SQL 以 SYSDBA 身份連接到一個 Oracle 實例。該組的成員可執行關鍵的數據庫管理任務,如創建數據庫、啓動和關閉實例。 
    該組的默認名稱爲dba。 
    SYSDBA 系統權限甚至在數據庫未打開時也允許訪問數據庫實例。對此權限的控制完全超出了數據庫本身的範圍。不要混淆 SYSDBA系統權限與數據庫角色 DBA。DBA 角色不包括 SYSDBA 或 SYSOPER 系統權限。

  • 數據庫操作員組(OSOPER,一般爲 oper): 
    OSOPER 組的成員可通過操作系統身份驗證使用 SQL 以 SYSOPER 身份連接到一個 Oracle 實例。這個可選組的成員擁有一組有限的數據庫管理權限,如管理和運行備份。 
    該組的默認名稱爲oper。SYSOPER 系統權限甚至在數據庫未打開時也允許訪問數據庫實例。對此權限的控制完全超出了數據庫本身的範圍。要使用該組,選擇 Advanced 安裝類型來安裝 Oracle 數據庫軟件。

實際只建兩個oinstall和dba,後面再安裝oracle數據庫的時候把OSOPER組也設置是dba組。

2.3. 創建Oracle數據庫安裝目錄

創建數據庫安裝目錄

[root@localhost ~]# mkdir -p /usr/local/environment/oracle

創建數據庫安裝文件目錄

[root@localhost ~]# mkdir -p /usr/local/environment/database

目錄所有者改爲oracle用戶

[root@localhost ~]# chown -R oracle:oinstall /usr/local/environment/oracle/[root@localhost ~]# chown -R oracle:oinstall /usr/local/environment/database/

2.4. 修改OS系統標識

oracle默認不支持CentOS系統安裝,所以需要修改一下系統標識(貌似不改也沒事),CentOS7 基於 RHEL7。 
查看當前系統版本

[root@localhost ~]# cat /etc/redhat-releaseCentOS Linux release 7.3.1611 (Core)

修改系統標識

[root@localhost ~]# vi /etc/redhat-release[root@localhost ~]# cat /etc/redhat-release redhat-7

2.5. 關閉防火牆

CentOS 7.2默認使用的是firewall作爲防火牆。 
查看防火牆狀態,運行中

[root@localhost ~]# systemctl status firewalld.service● firewalld.service - firewalld - dynamic firewall daemon  Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)  Active: active (running) since Mon 2017-09-25 10:07:07 CST; 15min ago    Docs: man:firewalld(1)Main PID: 668 (firewalld)  CGroup: /system.slice/firewalld.service          └─668 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopidSep 25 10:07:05 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...Sep 25 10:07:07 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.

關閉防火牆

[root@localhost ~]# systemctl stop firewalld.service

再次查看防火牆狀態,發現已關閉

[root@localhost ~]# systemctl status firewalld.service● firewalld.service - firewalld - dynamic firewall daemon  Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)  Active: inactive (dead) since Mon 2017-09-25 10:23:46 CST; 31s ago    Docs: man:firewalld(1)  Process: 668 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)Main PID: 668 (code=exited, status=0/SUCCESS)Sep 25 10:07:05 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...Sep 25 10:07:07 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.Sep 25 10:23:46 localhost.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon...Sep 25 10:23:46 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon.

禁止使用防火牆(重啓也是禁止的,因爲是個人虛擬機,所以直接禁用了防火牆)

[root@localhost ~]# systemctl disable firewalld.serviceRemoved symlink /etc/systemd/system/basic.target.wants/firewalld.service.Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

2.6. 修改內核參數

編輯/etc/sysctl.conf

[root@localhost ~]# vi /etc/sysctl.conf

添加如下代碼

net.ipv4.icmp_echo_ignore_broadcasts = 1net.ipv4.conf.all.rp_filter = 1fs.file-max = 6815744 #設置最大打開文件數fs.aio-max-nr = 1048576kernel.shmall = 2097152 #共享內存的總量,8G內存設置:2097152 = 8k*1024*1024/4kkernel.shmmax = 4294967296 #最大共享內存的段大小,官方建議的是內存的1/2,比如內存8G,那麼4*1024*1024*1024=4294967296kernel.shmmni = 4096 #整個系統共享內存端的最大數kernel.sem = 250 32000 100 128  #semaphores: semmsl, semmns, semopm, semmninet.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口範圍net.core.rmem_default = 262144net.core.rmem_max= 4194304net.core.wmem_default= 262144net.core.wmem_max= 1048576

修改後內容如下

[root@localhost ~]# cat /etc/sysctl.conf # sysctl settings are defined through files in# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.## Vendors settings live in /usr/lib/sysctl.d/.# To override a whole file, create a new file with the same in# /etc/sysctl.d/ and put new settings there. To override# only specific settings, add a file with a lexically later# name in /etc/sysctl.d/ and put new settings there.## For more information, see sysctl.conf(5) and sysctl.d(5).net.ipv4.icmp_echo_ignore_broadcasts = 1net.ipv4.conf.all.rp_filter = 1fs.file-max = 6815744 #設置最大打開文件數fs.aio-max-nr = 1048576kernel.shmall = 2097152 #共享內存的總量,8G內存設置:2097152 = 8k*1024*1024/4kkernel.shmmax = 4294967296 #最大共享內存的段大小,官方建議的是內存的1/2,比如內存8G,那麼4*1024*1024*1024=4294967296kernel.shmmni = 4096 #整個系統共享內存端的最大數kernel.sem = 250 32000 100 128  #semaphores: semmsl, semmns, semopm, semmninet.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口範圍net.core.rmem_default = 262144net.core.rmem_max= 4194304net.core.wmem_default= 262144net.core.wmem_max= 1048576

使配置參數生效

[root@localhost ~]# sysctl -p

2.7. 設置進程數和最大會話數

編輯文件/etc/security/limits.conf

[root@localhost ~]# vi /etc/security/limits.conf

加入以下語句:

oracle    soft    nproc    2047oracle    hard    nproc    16384oracle    soft    nofile    1024oracle    hard    nofile    65536

編輯後的文件內容如下

[root@localhost ~]# cat /etc/security/limits.conf # /etc/security/limits.conf##This file sets the resource limits for the users logged in via PAM.#It does not affect resource limits of the system services.##Also note that configuration files in /etc/security/limits.d directory,#which are read in alphabetical order, override the settings in this#file in case the domain is the same or more specific.#That means for example that setting a limit for wildcard domain here#can be overriden with a wildcard setting in a config file in the#subdirectory, but a user specific setting here can be overriden only#with a user specific setting in the subdirectory.##Each line describes a limit for a user in the form:##<domain>        <type>  <item>  <value>##Where:#<domain> can be:#        - a user name#        - a group name, with @group syntax#        - the wildcard *, for default entry#        - the wildcard %, can be also used with %group syntax,#                for maxlogin limit##<type> can have the two values:#        - "soft" for enforcing the soft limits#        - "hard" for enforcing hard limits##<item> can be one of the following:#        - core - limits the core file size (KB)#        - data - max data size (KB)#        - fsize - maximum filesize (KB)#        - memlock - max locked-in-memory address space (KB)#        - nofile - max number of open file descriptors#        - rss - max resident set size (KB)#        - stack - max stack size (KB)#        - cpu - max CPU time (MIN)#        - nproc - max number of processes#        - as - address space limit (KB)#        - maxlogins - max number of logins for this user#        - maxsyslogins - max number of logins on the system#        - priority - the priority to run user process with#        - locks - max number of file locks the user can hold#        - sigpending - max number of pending signals#        - msgqueue - max memory used by POSIX message queues (bytes)#        - nice - max nice priority allowed to raise to values: [-20, 19]#        - rtprio - max realtime priority##<domain>      <type>  <item>        <value>##*              soft    core            0#*              hard    rss            10000#@student        hard    nproc          20#@faculty        soft    nproc          20#@faculty        hard    nproc          50#ftp            hard    nproc          0#@student        -      maxlogins      4oracle    soft    nproc    2047oracle    hard    nproc    16384oracle    soft    nofile    1024oracle    hard    nofile    65536# End of file

2.8. 關聯設置(好像11gR1有要求,R2沒有要求)

編輯文件/etc/pam.d/login

[root@localhost ~]# vi /etc/pam.d/login

加入以下語句

session    required    pam_limits.so

修改後的文件如下

[root@localhost ~]# cat /etc/pam.d/login#%PAM-1.0auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.soauth      substack    system-authauth      include      postloginaccount    required    pam_nologin.soaccount    include      system-authpassword  include      system-auth# pam_selinux.so close should be the first session rulesession    required    pam_selinux.so closesession    required    pam_loginuid.sosession    optional    pam_console.so# pam_selinux.so open should only be followed by sessions to be executed in the user contextsession    required    pam_selinux.so opensession    required    pam_namespace.sosession    optional    pam_keyinit.so force revokesession    include      system-authsession    include      postlogin-session  optional    pam_ck_connector.sosession required pam_limits.so

2.9. 配置環境變量

2.9.1. 系統環境變量(好像11gR1有要求,R2沒有要求)

編輯系統環境變量

[root@localhost ~]# vi /etc/profile

增加如下內容

if [ $USER = "oracle" ]; then        if [ $SHELL = "/bin/ksh" ]; then              ulimit -p 16384              ulimit -n 65536        else              ulimit -u 16384 -n 65536        fifi

使配置文件生效

[root@localhost ~]# source /etc/profile

2.9.2. oracle環境變量

編輯oracle用戶配置文件

[root@localhost ~]# vi /home/oracle/.bash_profile

添加如下內容

export ORACLE_BASE=/usr/local/environment/oracle #oracle數據庫安裝目錄export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle數據庫路徑export ORACLE_SID=orcl #oracle啓動數據庫實例名export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系統環境變量export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系統環境變量export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK  #設置Oracle客戶端字符集,必須與Oracle安裝時設置的字符集保持一致,如:ZHS16GBK,否則出現數據導入導出中文亂碼問題

修改後的文件如下

[root@localhost ~]# cat /home/oracle/.bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then    . ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/.local/bin:$HOME/binexport PATHexport ORACLE_BASE=/usr/local/environment/oracle #oracle數據庫安裝目錄export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle數據庫路徑export ORACLE_SID=orcl #oracle啓動數據庫實例名export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系統環境變量export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系統環境變量export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK  #設置Oracle客戶端字符集,必須與Oracle安裝時設置的字符集保持一致,如:ZHS16GBK,否則出現數據導入導出中文亂碼問題

使配置生效

[root@localhost ~]# source /home/oracle/.bash_profile

3. 靜默安裝數據庫軟件和創建數據庫

3.1. 解壓安裝文件

設置安裝包權限

[root@localhost ~]# cd /usr/local/environment/[root@localhost environment]# chown oracle:oinstall linux.x64_11gR2_database_*

切換到oracle用戶

[root@localhost environment]# su - oracle[oracle@localhost ~]$ cd /usr/local/environment/

解壓

[oracle@localhost environment]$ unzip linux.x64_11gR2_database_1of2.zip[oracle@localhost environment]$ unzip linux.x64_11gR2_database_2of2.zip

3.2. 複製響應文件模板

[oracle@localhost environment]$ cp -R /usr/local/environment/database/response/ ~

3.3. 編輯響應文件

[oracle@localhost ~]$ vi ~/response/db_install.rsp

修改模板中的配置項,其中各項配置解釋如下:

###################################################################### Copyright(c) Oracle Corporation1998,2008. All rights reserved.          #### Specify values for the variables listedbelow to customize your installation.  #### Each variable is associated with acomment. The comment                #### can help to populate the variables withthe appropriate values.              #### IMPORTANT NOTE: This file contains plaintext passwords and            #### should be secured to have readpermission only by oracle user              #### or db administrator who owns thisinstallation.                          ####對整個文件的說明,該文件包含參數說明,靜默文件中密碼信息的保密  #######################################################################------------------------------------------------------------------------------# Do not change the following system generatedvalue. 標註響應文件版本,這個版本必須和要安裝的數據庫版本相同,安裝檢驗無法通過,不能更改#------------------------------------------------------------------------------oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0#------------------------------------------------------------------------------# Specify the installation option.# It can be one of the following:# 1. INSTALL_DB_SWONLY# 2. INSTALL_DB_AND_CONFIG# 3. UPGRADE_DB#選擇安裝類型:1.只裝數據庫軟件 2.安裝數據庫軟件並建庫 3.升級數據庫#-------------------------------------------------------------------------------oracle.install.option=INSTALL_DB_SWONLY#-------------------------------------------------------------------------------# Specify the hostname of the system as setduring the install. It can be used# to force the installation to use analternative hostname rather than using the# first hostname found on the system.(e.g., for systems with multiple hostnames# and network interfaces)指定操作系統主機名,通過hostname命令獲得#-------------------------------------------------------------------------------ORACLE_HOSTNAME=localhost#-------------------------------------------------------------------------------# Specify the Unix group to be set for theinventory directory. #指定oracle inventory目錄的所有者,通常會是oinstall或者dba#-------------------------------------------------------------------------------UNIX_GROUP_NAME=oinstall#-------------------------------------------------------------------------------# Specify the location which holds theinventory files.#指定產品清單oracle inventory目錄的路徑,如果是Win平臺下可以省略#-------------------------------------------------------------------------------INVENTORY_LOCATION=/u01/app/oracle/oraInventory#-------------------------------------------------------------------------------# Specify the languages in which thecomponents 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#指定數據庫語言,可以選擇多個,用逗號隔開。選擇en, zh_CN(英文和簡體中文)#------------------------------------------------------------------------------SELECTED_LANGUAGES=en,zh_CN#------------------------------------------------------------------------------# Specify the complete path of the OracleHome.設置ORALCE_HOME的路徑#------------------------------------------------------------------------------ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1#------------------------------------------------------------------------------# Specify the complete path of the OracleBase. 設置ORALCE_BASE的路徑#------------------------------------------------------------------------------ORACLE_BASE=/u01/app/oracle#------------------------------------------------------------------------------# Specify the installation edition of thecomponent.          # The value should contain only one ofthese choices.      # EE    : EnterpriseEdition                              # SE    : Standard Edition                                # SEONE  Standard Edition One# PE    : Personal Edition (WINDOWS ONLY)#選擇Oracle安裝數據庫軟件的版本(企業版,標準版,標準版1),不同的版本功能不同#詳細的版本區別參考附錄D#------------------------------------------------------------------------------oracle.install.db.InstallEdition=EE#------------------------------------------------------------------------------# This variable is used to enable ordisable custom install.# true : Components mentioned as part of 'customComponents' property#are considered for install.# false : Value for 'customComponents' isnot considered.#是否自定義Oracle的組件,如果選擇false,則會使用默認的組件#如果選擇true否則需要自己在下面一條參數將要安裝的組件一一列出。#安裝相應版權後會安裝所有的組件,後期如果缺乏某個組件,再次安裝會非常的麻煩。#------------------------------------------------------------------------------oracle.install.db.isCustomInstall=true#------------------------------------------------------------------------------# This variable is considered only if'IsCustomInstall' is set to true.# Description: List of Enterprise EditionOptions you would like to install.#            The following choices areavailable. You may specify any#            combination of thesechoices. The components you chooseshould#            be specified in the form"internal-component-name:version"#            Below is a list of components youmay specify to install.#            oracle.rdbms.partitioning:11.2.0.1.0- Oracle Partitioning#            oracle.rdbms.dm:11.2.0.1.0- Oracle Data Mining#            oracle.rdbms.dv:11.2.0.1.0- Oracle Database Vault#            oracle.rdbms.lbac:11.2.0.1.0- Oracle Label Security#            oracle.rdbms.rat:11.2.0.1.0- Oracle Real Application Testing#            oracle.oraolap:11.2.0.1.0- Oracle OLAP# oracle.install.db.isCustomInstall=true的話必須手工選擇需要安裝組件的話#------------------------------------------------------------------------------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################################################################################ PRIVILEGED OPERATING SYSTEM GROUPS                                      # Provide values for the OS groups to whichOSDBA and OSOPER privileges      ## needs to be granted. If the install isbeing performed as a member of the          ## group "dba", then that will beused unless specified otherwise below.            ##指定擁有OSDBA、OSOPER權限的用戶組,通常會是dba組################################################################################------------------------------------------------------------------------------# The DBA_GROUP is the OS group which is tobe granted OSDBA privileges.#------------------------------------------------------------------------------oracle.install.db.DBA_GROUP=dba#------------------------------------------------------------------------------# The OPER_GROUP is the OS group which isto be granted OSOPER privileges.#------------------------------------------------------------------------------oracle.install.db.OPER_GROUP=oinstall#------------------------------------------------------------------------------# Specify the cluster node names selectedduring the installation.#如果是RAC的安裝,在這裏指定所有的節點#------------------------------------------------------------------------------oracle.install.db.CLUSTER_NODES=#------------------------------------------------------------------------------# Specify the type of database to create.# It can be one of the following:# - GENERAL_PURPOSE/TRANSACTION_PROCESSING        # - DATA_WAREHOUSE                              #選擇數據庫的用途,一般用途/事物處理,數據倉庫#------------------------------------------------------------------------------oracle.install.db.config.starterdb.type=GENERAL_PURPOSE#------------------------------------------------------------------------------# Specify the Starter Database GlobalDatabase Name. 指定GlobalName#------------------------------------------------------------------------------oracle.install.db.config.starterdb.globalDBName=ora11g#------------------------------------------------------------------------------# Specify the Starter Database SID.指定SID#------------------------------------------------------------------------------oracle.install.db.config.starterdb.SID=orcl#------------------------------------------------------------------------------# Specify the Starter Database characterset.# It can be 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#選擇字符集。不正確的字符集會給數據顯示和存儲帶來麻煩無數。#通常中文選擇的有ZHS16GBK簡體中文庫或者unicode的AL32UTF8國際字符集#------------------------------------------------------------------------------oracle.install.db.config.starterdb.characterSet=AL32UTF8#------------------------------------------------------------------------------# This variable should be set to true ifAutomatic Memory Management# in Database is desired.# If Automatic Memory Management is notdesired, and memory allocation# is to be done manually, then set it tofalse.#11g的新特性自動內存管理,也就是SGA_TARGET和PAG_AGGREGATE_TARGET都#不用設置了,Oracle會自動調配兩部分大小。#------------------------------------------------------------------------------oracle.install.db.config.starterdb.memoryOption=true#------------------------------------------------------------------------------# Specify the total memory allocation forthe database. Value(in MB) should be# at least 256 MB, and should not exceedthe total physical memory available on the system.# Example:oracle.install.db.config.starterdb.memoryLimit=512#指定Oracle自動管理內存的大小,最小是256MB#------------------------------------------------------------------------------oracle.install.db.config.starterdb.memoryLimit=#------------------------------------------------------------------------------# This variable controls whether to loadExample Schemas onto the starter# database or not.是否載入模板示例#------------------------------------------------------------------------------oracle.install.db.config.starterdb.installExampleSchemas=false#------------------------------------------------------------------------------# This variable includes enabling auditsettings, configuring password profiles# and revoking some grants to public. Thesesettings are provided by default.# These settings may also be disabled.  是否啓用安全設置#------------------------------------------------------------------------------oracle.install.db.config.starterdb.enableSecuritySettings=true################################################################################ Passwords can be supplied for thefollowing four schemas in the                      ## starter database:                                                              ##  SYS                                                                    ##  SYSTEM                                                                ##  SYSMAN (used by Enterprise Manager)                                        ##  DBSNMP (used by Enterprise Manager)                                        ## Same password can be used for allaccounts (not recommended)                        ## or different passwords for each accountcan be provided (recommended)                  ##設置數據庫用戶密碼################################################################################------------------------------------------------------------------------------# This variable holds the password that isto be used for all schemas in the# starter database.#設定所有數據庫用戶使用同一個密碼,其它數據庫用戶就不用單獨設置了。#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.password.ALL=123456#-------------------------------------------------------------------------------# Specify the SYS password for the starterdatabase.#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.password.SYS=#-------------------------------------------------------------------------------# Specify the SYSTEM password for thestarter database.#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.password.SYSTEM=#-------------------------------------------------------------------------------# Specify the SYSMAN password for thestarter database.#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.password.SYSMAN=#-------------------------------------------------------------------------------# Specify the DBSNMP password for thestarter database.#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.password.DBSNMP=#-------------------------------------------------------------------------------# Specify the management option to beselected for the starter database.# It can be one of the following:# 1. GRID_CONTROL# 2. DB_CONTROL#數據庫本地管理工具DB_CONTROL,遠程集中管理工具GRID_CONTROL#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.control=DB_CONTROL#-------------------------------------------------------------------------------# Specify the Management Service to use ifGrid Control is selected to manage# the database. GRID_CONTROL需要設定grid control的遠程路徑URL#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=#-------------------------------------------------------------------------------# This variable indicates whether toreceive email notification for critical# alerts when using DB control.是否啓用Email通知, 啓用後會將告警等信息發送到指定郵箱#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false#-------------------------------------------------------------------------------# Specify the email address to which thenotifications are to be sent.設置通知EMAIL地址#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.dbcontrol.emailAddress=#-------------------------------------------------------------------------------# Specify the SMTP server used for emailnotifications.設置EMAIL郵件服務器#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.dbcontrol.SMTPServer=################################################################################ SPECIFY BACKUP AND RECOVERY OPTIONS                                    ## Out-of-box backup and recovery optionsfor the database can be mentioned              ## using the entries below.                                                        ##安全及恢復設置(默認值即可)out-of-box(out-of-box experience)縮寫爲OOBE#產品給用產品給用戶良好第一印象和使用感受################################################################################------------------------------------------------------------------------------# This variable is to be set to false ifautomated backup is not required. Else# this can be set to true.設置自動備份,和OUI裏的自動備份一樣。#------------------------------------------------------------------------------oracle.install.db.config.starterdb.automatedBackup.enable=false#------------------------------------------------------------------------------# Regardless of the type of storage that ischosen for backup and recovery, if# automated backups are enabled, a job willbe scheduled to run daily at# 2:00 AM to backup the database. This jobwill run as the operating system# user that is specified in this variable.自動備份會啓動一個job,指定啓動JOB的系統用戶ID#------------------------------------------------------------------------------oracle.install.db.config.starterdb.automatedBackup.osuid=#-------------------------------------------------------------------------------# Regardless of the type of storage that ischosen for backup and recovery, if# automated backups are enabled, a job willbe scheduled to run daily at# 2:00 AM to backup the database. This jobwill run as the operating system user# specified by the above entry. Thefollowing entry stores the password for the# above operating system user.自動備份會開啓一個job,需要指定OSUser的密碼#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.automatedBackup.ospwd=#-------------------------------------------------------------------------------# Specify the type of storage to use forthe database.# It can be one of the following:# - FILE_SYSTEM_STORAGE# - ASM_STORAGE#自動備份,要求指定使用的文件系統存放數據庫文件還是ASM#------------------------------------------------------------------------------oracle.install.db.config.starterdb.storageType=#-------------------------------------------------------------------------------# Specify the database file location whichis a directory for datafiles, control# files, redo logs.        # Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM#使用文件系統存放數據庫文件才需要指定數據文件、控制文件、Redo log的存放目錄#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=#-------------------------------------------------------------------------------# Specify the backup and recovery location.# Applicable only whenoracle.install.db.config.starterdb.storage=FILE_SYSTEM#使用文件系統存放數據庫文件才需要指定備份恢復目錄#-------------------------------------------------------------------------------oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=#-------------------------------------------------------------------------------# Specify the existing ASM disk groups tobe used for storage.# Applicable only whenoracle.install.db.config.starterdb.storage=ASM#使用ASM存放數據庫文件才需要指定存放的磁盤組#-------------------------------------------------------------------------------oracle.install.db.config.asm.diskGroup=#-------------------------------------------------------------------------------# Specify the password for ASMSNMP user ofthe ASM instance.                # Applicable only whenoracle.install.db.config.starterdb.storage=ASM_SYSTEM#使用ASM存放數據庫文件才需要指定ASM實例密碼#-------------------------------------------------------------------------------oracle.install.db.config.asm.ASMSNMPPassword=#------------------------------------------------------------------------------# Specify the My Oracle Support AccountUsername.# Example  :MYORACLESUPPORT_USERNAME=metalink#指定metalink賬戶用戶名#------------------------------------------------------------------------------MYORACLESUPPORT_USERNAME=#------------------------------------------------------------------------------# Specify the My Oracle Support AccountUsername password.# Example  : MYORACLESUPPORT_PASSWORD=password# 指定metalink賬戶密碼#------------------------------------------------------------------------------MYORACLESUPPORT_PASSWORD=#------------------------------------------------------------------------------# Specify whether to enable the user to setthe password for# My Oracle Support credentials. The valuecan be either true or false.# If left blank it will be assumed to befalse.# Example  : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true# 用戶是否可以設置metalink密碼#------------------------------------------------------------------------------SECURITY_UPDATES_VIA_MYORACLESUPPORT=#------------------------------------------------------------------------------# Specify whether user wants to give anyproxy details for connection.# The value can be either true or false. Ifleft blank it will be assumed to be false.# Example  : DECLINE_SECURITY_UPDATES=false# False表示不需要設置安全更新,注意,在11.2的靜默安裝中疑似有一個BUG# Response File中必須指定爲true,否則會提示錯誤,不管是否正確填寫了郵件地址#------------------------------------------------------------------------------DECLINE_SECURITY_UPDATES=true#------------------------------------------------------------------------------# Specify the Proxy server name. Lengthshould be greater than zero.#代理服務器名# Example  : PROXY_HOST=proxy.domain.com#------------------------------------------------------------------------------PROXY_HOST=#------------------------------------------------------------------------------# Specify the proxy port number. Should beNumeric and atleast 2 chars.#代理服務器端口# Example  : PROXY_PORT=25#------------------------------------------------------------------------------PROXY_PORT=#------------------------------------------------------------------------------# Specify the proxy user name. LeavePROXY_USER and PROXY_PWD# blank if your proxy server requires noauthentication.#代理服務器用戶名# Example  : PROXY_USER=username#------------------------------------------------------------------------------PROXY_USER=#------------------------------------------------------------------------------# Specify the proxy password. LeavePROXY_USER and PROXY_PWD # blank if your proxy server requires noauthentication.#代理服務器密碼# Example  : PROXY_PWD=password#------------------------------------------------------------------------------PROXY_PWD=

配置完成後的響應文件內容如下:

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0oracle.install.option=INSTALL_DB_AND_CONFIGORACLE_HOSTNAME=localhostUNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/usr/local/environment/oracle/oraInventorySELECTED_LANGUAGES=en,zh_CN,zh_TWORACLE_HOME=/usr/local/environment/oracle/product/11.2.0/db_1ORACLE_BASE=/usr/local/environment/oracleoracle.install.db.InstallEdition=EEoracle.install.db.isCustomInstall=falseoracle.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.0oracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=oinstalloracle.install.db.CLUSTER_NODES=oracle.install.db.config.starterdb.type=GENERAL_PURPOSEoracle.install.db.config.starterdb.globalDBName=orcloracle.install.db.config.starterdb.SID=orcloracle.install.db.config.starterdb.characterSet=ZHS16GBKoracle.install.db.config.starterdb.memoryOption=trueoracle.install.db.config.starterdb.memoryLimit=3143oracle.install.db.config.starterdb.installExampleSchemas=falseoracle.install.db.config.starterdb.enableSecuritySettings=trueoracle.install.db.config.starterdb.password.ALL=123456oracle.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_CONTROLoracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=falseoracle.install.db.config.starterdb.dbcontrol.emailAddress=oracle.install.db.config.starterdb.dbcontrol.SMTPServer=oracle.install.db.config.starterdb.automatedBackup.enable=falseoracle.install.db.config.starterdb.automatedBackup.osuid=oracle.install.db.config.starterdb.automatedBackup.ospwd=oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGEoracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/usr/local/environment/oracle/oradataoracle.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=falseDECLINE_SECURITY_UPDATES=truePROXY_HOST=PROXY_PORT=PROXY_USER=PROXY_PWD=

注意: 
這裏有一個簡單一些的方法,就是在一個有圖形界面的機器上用圖形界面配置安裝信息,配置完成後保存響應文件即可。

3.4. 靜默安裝

[oracle@localhost response]$ cd /usr/local/environment/database/[oracle@localhost database]$ ./runInstaller -silent -force -responseFile /home/oracle/response/db_install.rsp

注意: 
安裝中,如果提示[WARNING]不必理會,此時安裝程序仍在進行,如果出現[FATAL],則安裝程序已經停止了。 
控制檯直到出現以下提示則表示安裝完成

The following configuration scripts need to be executed as the "root" user. #!/bin/sh #Root scripts to run/usr/local/environment/oracle/product/11.2.0/db_1/root.shTo 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.

按照提示使用root用戶執行腳本

[root@localhost ~]# /usr/local/environment/oracle/product/11.2.0/db_1/root.shCheck /usr/local/environment/oracle/product/11.2.0/db_1/install/root_localhost.localdomain_2017-09-25_15-37-58.log for the output of root script

然後返回安裝界面回車,安裝完成。


3.5. 靜默配置監聽

[oracle@localhost database]$ netca /silent /responseFile ~/response/netca.rsp Parsing command line arguments:    Parameter "silent" = true    Parameter "responsefile" = /home/oracle/response/netca.rspDone 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

3.6. 檢查實例

[oracle@localhost database]$ ps -ef | grep ora_ | grep -v grep | wc -l25[oracle@localhost database]$ ps -ef | grep ora_ | grep -v greporacle    7264      1  0 15:33 ?        00:00:00 ora_pmon_orcloracle    7266      1  0 15:33 ?        00:00:00 ora_vktm_orcloracle    7270      1  0 15:33 ?        00:00:00 ora_gen0_orcloracle    7272      1  0 15:33 ?        00:00:00 ora_diag_orcloracle    7274      1  0 15:33 ?        00:00:00 ora_dbrm_orcloracle    7276      1  0 15:33 ?        00:00:00 ora_psp0_orcloracle    7278      1  0 15:33 ?        00:00:00 ora_dia0_orcloracle    7280      1  0 15:33 ?        00:00:00 ora_mman_orcloracle    7282      1  0 15:33 ?        00:00:00 ora_dbw0_orcloracle    7284      1  0 15:33 ?        00:00:00 ora_lgwr_orcloracle    7286      1  0 15:33 ?        00:00:00 ora_ckpt_orcloracle    7288      1  0 15:33 ?        00:00:00 ora_smon_orcloracle    7290      1  0 15:33 ?        00:00:00 ora_reco_orcloracle    7292      1  0 15:33 ?        00:00:00 ora_mmon_orcloracle    7294      1  0 15:33 ?        00:00:00 ora_mmnl_orcloracle    7296      1  0 15:33 ?        00:00:00 ora_d000_orcloracle    7298      1  0 15:33 ?        00:00:00 ora_s000_orcloracle    7394      1  0 15:33 ?        00:00:00 ora_qmnc_orcloracle    7419      1  0 15:33 ?        00:00:00 ora_cjq0_orcloracle    7523      1  0 15:34 ?        00:00:00 ora_q000_orcloracle    7525      1  0 15:34 ?        00:00:00 ora_q001_orcloracle    7531      1  0 15:34 ?        00:00:00 ora_smco_orcloracle    7533      1  0 15:34 ?        00:00:00 ora_w000_orcloracle    16214      1  0 15:49 ?        00:00:00 ora_j000_orcloracle    16216      1  0 15:49 ?        00:00:00 ora_j001_orcl

3.7. 查看監聽狀態

[oracle@localhost database]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-SEP-2017 15:51:06Copyright (c) 1991, 2009, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))STATUS of the LISTENER------------------------Alias                    LISTENERVersion                  TNSLSNR for Linux: Version 11.2.0.1.0 - ProductionStart Date                25-SEP-2017 15:31:02Uptime                    0 days 0 hr. 20 min. 4 secTrace Level              offSecurity                  ON: Local OS AuthenticationSNMP                      OFFListener Parameter File  /usr/local/environment/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log File        /usr/local/environment/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))Services Summary...Service "orcl" has 1 instance(s).  Instance "orcl", status READY, has 1 handler(s) for this service...Service "orclXDB" has 1 instance(s).  Instance "orcl", status READY, has 1 handler(s) for this service...The command completed successfully

3.8. 查看實例狀態

[oracle@localhost database]$ sqlplus / as sysdba
SQL> select status from v$instance;STATUS------------OPEN

3.9. 查看默認安裝的用戶

SQL> set lines 256 pages 500;SQL> select USER_ID,USERNAME,ACCOUNT_STATUS,DEFAULT_TABLESPACE from dba_users;USER_ID USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE---------- ------------------------------ -------------------------------- ------------------------------74 MGMT_VIEW OPEN SYSTEM0 SYS OPEN SYSTEM5 SYSTEM OPEN SYSTEM30 DBSNMP OPEN SYSAUX72 SYSMAN OPEN SYSAUX9 OUTLN EXPIRED & LOCKED SYSTEM75 FLOWS_FILES EXPIRED & LOCKED SYSAUX57 MDSYS EXPIRED & LOCKED SYSAUX53 ORDSYS EXPIRED & LOCKED SYSAUX42 EXFSYS EXPIRED & LOCKED SYSAUX32 WMSYS EXPIRED & LOCKED SYSAUX31 APPQOSSYS EXPIRED & LOCKED SYSAUX78 APEX_030200 EXPIRED & LOCKED SYSAUX83 OWBSYS_AUDIT EXPIRED & LOCKED SYSAUX54 ORDDATA EXPIRED & LOCKED SYSAUX43 CTXSYS EXPIRED & LOCKED SYSAUX46 ANONYMOUS EXPIRED & LOCKED SYSAUX45 XDB EXPIRED & LOCKED SYSAUX55 ORDPLUGINS EXPIRED & LOCKED SYSAUX79 OWBSYS EXPIRED & LOCKED SYSAUX56 SI_INFORMTN_SCHEMA EXPIRED & LOCKED SYSAUX61 OLAPSYS EXPIRED & LOCKED SYSAUX84 SCOTT EXPIRED & LOCKED USERS21 ORACLE_OCM EXPIRED & LOCKED USERS2147483638 XS$NULL EXPIRED & LOCKED USERS65 MDDATA EXPIRED & LOCKED USERS14 DIP EXPIRED & LOCKED USERS76 APEX_PUBLIC_USER EXPIRED & LOCKED USERS70 SPATIAL_CSW_ADMIN_USR EXPIRED & LOCKED USERS67 SPATIAL_WFS_ADMIN_USR EXPIRED & LOCKED USERS30 rows selected.

3.10. 如果使用歸檔日誌,那麼設置爲歸檔模式

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; (手工歸檔測試)

4. 設置開機自啓動

4.1. 修改/etc/oratab文件

[oracle@localhost environment]$ vi /etc/oratab

orcl:/usr/local/environment/oracle/product/11.2.0/db_1:N改爲orcl:/usr/local/environment/oracle/product/11.2.0/db_1:Y

4.2. 切換到root賬戶建立自啓動腳本

[root@localhost environment]# vi /etc/rc.d/init.d/oracle

添加以下內容,ORA_HOME和ORA_OWNER根據實際情況可以修改。

#!/bin/sh#chkconfig: 2345 20 80#description: Oracle dbstart / dbshut#以上兩行爲chkconfig所需ORA_HOME=/usr/local/environment/oracle/product/11.2.0/db_1ORA_OWNER=oracleLOGFILE=/var/log/oracle.logecho "#################################" >> ${LOGFILE}date +"### %T %a %D: Run Oracle" >> ${LOGFILE}if [ ! -f ${ORA_HOME}/bin/dbstart ] || [ ! -f ${ORA_HOME}/bin/dbshut ]; then    echo "Error: Missing the script file ${ORA_HOME}/bin/dbstart or ${ORA_HOME}/bin/dbshut!" >> ${LOGFILE}    echo "#################################" >> ${LOGFILE}    exitfistart(){    echo "###Startup Database..."    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbstart ${ORA_HOME}"    echo "###Done."    echo "###Run database control..."    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl start dbconsole"    echo "###Done."}stop(){    echo "###Stop database control..."    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl stop dbconsole"    echo "###Done."    echo "###Shutdown Database..."    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbshut ${ORA_HOME}"    echo "###Done."}case "$1" in    'start')        start >> ${LOGFILE}    ;;    'stop')        stop >> ${LOGFILE}    ;;    'restart')        stop >> ${LOGFILE}        start >> ${LOGFILE}    ;;esacdate +"### %T %a %D: Finished." >> ${LOGFILE}echo "#################################" >> ${LOGFILE}echo ""

4.3. 修改/etc/init.d/oracle服務文件權限

[root@localhost environment]# chmod 755 /etc/init.d/oracle

4.4. 設置爲開機啓動

[root@localhost environment]# chkconfig oracle on

4.5. 進行service oracle start/stop/restart測試

[root@localhost environment]# service oracle stop[root@localhost environment]# service oracle start[root@localhost environment]# service oracle restart

4.6. 重啓查看Oracle監聽和實例進程是否能自動啓動

[root@localhost environment]# reboot


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