Centos6.5 Oracle11g 靜默離線安裝完整版教程(無需圖形化界面)

1 修改/etc/security/limits.conf文件,修改用戶的SHELL的限制
[root@hqc-test-hdp3 database]# vim /etc/security/limits.conf

#@student - maxlogins 4
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
#End of file

2 修改/etc/pam.d/login 文件
[root@hqc-test-hdp3 database]# vim /etc/pam.d/login

-session optional pam_ck_connector.so

session required /lib/security/pam_limits.so
session required pam_limits.so

3 修改linux內核,修改/etc/sysctl.conf文件
[root@hqc-test-hdp3 database]# vim /etc/sysctl.conf

#Controls the maximum size of a message, in bytes
kernel.msgmax = 65536

#Controls the maximum shared segment size, in bytes
#kernel.shmmax = 68719476736

#Controls the maximum number of shared memory segments, in pages
#kernel.shmall = 4294967296

fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

4 輸入命令:sysctl -p,使/etc/sysctl.conf配置文件立即生效
[root@hqc-test-hdp3 ~]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
error: “net.bridge.bridge-nf-call-ip6tables” is an unknown key
error: “net.bridge.bridge-nf-call-iptables” is an unknown key
error: “net.bridge.bridge-nf-call-arptables” is an unknown key
kernel.msgmnb = 65536
kernel.msgmax = 65536
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

5 修改/etc/profile
[root@hqc-test-hdp3 ~]# vim /etc/profile

unset i
unset -f pathmunge
export JAVA_HOME=/opt/java
export PATH=PATH:PATH:JAVA_HOME/bin
export CLASSPATH=JAVAHOME/libexportCLASSPATH=JAVA_HOME/lib export CLASSPATH=CLASSPATH:$JAVA_HOME/jre/lib

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

6.創建用戶和組

6.1 創建用戶組oinstall、dba
[root@hqc-test-hdp3 ~]# groupadd oinstall
[root@hqc-test-hdp3 ~]# groupadd dba

6.2 創建oracle用戶,主組爲oinstall,副組dba
[root@hqc-test-hdp3 ~]# useradd -g oinstall -G dba -m oracle

6.3 設置用戶oracle密碼,輸入兩次密碼
[root@hqc-test-hdp3 ~]# passwd oracle
更改用戶 oracle 的密碼 。
新的 密碼:drguo@oracle123
重新輸入新的 密碼:drguo@oracle123
passwd: 所有的身份驗證令牌已經成功更新。

7 創建數據庫軟件目錄和數據文件存放目錄
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/oracle
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/oradata
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/oraInventory
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/fast_recovery_area
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/oracle/product

8 修改目錄權限,更改目錄屬主爲Oracle用戶所有
[root@hqc-test-hdp3 ~]# chown -R oracle:oinstall /home/oracle/app

9 配置oracle用戶的環境變量

9.1 用命令su - oracle切換到oracle用戶且其家目錄下
[root@hqc-test-hdp3 ~]# su - oracle
[oracle@hqc-test-hdp3 ~]$

9.2 修改.bash_profile
[oracle@hqc-test-hdp3 ~]$ vim .bash_profile
#.bash_profile

#Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

#User specific environment and startup programs

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

10 解壓安裝文件
oracle11g安裝文件下載地址 https://download.csdn.net/download/dr_guo/11459608
[root@hqc-test-hdp3 database]# unzip linux.x64_11gR2_database_1of2.zip
[root@hqc-test-hdp3 database]# unzip linux.x64_11gR2_database_2of2.zip

11 創建/etc/oraInst.loc文件,否則安裝時會報錯:
SEVERE: [FATAL] [INS-32038] The operating system group specified for central inventory (oraInventory) ownership is invalid.

[oracle@hqc-test-hdp3 ~]$ su
密碼:
[root@hqc-test-hdp3 oracle]# vim /etc/oraInst.loc

inventory_loc=/home/oracle/app/oraInventory
inst_group=oinstall

12 安裝未安裝的package

可以訪問外網:
[root@hqc-test-hdp3 oracle]# yum install binutils compat-libstdc+±33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc+±devel make pdksh sysstat unixODBC unixODBC-devel

不能訪問外網:
依賴包下載地址 https://download.csdn.net/download/dr_guo/11459600
[root@hqc-test-hdp3 data]# cd package/
[root@hqc-test-hdp3 package]# rpm -ivh *.rpm

13 準備responseFile文件
從Oracle軟件中獲取文件模板

[root@hqc-test-hdp3 data]# cd database/response/
[root@hqc-test-hdp3 response]# ls
dbca.rsp db_install.rsp netca.rsp

其中database是Oracle軟件解壓後生成的目錄。可見在response目錄下有三個模板,其中dbca.rsp是用來創建數據庫的。db_install.rsp是用來安裝Oracle軟件的。netca.rsp是用來創建監聽器的。當然也可在db_install.rsp中直接創建數據庫。在這裏,爲求方便,我們選擇db_install.rsp模板一併安裝軟件,創建數據庫。

14 編輯responseFile文件

