測試環境:centos 6.9 X64 mini 版 Oracle版本:11g r2 Oracle軟體包:db_112040_Linux-x86-64_1of7.zip;db_112040_Linux-x86-64_2of7.zip 靜默安裝的應答原文件路徑:/home/soft/database/ ...
測試環境:centos 6.9 X64 mini 版
Oracle版本:11g r2
Oracle軟體包:db_112040_Linux-x86-64_1of7.zip;db_112040_Linux-x86-64_2of7.zip
靜默安裝的應答原文件路徑:/home/soft/database/response
一、環境準備
環境初始化腳本:來源於網上做了個小修改
功能:實現環境的修改和補丁的補全
1 #!/bin/bash 2 # oracle 11g R2 for linux 安裝輔助腳本 3 # Redkey 4 # version 1.3 5 # date 2017.10.19 6 #定義常量 7 SYSCTL=/etc/sysctl.conf 8 LIMITS=/etc/security/limits.conf 9 PAM=/etc/pam.d/login 10 PROFILE=/etc/profile 11 BASH_PROFILE=/home/oracle/.bash_profile 12 #迴圈變數 13 i=1 14 #定義顯示顏色 15 #顏色定義 信息(33黃色) 警示(31紅色) 過程(36淺藍) 16 #判斷執行用戶是否root 17 isroot() 18 { 19 if [ $USER != "root" ];then 20 echo -e "\n\e[1;31m the user must be root,and now you user is $USER,please su to root. \e[0m" 21 exit4 22 else 23 echo -e "\n\e[1;36m check root ... OK! \e[0m" 24 fi 25 } 26 yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh compat-db control-center libstdc++ libstdc++-devel xscreensaver openmotif21 ksh* compat-libcap* zip unzip 27 #掛在光碟到/mnt/cdrom目錄下 28 #mount_cdrom() 29 #{ 30 #echo -e "\n\e[1;31m please insert RHEL to CDROM,press any key ...\e[0m" 31 #read -n 1 32 #if [ -d /mnt/cdrom ];then 33 # mount -t auto -o ro /dev/cdrom /mnt/cdrom 34 #else 35 # mkdir -p /mnt/cdrom 36 # mount -t auto -o ro /dev/cdrom /mnt/cdrom 37 #fi 38 #if [ $? -eq 0 ];then 39 # echo -e "\n\e[1;36m CDROM mount on /mnt/cdrom ... OK! \e[0m" 40 #fi 41 #} 42 #設置yum本地光碟源 43 #yum_repo() 44 #{ 45 # rm -rf /etc/yum.repos.d/* && cat <<EOF >> /etc/yum.repos.d/Server.repo 46 #[Server] 47 #name=MyRPM 48 #baseurl=file:///mnt/cdrom/Server 49 #enabled=1 50 #gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release 51 #EOF 52 #if [ $? -eq 0 ];then 53 #echo -e "\n\e[1;36m /etc/yum.repos.d/Server.repo ... OK! \e[0m" 54 #fi 55 #} 56 #添加oracle用戶,添加oracle用戶所屬組oinstall及附加組dba 57 ouseradd() 58 { 59 if [[ `grep "oracle" /etc/passwd` != "" ]];then 60 userdel -r oracle 61 fi 62 if [[ `grep "oinstall" /etc/group` = "" ]];then 63 groupadd oinstall 64 fi 65 if [[ `grep "dba" /etc/group` = "" ]];then 66 groupadd dba 67 fi 68 useradd oracle -g oinstall -G dba && echo $1 |passwd oracle --stdin 69 if [ $? -eq 0 ];then 70 echo -e "\n\e[1;36m oracle's password updated successfully --- OK! \e[0m" 71 else 72 echo -e "\n\e[1;31m oracle's password set faild. --- NO!\e[0m" 73 fi 74 } 75 #檢查oracle所需軟體包並安裝 76 packagecheck() 77 { 78 for package in binutils compat-libcap1 compat-libstdc++ gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat 79 do 80 rpm -q $package 2> /dev/null 81 if [ $? != 0 ];then 82 yum -y install $package 83 echo -e "\n\e[1;36m $package is already installed ... OK! \e[0m" 84 fi 85 done 86 } 87 #安裝桌面套件 X Window System / Desktop 88 #xdesk() 89 #{ 90 # yum -y groupinstall "X Window System" "Desktop" 91 #} 92 # 設置內核參數 93 94 kernelset() 95 { 96 cp $SYSCTL{,.bak} && cat <<EOF >>$SYSCTL 97 fs.aio-max-nr = 1048576 98 fs.file-max = 6815744 99 kernel.shmall = 2097152 100 kernel.shmmax = 4294967295 101 kernel.shmmni = 4096 102 kernel.sem = 250 32000 100 128 103 net.ipv4.ip_local_port_range = 9000 65500 104 net.core.rmem_default = 262144 105 net.core.rmem_max = 4194304 106 net.core.wmem_default = 262144 107 net.core.wmem_max = 1048575 108 EOF 109 if [ $? -eq 0 ];then 110 echo -e "\n\e[1;36m kernel parameters updated successfully --- OK! \e[0m" 111 fi 112 sysctl -p 113 } 114 #設置oracle資源限制 115 oralimit() 116 { 117 cp $LIMITS{,.bak} && cat <<EOF >> $LIMITS 118 oracle soft nproc 2047 119 oracle hard nproc 16384 120 oracle soft nofile 1024 121 oracle hard nofile 65536 122 oracle soft stack 10240 123 EOF 124 if [ $? -eq 0 ];then 125 echo -e "\n\e[1;36m $LIMITS updated successfully ... OK! \e[0m" 126 fi 127 } 128 #設置login文件 129 setlogin() 130 { 131 cp $PAM{,.bak} && cat <<EOF >>$PAM 132 session required pam_limits.so 133 EOF 134 if [ $? -eq 0 ];then 135 echo -e "\n\e[1;36m $PAM updated successfully ... OK! \e[0m" 136 fi 137 } 138 #設置profile文件 139 setprofile() 140 { 141 cp $PROFILE{,.bak} && cat <<EOF >>$PROFILE 142 if [ $USER = "oracle" ];then 143 if [ $SHELL = "/bin/ksh" ];then 144 ulimit -p 16384 145 ulimit -n 65536 146 else 147 ulimit -u 16384 -n 65536 148 fi 149 fi 150 EOF 151 if [ $? -eq 0 ];then 152 echo -e "\n\e[1;36m $PROFILE updated successfully ... OK! \e[0m" 153 fi 154 } 155 #設置oracle的profile文件 156 setbash_profile() 157 { 158 cp $BASH_PROFILE{,.bak} && cat <<EOF >> $BASH_PROFILE 159 umask 022 160 ORACLE_BASE=/home/oracle/app 161 ORACLE_HOME=/home/oracle/app/product/11.2.0/db_1 162 ORACLE_SID=orcl 163 PATH=$ORACLE_HOME/bin/:$PATH 164 LANG=en_US.UTF-8 165 stty erase ^H 166 export ORACLE_BASE ORACLE_HOME ORACLE_SID 167 EOF 168 if [ $? -eq 0 ];then 169 echo -e "\n\e[1;36m $BASH_PROFILE updated successfully ... OK! \e[0m" 170 fi 171 . $BASH_PROFILE 172 } 173 #系統環境檢查 174 oscheck() 175 { 176 #查看記憶體大小是否大於1G 177 echo -e "\n check MEM Size ..." 178 if [ `cat /proc/meminfo | grep MemTotal | awk '{print $2}'` -lt 1048576 ];then 179 echo -e "\n\e[1;33m Memory Small \e[0m" 180 exit 1 181 else 182 echo -e "\n\e[1;36m Memory checked PASS \e[0m" 183 fi 184 #查看tmp空間大小 185 echo -e "\n check tmpfs Size ..." 186 cp /etc/fstab{,.bak} 187 while true;do 188 if [ `df | awk '/tmpfs/ {print $2}'` -lt 1048576 ];then 189 echo -e "\n\e[1;33m tmpfs Smaill \e[0m" 190 sed -i '/tmpfs/s/defaults/defaults,size=1G/' /etc/fstab && mount -o remount /dev/shm 191 if [ $? != 0 ];then 192 i=i+1 193 if [ $i -eq 3 ];then 194 echo -e "\n\e[1;31m set tmpfs faild. \e[0m" 195 exit 3 196 fi 197 else 198 echo -e "\n\e[1;36 tmpfs updated successfully. \e[0m" 199 break 200 fi 201 else 202 echo -e "\n\e[1;36m tmpfs checked PASS \e[0m" 203 break 204 fi 205 done 206 } 207 #停止防火牆IPTABLES 208 service iptables stop 209 chkconfig iptables off 210 #關閉SELINUX 211 cp /etc/selinux/config{,.bak} && sed -i '/SELINUX/s/enforcing/disabled/;/SELINUX/s/permissive/disabled/' /etc/selinux/config 212 setenforce 0 213 #執行以上函數 214 isroot 215 oscheck 216 packagecheck 217 xdesk 218 kernelset 219 oralimit 220 setlogin 221 setprofile 222 echo -e "\n\e[1;33m please input oracle's user passwd: \e[0m" 223 read oraclepw 224 ouseradd $oraclepw 225 setbash_profile 226 echo -e "\n\e[1;33m please input oracle install PATH(default /home/oracle/app) \e[0m" 227 read oraclepath 228 if [ -z $oraclepath ];then 229 oraclepath=/home/oracle/app 230 fi 231 echo -e "\n\e[1;33m please input oracle_sid (default orcl) \e[0m" 232 read orasid 233 if [ -z orasid ];then 234 orasid=orcl 235 fi 236 setbash_profile $oraclepath $orasid 237 mkdir -p $oraclepath && chown -R oracle:oinstall $oraclepath && chmod -R 755 $oraclepath && mkdir -p /home/oracle/app/oraInventory && chown -R oracle:oinstall /home/oracle/ 238 unset i 239 echo -e "\n\e[1;35m Oracle install pre-setting finish! && please run oracle installer as user oracle \e[0m"
1、首先複製上面的文本進行創建腳本文件並授可執行許可權,並執行腳本
[root@oracle ~]vim oracleinstall.sh 複製腳本粘貼進來
[root@oracle ~]chmod +x oracleinstall.sh && ./oracleinstall.sh
2、執行腳本需要輸入oracle用戶密碼,其它的兩個可以保持預設
3、然後切換到oracle賬戶
[root@oracle ~] su - oracel
4、新建一個soft文件夾
[oracle@oracle ~]mkdir soft
切換到目錄
我實際上是建在home目下麵的
需要在root用戶下授於oracle:orinstall的許可權
[root@oracle ~]chown -R oracle:oinstall /home/soft
[root@oracle ~]cd /home/soft/
4、上傳並解壓db_112040_Linux-x86-64_1of7.zip;db_112040_Linux-x86-64_2of7.zip
推薦使用rz上傳命令(在初始化腳本時已安裝)
解壓命令:unzip db_112040_Linux-x86-64_1of7.zip && unzip db_112040_Linux-x86-64_2of7.zip
二、安裝資料庫軟體
靜默安裝腳本內容:
1 #################################################################### 2 ## Copyright(c) Oracle Corporation 1998,2013. All rights reserved.## 3 ## ## 4 ## Specify values for the variables listed below to customize ## 5 ## your installation. ## 6 ## ## 7 ## Each variable is associated with a comment. The comment ## 8 ## can help to populate the variables with the appropriate ## 9 ## values. ## 10 ## ## 11 ## IMPORTANT NOTE: This file contains plain text passwords and ## 12 ## should be secured to have read permission only by oracle user ## 13 ## or db administrator who owns this installation. ## 14 ## ## 15 #################################################################### 16 17 #------------------------------------------------------------------------------ 18 # Do not change the following system generated value. 19 #------------------------------------------------------------------------------ 20 oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0 21 22 #------------------------------------------------------------------------------ 23 # Specify the installation option. 24 # It can be one of the following: 25 # - INSTALL_DB_SWONLY 26 # - INSTALL_DB_AND_CONFIG 27 # - UPGRADE_DB 28 #------------------------------------------------------------------------------- 29 oracle.install.option=INSTALL_DB_SWONLY 30 31 #------------------------------------------------------------------------------- 32 # Specify the hostname of the system as set during the install. It can be used 33 # to force the installation to use an alternative hostname rather than using the 34 # first hostname found on the system. (e.g., for systems with multiple hostnames 35 # and network interfaces) 36 #------------------------------------------------------------------------------- 37 ORACLE_HOSTNAME=oracle 38 39 #------------------------------------------------------------------------------- 40 # Specify the Unix group to be set for the inventory directory. 41 #------------------------------------------------------------------------------- 42 UNIX_GROUP_NAME=oinstall 43 44 #------------------------------------------------------------------------------- 45 # Specify the location which holds the inventory files. 46 # This is an optional parameter if installing on 47 # Windows based Operating System. 48 #------------------------------------------------------------------------------- 49 INVENTORY_LOCATION=/home/oracle/app/oraInventory 50 51 #------------------------------------------------------------------------------- 52 # Specify the languages in which the components will be installed. 53 # 54 # en : English ja : Japanese 55 # fr : French ko : Korean 56 # ar : Arabic es : Latin American Spanish 57 # bn : Bengali lv : Latvian 58 # pt_BR: Brazilian Portuguese lt : Lithuanian 59 # bg : Bulgarian ms : Malay 60 # fr_CA: Canadian French es_MX: Mexican Spanish 61 # ca : Catalan no : Norwegian 62 # hr : Croatian pl : Polish 63 # cs : Czech pt : Portuguese 64 # da : Danish ro : Romanian 65 # nl : Dutch ru : Russian 66 # ar_EG: Egyptian zh_CN: Simplified Chinese 67 # en_GB: English (Great Britain) sk : Slovak 68 # et : Estonian sl : Slovenian 69 # fi : Finnish es_ES: Spanish 70 # de : German sv : Swedish 71 # el : Greek th : Thai 72 # iw : Hebrew zh_TW: Traditional Chinese 73 # hu : Hungarian tr : Turkish 74 # is : Icelandic uk : Ukrainian 75 # in : Indonesian vi : Vietnamese 76 # it : Italian 77 # 78 # all_langs : All languages 79 # 80 # Specify value as the following to select any of the languages. 81 # Example : SELECTED_LANGUAGES=en,fr,ja 82 # 83 # Specify value as the following to select all the languages. 84 # Example : SELECTED_LANGUAGES=all_langs 85 #------------------------------------------------------------------------------ 86 SELECTED_LANGUAGES=en,zh_CN 87 88 #------------------------------------------------------------------------------ 89 # Specify the complete path of the Oracle Home. 90 #------------------------------------------------------------------------------ 91 ORACLE_HOME=/home/oracle/app/product/11.2.0/db_1 92 93 #------------------------------------------------------------------------------ 94 # Specify the complete path of the Oracle Base. 95 #------------------------------------------------------------------------------ 96 ORACLE_BASE=/home/oracle/app 97 98 #------------------------------------------------------------------------------ 99 # Specify the installation edition of the component. 100 # 101 # The value should contain only one of these choices. 102 # - EE : Enterprise Edition 103 # - SE : Standard Edition 104 # - SEONE : Standard Edition One 105 # - PE : Personal Edition (WINDOWS ONLY) 106 #------------------------------------------------------------------------------ 107 oracle.install.db.InstallEdition=EE 108 109 #------------------------------------------------------------------------------ 110 # This variable is used to enable or disable custom install and is considered 111 # only if InstallEdition is EE. 112 # 113 # true : Components mentioned as part of 'optionalComponents' property 114 # are considered for install. 115 # false : Value for 'optionalComponents' is not considered. 116 #------------------------------------------------------------------------------ 117 oracle.install.db.EEOptionsSelection=true 118 119 #------------------------------------------------------------------------------ 120 # This variable is considered only if 'EEOptionsSelection' is set to true. 121 # 122 # Description: List of Enterprise Edition Options you would like to enable. 123 # 124 # The following choices are available. You may specify any 125 # combination of these choices. The components you choose should 126 # be specified in the form "internal-component-name:version" 127 # Below is a list of components you may specify to enable. 128 # 129 # oracle.oraolap:11.2.0.4.0 - Oracle OLAP 130 # oracle.rdbms.dm:11.2.0.4.0 - Oracle Data Mining 131 # oracle.rdbms.dv:11.2.0.4.0 - Oracle Database Vault 132 # oracle.rdbms.lbac:11.2.0.4.0 - Oracle Label Security 133 # oracle.rdbms.partitioning:11.2.0.4.0 - Oracle Partitioning 134 # oracle.rdbms.rat:11.2.0.4.0 - Oracle Real Application Testing 135 #------------------------------------------------------------------------------ 136 oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0 137 138 ############################################################################### 139 # # 140 # PRIVILEGED OPERATING SYSTEM GROUPS # 141 # ------------------------------------------ # 142 # Provide values for the OS groups to which OSDBA and OSOPER privileges # 143 # needs to be granted. If the install is being performed as a member of the # 144 # group "dba", then that will be used unless specified otherwise below. # 145 # # 146 # The value to be specified for OSDBA and OSOPER group is only for UNIX based # 147 # Operating System. # 148 # # 149 ############################################################################### 150 151 #------------------------------------------------------------------------------ 152 # The DBA_GROUP is the OS group which is to be granted OSDBA privileges. 153 #------------------------------------------------------------------------------ 154 oracle.install.db.DBA_GROUP=dba 155 156 #------------------------------------------------------------------------------ 157 # The OPER_GROUP is the OS group which is to be granted OSOPER privileges. 158 # The value to be specified for OSOPER group is optional. 159 #------------------------------------------------------------------------------ 160 oracle.install.db.OPER_GROUP=oinstall 161 162 #------------------------------------------------------------------------------ 163 # Specify the cluster node names selected during the installation. 164 # Example : oracle.install.db.CLUSTER_NODES=node1,node2 165 #------------------------------------------------------------------------------ 166 oracle.install.db.CLUSTER_NODES= 167 168 #------------------------------------------------------------------------------ 169 # This variable is used to enable or disable RAC One Node install. 170 # 171 # - true : Value of RAC One Node service name is used. 172 # - false : Value of RAC One Node service name is not used. 173 # 174 # If left blank, it will be assumed to be false 175 #------------------------------------------------------------------------------ 176 oracle.install.db.isRACOneInstall= 177 178 #------------------------------------------------------------------------------ 179 # Specify the name for RAC One Node Service. 180 #------------------------------------------------------------------------------ 181 oracle.install.db.racOneServiceName= 182 183 #------------------------------------------------------------------------------ 184 # Specify the type of database to create. 185 # It can be one of the following: 186 # - GENERAL_PURPOSE/TRANSACTION_PROCESSING 187 # - DATA_WAREHOUSE 188 #------------------------------------------------------------------------------ 189 oracle.install.db.config.starterdb.type=GENERAL_PURPOSE 190 191 #------------------------------------------------------------------------------ 192 # Specify the Starter Database Global Database Name. 193 #------------------------------------------------------------------------------ 194 oracle.install.db.config.starterdb.globalDBName=orcl 195 196 #------------------------------------------------------------------------------ 197 # Specify the Starter Database SID. 198 #------------------------------------------------------------------------------ 199 oracle.install.db.config.starterdb.SID=orcl 200 201 #------------------------------------------------------------------------------ 202 # Specify the Starter Database character set. 203 # 204 # It can be one of the following: 205 # AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2, 206 # EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257, 207 # BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6, 208 # AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8, 209 # IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE, 210 # KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950, 211 # ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258 212 #------------------------------------------------------------------------------ 213 oracle.install.db.config.starterdb.characterSet=AL32UTF8 214 215 #------------------------------------------------------------------------------ 216 # This variable should be set to true if Automatic Memory Management 217 # in Database is desired. 218 # If Automatic Memory Management is not desired, and memory allocation 219 # is to be done manually, then set it to false. 220 #------------------------------------------------------------------------------ 221 oracle.install.db.config.starterdb.memoryOption=true 222 223 #------------------------------------------------------------------------------ 224 # Specify the total memory allocation for the database. Value(in MB) should be 225 # at least 256 MB, and should not exceed the total physical memory available 226 # on the system. 227 # Example: oracle.install.db.config.starterdb.memoryLimit=512 228 #------------------------------------------------------------------------------ 229 oracle.install.db.config.starterdb.memoryLimit= 230 231 #------------------------------------------------------------------------------ 232 # This variable controls whether to load Example Schemas onto 233 # the starter database or not. 234 #------------------------------------------------------------------------------ 235 oracle.install.db.config.starterdb.installExampleSchemas=false 236 237 #------------------------------------------------------------------------------ 238 # This variable includes enabling audit settings, configuring password profiles 239 # and revoking some grants to public. These settings are provided by default. 240 # These settings may also be disabled. 241 #------------------------------------------------------------------------------ 242 oracle.install.db.config.starterdb.enableSecuritySettings=true 243 244 ############################################################################### 245 # # 246 # Passwords can be supplied for the following four schemas in the # 247 # starter database: # 248 # SYS # 249 # SYSTEM # 250 # SYSMAN (used by Enterprise Manager) # 251 # DBSNMP (used by Enterprise Manager) # 252 # # 253 # Same password can be used for all accounts (not recommended) # 254 # or different passwords for each account can be provided (recommended) # 255 # # 256 ############################################################################### 257 258 #------------------------------------------------------------------------------ 259 # This variable holds the password that is to be used for all schemas in the 260 # starter database. 261 #------------------------------------------------------------------------------- 262 oracle.install.db.config.starterdb.password.ALL=111111 263 264 #------------------------------------------------------------------------------- 265 # Specify the SYS password for the starter database. 266 #------------------------------------------------------------------------------- 267 oracle.install.db.config.starterdb.password.SYS= 268 269 #------------------------------------------------------------------------------- 270 # Specify the SYSTEM password for the starter database. 271 #------------------------------------------------------------------------------- 272 oracle.install.db.config.starterdb.password.SYSTEM= 273 274 #------------------------------------------------------------------------------- 275 # Specify the SYSMAN password for the starter database. 276 #------------------------------------------------------------------------------- 277 oracle.install.db.config.starterdb.password.SYSMAN= 278 279 #------------------------------------------------------------------------------- 280 # Specify the DBSNMP password for the starter database. 281 #------------------------------------------------------------------------------- 282 or