說明:原創(chuàng),經(jīng)過一天的折騰趾娃,終于搞清楚centos7.2上靜默安裝oracle數(shù)據(jù)庫(kù)缭嫡,并且經(jīng)過安裝驗(yàn)證。由于之前都是在桌面環(huán)境中安裝抬闷,一般依賴包安裝完妇蛀,安裝過程和Windows上相似。但是如果服務(wù)器中的Linux安裝了桌面環(huán)境笤成,因?yàn)樽烂姝h(huán)境運(yùn)行還是比較占用資源评架,會(huì)拖慢服務(wù)器的速度,所以現(xiàn)在大多數(shù)Linux服務(wù)器都是無桌面版的炕泳,安裝都是最小化環(huán)境纵诞。
當(dāng)然,可以在安裝最小化環(huán)境中的Linux中安裝桌面環(huán)境培遵,安裝好后再次安裝oracle數(shù)據(jù)庫(kù)浙芙。最后又將桌面環(huán)境卸載。但是這種方法麻煩費(fèi)時(shí)籽腕。
今天嗡呼,花了一天時(shí)間,折騰安裝桌面再次安裝數(shù)據(jù)庫(kù)皇耗,系統(tǒng)都做了好幾次了南窗。最后決定嘗試靜默安裝數(shù)據(jù)庫(kù),終于嘗試兩次之后安裝成功廊宪。
只要嘗試矾瘾,不斷總結(jié),肯定會(huì)成功的箭启。原來,靜默安裝步驟也就比較簡(jiǎn)單蛉迹。主要還是在響應(yīng)文件的配置傅寡。其他的配置基本和桌面環(huán)境安裝一樣。
說明:為了安裝方便北救,最好使用Xshell類似的工具連接到centos終端
1荐操、創(chuàng)建用戶及組
groupadd oinstall #創(chuàng)建oinstall
groupadd dba # 創(chuàng)建dba組
useradd -g oinstall -G dba oracle #創(chuàng)建oracle用戶
passwd oracle # 修改oracle用戶的登錄密碼
[root@rainbow oracle]# id oracle #查看oracle用戶信息
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)
2、創(chuàng)建目錄
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
3珍策、安裝依賴包
依賴包是安裝oracle的必須托启,如果某些需要的依賴包沒有安裝上,安裝過程中會(huì)出現(xiàn)各種各樣的錯(cuò)誤攘宙。所以屯耸,依賴包安裝完整拐迁,安裝過程一般會(huì)比較順利。
直接執(zhí)行如下命令疗绣,安裝依賴包线召。
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
- 參考官方:http://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm#BHCCADGD
- The following or later version of packages for Oracle Linux 7, and Red Hat Enterprise Linux 7 must be installed:
binutils-2.23.52.0.1-12.el7.x86_64 compat-libcap1-1.10-3.el7.x86_64 compat-libstdc++-33-3.2.3-71.el7.i686 compat-libstdc++-33-3.2.3-71.el7.x86_64 gcc-4.8.2-3.el7.x86_64 gcc-c++-4.8.2-3.el7.x86_64 glibc-2.17-36.el7.i686 glibc-2.17-36.el7.x86_64 glibc-devel-2.17-36.el7.i686 glibc-devel-2.17-36.el7.x86_64 ksh libaio-0.3.109-9.el7.i686 libaio-0.3.109-9.el7.x86_64 libaio-devel-0.3.109-9.el7.i686 libaio-devel-0.3.109-9.el7.x86_64 libgcc-4.8.2-3.el7.i686 libgcc-4.8.2-3.el7.x86_64 libstdc++-4.8.2-3.el7.i686 libstdc++-4.8.2-3.el7.x86_64 libstdc++-devel-4.8.2-3.el7.i686 libstdc++-devel-4.8.2-3.el7.x86_64 libXi-1.7.2-1.el7.i686 libXi-1.7.2-1.el7.x86_64 libXtst-1.2.2-1.el7.i686 libXtst-1.2.2-1.el7.x86_64 make-3.82-19.el7.x86_64 sysstat-10.1.5-1.el7.x86_64 unixODBC-2.3.1-6.el7.x86_64 or later unixODBC-2.3.1-6.el7.i686 or later unixODBC-devel-2.3.1-6.el7.x86_64 or later unixODBC-devel-2.3.1-6.el7.i686 or later
4、更改hosts文件
hosts文件中多矮,要講主機(jī)名添加到配置文件中缓淹,及添加到127.0.0.1后面,如果沒有加塔逃,安裝過程中會(huì)出錯(cuò)讯壶。
- 首先查看主機(jī)名:使用hostname命令
[root@rainbow oracle]# hostname rainbow
- 主機(jī)名為rainbow,則把rainbow添加到/etc/hosts文件中:
[root@rainbow oracle]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 rainbow ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
- 將自己的主機(jī)名添加到文件中湾盗,保存退出鹏溯。
5、配置內(nèi)核參數(shù)/etc/sysctl.conf
編輯sysctl.conf文件
`[root@rainbow oracle]# vi /etc/sysctl.conf
加入如下配置
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
vm.hugetlb_shm_group = 1001 #此處與id oracle中的dba中一致讓內(nèi)核參數(shù)生效淹仑,執(zhí)行:/sbin/sysctl -p
6丙挽、修改用戶限制
vi /etc/secruity/limits.conf
#在末尾添加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
- 保存退出。
7匀借、修改 /etc/pam.d/login
vi /etc/pam.d/login
打開編輯此文件颜阐,在末尾加入如下配置:
session required /lib64/security/pam_limits.so session required pam_limits.so
說明:此處,要使用lib64,如果使用lib吓肋,則可能會(huì)出現(xiàn)無法登陸系統(tǒng)的情況凳怨,使用lib是在32位的情況下,如果是64位系統(tǒng)是鬼,則應(yīng)該使用lib64
- 保存退出肤舞。
8、修改系統(tǒng)配置文件/etc/profile
vi /etc/profile
加入如下配置:
if [[ $USER = "oracle" ]]; then if [[ $SHELL = "/bin/ksh" ]]; then ulimit -p16384 ulimit -n65536 else ulimit -u16384 -n 65536 fi fi
- 注意空格
- 保存退出
- 使其生效 source /etc/profile
9均蜜、修改oracle用戶環(huán)境變量
vi /home/oracle/.bash_profile
加入如下配置文件:
`#oracle
export TMP=/tmp;
export TMPDIR=$TMP;
export ORACLE_BASE=/u01/app/oracle;
export ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1;
export ORACLE_SID=orcl;
export ORACLE_TERM=xterm;
export PATH=/usr/sbin:$PATH;
export PATH=$ORACLE_HOME/bin:$PATH;
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;`
- 保存退出李剖。
- 使其生效:source /home/oracle/.bash_profile
10、上傳囤耳、解壓oracle安裝文件
使用sftp將安裝文件上傳至服務(wù)器篙顺。
- 解壓文件夾
[root@rainbow oracle]# unzip linuxamd64_12102_database_1of2.zip [root@rainbow oracle]# unzip linuxamd64_12102_database_2of2.zip
加壓之后,得到一個(gè)database的文件夾充择,將其移動(dòng)到/u01/app/oracle目錄下
mv database /u01/app/oracle - 對(duì)文件授權(quán)
chown -R oracle:oinstall /u01/app/oracle/database
11德玫、編輯、安裝數(shù)據(jù)庫(kù)響應(yīng)文件db_install.rsp
最終的安裝主要在與三個(gè)響應(yīng)文件的配置:dbca.rsp,netca.rsp,db_install.rsp椎麦,分別對(duì)應(yīng)于創(chuàng)建數(shù)據(jù)庫(kù)宰僧,創(chuàng)建監(jiān)聽,安裝數(shù)據(jù)庫(kù)观挎。三個(gè)文件的路徑在database/response 文件夾下琴儿。
為了防止出錯(cuò)段化,我們把三個(gè)響應(yīng)文件復(fù)制到oracle用戶路徑下,出錯(cuò)之后可以刪除再?gòu)?fù)制更改即可凤类。
在oracle用戶目錄下穗泵,創(chuàng)建一個(gè)etc文件夾
[oracle@rainbow /]$ mkdir /home/oracle/etc
復(fù)制響應(yīng)文件
[oracle@rainbow /]$ cp /u01/app/oracle/database/response/* /home/oracle/etc
[oracle@rainbow /]$ ls /home/oracle/etc/ dbca.rsp db_install.rsp netca.rsp
授權(quán)
[oracle@rainbow /]$ su - root [root@rainbow ~]# chmod 700 /home/oracle/etc/*.rsp
編輯安裝響應(yīng)文件
[root@rainbow ~]# vi /home/oracle/etc/db_install.rsp
找到如下的配置,將配置更改如下:
`oracle.install.option=INSTALL_DB_SWONLY // 安裝類型
ORACLE_HOSTNAME=rainbow // 主機(jī)名稱(hostname查詢)
UNIX_GROUP_NAME=oinstall // 安裝組
INVENTORY_LOCATION=/u01/app/oracle/oraInventory //INVENTORY目錄(不填就是默認(rèn)值)
SELECTED_LANGUAGES=en // 選擇語(yǔ)言
ORACLE_HOME=/u01/app/oracle/product/12.1.0/db_1 //oracle_home
ORACLE_BASE=/u01/app/oracle //oracle_base
oracle.install.db.InstallEdition=EE // oracle版本
oracle.install.db.isCustomInstall=false //自定義安裝谜疤,否佃延,使用默認(rèn)組件
oracle.install.db.DBA_GROUP=dba // dba用戶組
oracle.install.db.OPER_GROUP=dba // oper用戶組
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //數(shù)據(jù)庫(kù)類型
oracle.install.db.config.starterdb.globalDBName=orcl //globalDBName
oracle.install.db.config.starterdb.SID=orcl //SID
oracle.install.db.config.starterdb.password.ALL=admin123 //設(shè)定所有數(shù)據(jù)庫(kù)用戶使用同一個(gè)密碼
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false //(手動(dòng)寫了false)
DECLINE_SECURITY_UPDATES=true //設(shè)置安全更新(貌似是有bug,這個(gè)一定要選true夷磕,否則會(huì)無限提醒郵件地址有問題履肃,終止安裝。PS:不管地址對(duì)不對(duì))`
- 配置好后坐桩。保存退出尺棋。
- 開始安裝數(shù)據(jù)庫(kù)。切換到oracle用戶下
[root@rainbow ~]# su - oracle [oracle@rainbow database]$ /u01/app/oracle/database/runInstaller -silent -responseFile /home/oracle/etc/db_install.rsp
- 安裝過程如下绵跷,出現(xiàn)如下結(jié)果膘螟,說明安裝成功
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 500 MB. Actual 17997 MB Passed
Checking swap space: must be greater than 150 MB. Actual 2999 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-06-04_07-51-31PM. Please wait ...[oracle@rainbow database]$ [WARNING] [INS-32055] 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 does not meet some optional requirements.
CAUSE: Some of the optional prerequisites are not met. See logs for details. /tmp/OraInstall2017-06-04_07-51-31PM/installActions2017-06-04_07-51-31PM.log
ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2017-06-04_07-51-31PM/installActions2017-06-04_07-51-31PM.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/installActions2017-06-04_07-51-31PM.log
The installation of Oracle Database 12c was successful.
Please check '/u01/app/oracle/oraInventory/logs/silentInstall2017-06-04_07-51-31PM.log' for more details.
As a root user, execute the following script(s):
1. /u01/app/oracle/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/12.1.0/db_1/root.sh
Successfully Setup Software
- 使用root用戶登錄 ,分別執(zhí)行
/u01/app/oracle/oraInventory/orainstRoot.sh /u01/app/oracle/product/12.1.0/db_1/root.sh
- 到此碾局,數(shù)據(jù)庫(kù)已成功安裝上荆残。
12、配置净当、啟動(dòng)監(jiān)聽
監(jiān)聽器配置響應(yīng)文件為:/home/oracle/etc/netca.rsp,此文件使用默認(rèn)即可内斯。
執(zhí)行配置監(jiān)聽
[oracle@rainbow database]$ /u01/app/oracle/product/12.1.0/db_1/bin/netca -silent -responseFile /home/oracle/etc/netca.rsp
出現(xiàn)如下信息,說明監(jiān)聽配置成功像啼。
[oracle@rainbow database]$ /u01/app/oracle/product/12.1.0/db_1/bin/netca -silent -responseFile /home/oracle/etc/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/etc/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/oracle/product/12.1.0/db_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
[oracle@rainbow database]$啟動(dòng)監(jiān)聽
[oracle@rainbow database]$ lsnrctl start
- 查看監(jiān)聽狀態(tài)
[oracle@rainbow database]$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 04-JUN-2017 20:15:07
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 04-JUN-2017 20:08:08
Uptime 0 days 0 hr. 7 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/rainbow/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
- 重啟監(jiān)聽
[oracle@rainbow database]$ lsnrctl reload
13俘闯、靜默創(chuàng)建數(shù)據(jù)庫(kù)實(shí)例
編輯應(yīng)答文件
[oracle@rainbow database]$ vi /home/oracle/etc/dbca.rsp
將其更改如下:
[GENERAL] RESPONSEFILE_VERSION = "12.1.0" OPERATION_TYPE = "createDatabase" [CREATEDATABASE] GDBNAME = "dbsrv2" SID = "dbsrv2" TEMPLATENAME = "General_Purpose.dbc" CHARACTERSET = "AL32UTF8"
保存退出
執(zhí)行安裝數(shù)據(jù)庫(kù)實(shí)例
[oracle@rainbow database]$ /u01/app/oracle/product/12.1.0/db_1/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp
- 執(zhí)行安裝后,依次輸入sys和system的密碼忽冻,然后耐性等待真朗,會(huì)顯示安裝的進(jìn)度。
- 查看日志信息:
`[oracle@rainbow database]$ cat /u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log
Unique database identifier check passed.
/ has enough space. Required space is 6140 MB , available space is 12658 MB.
File Validations Successful.
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
DBCA_PROGRESS : 37%
Creating and starting Oracle instance
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
Completing Database Creation
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/orcl.
Database Information:
Global Database Name:orcl
System Identifier(SID):orcl
`
- 日志顯示甚颂,數(shù)據(jù)庫(kù)實(shí)例已經(jīng)成功創(chuàng)建蜜猾。
- 此時(shí),查看監(jiān)聽振诬,orcl數(shù)據(jù)庫(kù)實(shí)例已經(jīng)正常運(yùn)行。
`[oracle@rainbow database]$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 04-JUN-2017 20:54:52
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 04-JUN-2017 20:08:08
Uptime 0 days 0 hr. 46 min. 44 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/rainbow/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
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
`
14衍菱、數(shù)據(jù)庫(kù)的啟動(dòng)與停止
進(jìn)入到oracle安裝目錄的bin目錄下赶么,執(zhí)行 dbstop即可停止數(shù)據(jù)庫(kù)。
15脊串、開放端口(使用root用戶)
由于數(shù)據(jù)庫(kù)安裝了一般需要外網(wǎng)訪問辫呻,所以需要開放數(shù)據(jù)庫(kù)連接端口清钥。
[root@rainbow /]# firewall-cmd --zone=public --add-port=1521/tcp --permanent
success
[root@rainbow /]# firewall-cmd --zone=public --add-port=5500/tcp --permanent
success
[root@rainbow /]# firewall-cmd --reload
success
- 命令含義:
--zone #作用域
--add-port=80/tcp #添加端口,格式為:端口/通訊協(xié)議
--permanent #永久生效放闺,沒有此參數(shù)重啟后失效 - 重啟防火墻
firewall-cmd --reload
16祟昭、設(shè)置oracle數(shù)據(jù)庫(kù)隨系統(tǒng)開機(jī)自啟動(dòng)。
大多數(shù)情況下怖侦,我們都需要讓oracle數(shù)據(jù)庫(kù)隨服務(wù)器開機(jī)自啟動(dòng)篡悟。
- 1、編輯/etc/oratab
orcl:/u01/app/oracle/product/12.1.0/db_1:N - 將以上配置改為:
orcl:/u01/app/oracle/product/12.1.0/db_1:Y - 保存退出
- 2匾寝、編輯/etc/rc.d/rc.local
vi /etc/rc.d/rc.local - 加入如下配置:
su oracle -lc "/u01/app/oracle/product/12.1.0/db_1/bin/lsnrctl start"
su oracle -lc /u01/app/oracle/product/12.1.0/db_1/bin/dbstart - 保存退出
- 重啟系統(tǒng)搬葬,再次連接數(shù)據(jù)庫(kù),將正常連接上艳悔。
說明:本人水平有限急凰,有些地方可能不完善,望大家多多知道俺