1. 從官網(wǎng)下載Oracle安裝包到CentOS中, 共有兩個壓縮包:
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
2. 添加用戶組和用戶
groupadd -g oinstall #添加oinstall組
groupadd -g dba #添加dba組
useradd -g oinstall -G dba oracle #添加用戶oracle
passwd oracle #輸入oracle用戶的密碼
3. 在/etc/hosts文件中添加主機IP跟主機名
192.168.1.1 gongxm
4.關(guān)閉selinux ,編輯 /etc/selinux/config文件,設(shè)置SELINUX= enforcing 為SELINUX=disabled
5.關(guān)閉防火墻
查看防火墻狀態(tài):systemctl status firewalld
停止防火墻:systemctl stop firewalld
關(guān)閉自啟動防火墻服務(wù):systemctl disable firewalld
6. 修改內(nèi)核參數(shù)
編輯 /etc/sysctl.conf
添加以下設(shè)置:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
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
再執(zhí)行下面的命令使參數(shù)生效:
sysctl -p
7.修改用戶的限制文件
編輯 /etc/security/limits.conf
添加以下配置:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
8.修改/etc/pam.d/login文件
添加以下內(nèi)容:
session required /lib64/security/pam_limits.so
session required pam_limits.so
9.修改/etc/profile文件
添加以下內(nèi)容:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
10.創(chuàng)建安裝目錄蔓搞、修改文件權(quán)限
mkdir -p /app/oracle/product/11.2.0
mkdir /app/oracle/oradata
mkdir /app/oracle/inventory
mkdir /app/oracle/fast_recovery_area
chown -R oracle:oinstall /app/oracle
chmod -R 775 /app/oracle
11.安裝Oracle 11g依賴包
yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel
12.安裝unzip命令
yum -y unzip
13.解壓兩個文件:
unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
14.切換到oracle賬號登陸, 設(shè)置環(huán)境變量
編輯.bash_profile文件:
vim .bash_profile
添加:
ORACLE_BASE=/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
15.切換到root賬號, 編輯靜默安裝響應(yīng)文件
進入oracle安裝包解壓后的目錄,編輯 .../database/response/db_install.rsp文件:
vim db_install.rsp
修改以下參數(shù):
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=gongxm
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/app/oracle/product/11.2.0
ORACLE_BASE=/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
16.根據(jù)響應(yīng)文件安裝oracle 11g
./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /home/oracle/database/response/db_install.rsp
開始Oracle在后臺靜默安裝周蹭。安裝過程中触创,如果提示[WARNING]不必理會颇蜡,此時安裝程序仍在后臺進行产上,如果出現(xiàn)[FATAL]撑蒜,則安裝程序已經(jīng)停止了歹啼。
此時再打開另外一個終端選項卡,輸入提示的會話日志目錄:
tail –f /app/oracle/inventory/logs/installActions2018-05-18_11-27-36PM.log
看到日志文件會持續(xù)輸出安裝信息沒有輸入異常信息座菠,則表明安裝過程正常狸眼。
17. 如果提示以下內(nèi)容, 說明需要分配交換空間
swap space: 0 MB available, 150 MB required.
可以參考: 這里
18.提示安裝完成后, 切換到root賬號
執(zhí)行以下命令:
sh /app/oracle/inventory/orainstRoot.sh
sh /app/oracle/product/11.2.0/root.sh
注意:
執(zhí)行第一個命令時, 會提示:
Changing permissions of /app/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /app/oracle/inventory to oinstall.
這是正常的!!!
19.用oracle用戶登錄配置監(jiān)聽
netca -silent -responseFile /home/oracle/database/response/netca.rsp
需要配置DISPLAY變量,配完之后重新netca:
export DISPLAY=localhost:0.0
成功運行后浴滴,會在/app/oracle/product/11.2.0/network/admin/ 中生成listener.ora和sqlnet.ora兩個文件
20.如果出現(xiàn)以下異常:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/app/oracle/product/11.2.0/jdk/jre/lib/amd64/xawt/libmawt.so:
libXext.so.6: cannot open shared object file: No such file or directory
解決方案:
安裝以下內(nèi)容:
#yum install libXp
#yum install libXt
#yum install libXtst
21.切換到root用戶拓萌,編輯 /home/oracle/database/response/dbca.rsp
修改以下參數(shù):
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/app/oracle/oradata
RECOVERYAREADESTINATION=/app/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "1638"
22.切換到oracle賬號進行靜默配置
dbca -silent -responseFile /home/oracle/database/response/dbca.rsp
這時會開始生成數(shù)據(jù), 稍等幾分鐘升略,會有進度的提示
23.完成建庫后微王,檢查安裝是否成功
[oracle@gongxm database]$ sqlplus / as sysdba //以SYSDBA這個角色登陸SQLPLUS
SQL> startup //啟動數(shù)據(jù)庫
SQL> select count(*) from tabs; //查詢tabs表的字段數(shù)量,
// 如果有內(nèi)容品嚣,表示連接數(shù)據(jù)庫正常
24.查看監(jiān)聽狀態(tài)
lsnrctl status
如果提示以下內(nèi)容:
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-MAY-2018 09:03:40
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 19-MAY-2018 08:36:13
Uptime 0 days 0 hr. 27 min. 27 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File /app/oracle/diag/tnslsnr/gongxm/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=gongxm)(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
表示監(jiān)聽正常炕倘!