[root@hqc-test-hdp3 response]# vim db_install.rsp

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_AND_CONFIG
ORACLE_HOSTNAME=oracle
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/oracle/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/home/oracle/app
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=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=400
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=1Password
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=xxxx@xxxx.com
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/home/oracle/app/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/home/oracle/app/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
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=

15 改用oracle用戶登錄,靜默安裝

[root@hqc-test-hdp3 response]# su oracle
[oracle@hqc-test-hdp3 response]$ cd /data/database/
[oracle@hqc-test-hdp3 database]$ ./runInstaller -silent -ignorePrereq -responseFile /data/database/response/db_install.rsp

正在啓動 Oracle Universal Installer…

檢查臨時空間: 必須大於 120 MB。 實際爲 39013 MB 通過
檢查交換空間: 必須大於 150 MB。 實際爲 3967 MB 通過
準備從以下地址啓動 Oracle Universal Installer /tmp/OraInstall2019-08-01_12-38-52PM. 請稍候…[oracle@hqc-test-hdp3 database]$ 可以在以下位置找到本次安裝會話的日誌:
/home/oracle/app/oraInventory/logs/installActions2019-08-01_12-38-52PM.log

查看日誌

[oracle@hqc-test-hdp3 database]$ tail -f /home/oracle/app/oraInventory/logs/installActions2019-08-01_12-38-52PM.log
信息: Validating state
警告: Validation disabled for the state finish
信息: Completed validating state
信息: Terminating all background operations
信息: Terminated all background operations
信息: Successfully executed the flow in SILENT mode
信息: Finding the most appropriate exit status for the current application
信息: Exit Status is 0
信息: Shutdown Oracle Database 11g 發行版 2 安裝程序
信息: Unloading Setup Driver

如果在日誌文件中看到如上的內容,證明安裝已經完成。

16 啓動數據庫
[oracle@hqc-test-hdp3 database]$ source /home/oracle/.bash_profile
[oracle@hqc-test-hdp3 package]$ sqlplus / as sysdba
sqlplus: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory
報錯了,切換到root用戶看一下有沒有這個文件
[root@hqc-test-hdp3 lib]# find / -name libclntsh.so.11.1
/home/oracle/app/oracle/product/11.2.0/dbhome_1/inventory/Scripts/ext/lib/libclntsh.so.11.1
/home/oracle/app/oracle/product/11.2.0/dbhome_1/inventory/backup/2019-08-01_02-05-05PM/Scripts/ext/lib/libclntsh.so.11.1
/data/database/stage/ext/lib/libclntsh.so.11.1
有的話拷到oracle目錄下
[root@hqc-test-hdp3 lib]# cp /home/oracle/app/oracle/product/11.2.0/dbhome_1/inventory/Scripts/ext/lib/libclntsh.so.11.1 /home/oracle/app/oracle/product/11.2.0/dbhome_1/lib/
[root@hqc-test-hdp3 lib]# cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/lib
修改權限或改所有者,千萬別忘了!
[root@hqc-test-hdp3 lib]# chmod 777 libclntsh.so.11.1

沒有的話,點此下載:https://download.csdn.net/download/dr_guo/11460107

切換到oracle用戶
[oracle@hqc-test-hdp3 package]$ sqlplus / as sysdba
sqlplus: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory
如果還是報錯,再切換到root用戶,在 /etc/ld.so.conf 加入 ORCALEHOME/lib[oracle@hqctesthdp3package]ORCALE_HOME/lib 目錄 [oracle@hqc-test-hdp3 package] su
密碼:
[root@hqc-test-hdp3 lib]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/home/oracle/app/oracle/product/11.2.0/dbhome_1/lib

[oracle@hqc-test-hdp3 database]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 1 14:58:04 2019

Copyright © 1982, 2009, Oracle. All rights reserved.

ERROR:
ORA-12547: TNS:lost contact

報另一個錯ORA-12547: TNS:lost contact
修改權限

[root@hqc-test-hdp3 ~]# cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/
[root@hqc-test-hdp3 dbhome_1]# cd bin/
[root@hqc-test-hdp3 bin]# chmod 6751 oracle

檢查ORACLEHOME/bin/oracleORACLE_HOME/bin/oracle和ORACLE_HOME/rdbms/lib/config.o的文件大小是否爲0
[root@hqc-test-hdp3 dbhome_1]# ll rdbms/lib/config.o
-rw-r–r-- 1 oracle oinstall 0 8月 1 14:06 rdbms/lib/config.o
[root@hqc-test-hdp3 dbhome_1]# ll bin/oracle
-rwsr-s–x 1 oracle oinstall 0 8月 15 2009 bin/oracle

如果大小爲0,那麼需要先備份config.o文件,然後重新編譯oracle軟件:
[root@hqc-test-hdp3 dbhome_1]# mv rdbms/lib/config.o rdbms/lib/config.o.bak
[root@hqc-test-hdp3 dbhome_1]# su oracle
[oracle@hqc-test-hdp3 dbhome_1]$ bin/relink all

17 大功告成
[root@hqc-test-hdp3 lib]# sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 1 15:42:39 2019

Copyright © 1982, 2009, Oracle. All rights reserved.

Connected to an idle instance.

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

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