oracle 11g linux命令列靜默安裝
以前安裝資料庫一直都是用的圖形化介面,最近在生產linux上因為某些原因無法使用圖形化安裝,因此萌生了靜默安裝的想法,這樣不用依賴圖形化的懶人操作介面,也算是一個額外的收穫,安裝步驟如下:
系統 | oracle linux 7.0 |
安裝包 | p10404530_112030_Linux-x86-64_1of7.zip p10404530_112030_Linux-x86-64_2of7.zip |
yum映象檔案 | CentOS-7-x86_64-DVD-1406.iso |
靜默安裝準備檔案 | db_install.rsp,準【】備responseFile檔案】分割線有說明 |
1、安裝前準備
--------------------------------------yum源配置---------------------------------------------------------------
mkdir /yum #建立目錄
mkdir -p /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
mount -o loop -t iso9660 /opt/CentOS-7-x86_64-DVD-1406.iso /yum #裝載映象
vi /etc/yum.repos.d/yumo.repo #編輯repo檔案
[yumo]
name=yumo
baseurl=file:///yum
gpgcheck=0
enabled=1
yum clean all #清除舊yum源
yum repolist #檢視yum repo
安裝oracle需要的yum源
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers glibc-static kernel-headers pdksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel libstdc++-static make numactl-devel sysstat unixODBC unixODBC-devel
--------------------------------------關閉防火牆、SELINUX---------------------------------------------------
1.Oracle linux 7.0版本關閉防火牆
檢視防火牆狀態。
systemctl status firewalld
臨時關閉防火牆命令。重啟電腦後,防火牆自動起來。
systemctl stop firewalld
永久關閉防火牆命令。重啟後,防火牆不會自動啟動。
systemctl disable firewalld
開啟防火牆命令。
systemctl enable firewalld
2.centos 6.7關閉防火牆
servcie iptables stop --臨時關閉防火牆
chkconfig iptables off --永久關閉防火牆
3.檢查SELINUX是否開啟,結果沒有開啟,狀態為:disabled
/usr/sbin/sestatus -v
vi /etc/selinux/config
修改SELINUX=disabled
--------------------------------------使用者使用者組設定---------------------------------------------------------------
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
mkdir -p /u01/app
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app
--------------------------------------linux系統檔案設定---------------------------------------------------------------
vi /etc/sysctl.conf
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
--------------------------------------設定.bash_profile環境變數---------------------------------------------------
vi .bash_profile #需要進入oracle使用者下su - oracle
export ORACLE_BASE=/u01/app/oracle/inventory
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin儲存x,退出
source .bash_profile #編譯環境變數
--------------------------------------準備responseFile檔案-------------------------------------------------------------
解壓p10404530_112030_Linux-x86-64_1of7.zip、p10404530_112030_Linux-x86-64_2of7.zip檔案後出現database/response/,檔案下有三個.rsp檔案,如下
dbca.rsp:建立資料庫
db_install.rsp:安裝oracle軟體,也可同時建立資料庫
netca.rsp :建立監聽
修改db_install.rsp相關內容如下:
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY #僅安裝資料庫軟體,不建立資料庫。INSTALL_DB_AND_CONFIG引數可一併安裝建立
ORACLE_HOSTNAME=localhost.localdomain
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
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
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1024 #根據linux的記憶體設定,我的linux伺服器總記憶體4G,給oracle 1G
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=123456 #所有使用者密碼都為123456
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.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=/u01/app/oracle/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oracle/fast_recovery_area
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true #此處若為false,則安裝報錯My Oracle Support Username/Email Address Not Specified
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
2、開始安裝
--------------------------------------runInstaller 安裝資料庫軟體-------------------------------------
[[email protected] database]$ ./runInstaller -silent -ignoreSysPrereqs -showProgress -responseFile /opt/database/response/db_install.rsp
其中-silent指的是靜默安裝,-ignorePrereq忽略prerequisite的檢查結果,showProgress顯示進度,responseFile是種子檔案。
[[email protected] database]$ ./runInstaller -silent -ignoreSysPrereqs -showProgress -responseFile /opt/database/response/db_install.rsp
Starting Oracle Universal Installer...Checking Temp space: must be greater than 120 MB. Actual 27915 MB Passed
Checking swap space: must be greater than 150 MB. Actual 3983 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-12-28_06-43-18PM. Please wait ...[[email protected] 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/OraInstall2018-12-28_06-43-18PM/installActions2018-12-28_06-43-18PM.log
ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2018-12-28_06-43-18PM/installActions2018-12-28_06-43-18PM.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:
/u01/app/oracle/oraInventory/logs/installActions2018-12-28_06-43-18PM.logPrepare in progress.
.................................................. 9% Done.Prepare successful.
Copy files in progress.
.................................................. 14% Done.
.................................................. 20% Done.
.................................................. 26% Done.
.................................................. 31% Done.
.................................................. 36% Done.
.................................................. 44% Done.
.................................................. 49% Done.
.................................................. 55% Done.
.................................................. 63% Done.
.................................................. 68% Done.
.................................................. 73% Done.
.................................................. 78% Done.
.................................................. 83% Done.
..............................
Copy files successful.Link binaries in progress.
..........
Link binaries successful.Setup files in progress.
.................................................. 88% Done.
.................................................. 94% Done.Setup files successful.
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oracle/oraInventory/logs/silentInstall2018-12-28_06-43-18PM.log' for more details.Execute Root Scripts in progress.
As a root user, execute the following script(s):
1. /u01/app/oracle/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
.................................................. 100% Done.Execute Root Scripts successful.
Successfully Setup Software.
最後,需root使用者手動執行以下兩個檔案:
1./u01/app/oracle/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
--------------------------------------dbca建立資料庫--------------------------------------------------------------
[[email protected] database]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName orcl -sysPassword 123456 -systemPassword 123456
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/inventory/cfgtoollogs/dbca/orcl/orcl.log" for further details.
刪除資料庫命令可參考
dbca -silent -deleteDatabase -sourceDB orcl -sysDBAUserName sys -sysDBAPassword 123456
--------------------------------------tnsnames.ora , listener.ora 設定----------------------------------
cd $ORACLE_HOME/network/admin
[[email protected] admin]$ cat tnsnames.ora
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.136.211)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
[[email protected] admin]$ cat listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM = extproc)
)
)LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.136.211)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
[[email protected] admin]$
啟動監聽lsnrctl start
[[email protected] admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-DEC-2018 19:41:19
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.136.211)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 28-DEC-2018 19:04:10
Uptime 0 days 0 hr. 37 min. 9 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/inventory/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(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
[[email protected] admin]$
至此,資料庫已全部安裝建立完畢,可正常使用!