cent os6.5靜默安裝oracle
阿新 • • 發佈:2019-01-02
前言:
最近需要在CentOs6.5下安裝Oracle環境,第一次接觸在Linux下安裝Oracle資料庫,查詢了網上好多資料,安裝期間遇到不少問題,弄得焦頭爛額,好在最後安裝成功了,這裡將我自己總結的安裝步驟寫出來,希望可以幫助到像我一樣初次接觸Oracle安裝的同仁吧! 參考相關文章: CentOS 6.5 X64上64位Oracle11gR2 靜默安裝,靜默設定監聽,靜默建庫親自實踐記錄 此文章具體出處不知,但在此謝過作者!1.安裝環境
作業系統:CentOs6.5 資料庫版本: Oracle 11G R22.準備工作(安裝包環境)
2.1關閉SELINUX
這步驟參考其他文章設定,具體目的未知,去掉後也不知是否可行,還望各位指教。vim /etc/selinux/config
設定 SELINUX=disabled
#setenforce 0 //關閉selinux
#service iptables stop //臨時關閉防火牆
2.2 必須安裝的包環境
yum install -y binutils* yum install -y compat-libstdc* yum install -y elfutils-libelf* yum install -y gcc* yum install -y glibc* yum install -y ksh* yum install -y libaio* yum install -y libgcc* yum install -y libstdc* yum install -y make* yum install -y sysstat* yum install libXp* -y yum install -y glibc-kernheaders
3.新增Oracle使用者以及相關組
groupadd -g 5000 oinstall
groupadd -g 501 dba
useradd -g oinstall -G dba oracle
passwd oracle //修改密碼
4.修改核心引數檔案配置
#vim /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 = 1048586
若將要新增的引數名已存在請保證其值不小於待新增的值。
# /sbin/sysctl -p 使引數生效
5.修改使用者的限制檔案
vim /etc/security/limits.conf
在裡面加入
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle hard stack 10240
6.設定安裝目錄和設定檔案許可權
//資料庫系統安裝目錄
mkdir /oracle
//資料庫資料安裝目錄
mkdir /oracle/oradata
//資料備份目錄
mkdir /oracle/oradata_back
//清單目錄
mkdir /oraInventory
chown -R oracle:oinstall /oracle /oraInventory /oracle/oradata
chmod -R 775 /oracle /oraInventory /oracle/oradata
配置環境變數
vim /home/oracle/.bash_profile
新增
export ORACLE_BASE=/oracle
exportORACLE_HOME=/oracle/product/11.2.4/db_1
export ORACLE_SID=JCZH
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_LANG=american_america.AL32UTF8
配置日誌操作使用者組 建立/etc/oraInst.loc
vi /etc/oraInst.loc
加入
inventory_loc=/oraInventory
inst_group=oinstall,dba
儲存後執行
chmod 777 /etc/oraInst.loc
chown -R oralce:oinstall /etc/oraInst.loc
7.靜默安裝響應檔案
su - oracle
cp -R /oracle/database/response /home/oracle //複製一份模板
cd /home/oracle/response
mv db_install.rsp db_install_swonly.rsp
vim db_install_swonly.rsp //開始修改這個安裝響應檔案 需要設定的選項如下:
oracle.install.option=INSTALL_DB_SWONLY //只安裝軟體,不安裝啟動資料庫
ORACLE_HOSTNAME=oracle11gcentos6.dlxg.gov.cn//通過hostname命令獲得
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION= /oraInventory //清單目錄
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME= /oracle/product/11.2.4/db_1
ORACLE_BASE= /oracle
oracle.install.db.InstallEdition=EE //安裝的Oracle版本
oracle.install.db.isCustomInstall=false //是否自定義安裝,若未找到此選項無需安裝
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=JCZHSTANDBY全域性資料庫名
oracle.install.db.config.starterdb.SID=JCZH例項名稱
oracle.install.db.config.starterdb.password.ALL=oracle是否所有的賬戶都使用同一個密碼
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true //一定要設定為true
若安裝時提示主機名找不到 在/etc/hosts 中 新增自定義的主機名
8. 根據響應檔案安裝Oracle
cd /opt/database 此目錄為Oracle安裝包解壓後的存放路徑
$./runInstaller -silent -responseFile/home/oracle/response/db_install_swonly.rsp -ignorePrereq
安裝過程中,如果提示[WARNING]不必理會,此時安裝程式仍在進行,如果出現[FATAL], 則安裝程式已經停止了。
開啟另一個終端,執行#tail -100f /home/oracle/inventory/logs/installActions......log 此檔案替換為提示彈出的日誌路徑
可以實時跟蹤檢視安裝日誌,瞭解安裝的進度。
當出現:以下配置指令碼需要以"root" 使用者的身份執行。/oracle/inventory/orainstRoot.sh
/oracle/11.2.4/root.sh
要執行配置指令碼, 請執行以下操作:
1. 開啟一個終端視窗 2.
2. 以 "root" 身份登入 3. 執行指令碼 4. 返回此視窗並按 "Enter" 鍵繼續
3. Successfully Setup Software. 表示安裝成功了。
4. 按照其提示操作。 $exit //退回到root
如提示沒有臨時資料夾許可權 給tmp/下以CVC開頭的資料夾下的指令碼檔案賦予執行許可權
9.靜默配置監聽
靜默配置監聽 netca /silent /responsefile /home/oracle/response/netca.rsp
正在對命令列引數進行語法分析:
引數"silent" = true
引數"responsefile" = /home/oracle/response/netca.rsp
完成對命令列引數進行語法分析。
Oracle Net Services 配置: 完成概要檔案配置。
Oracle Net 監聽程式啟動:
正在執行監聽程式控制: /oracle/product/11.2.4/bin/lsnrctl start LISTENER 監聽程式控制完成。
監聽程式已成功啟動。 監聽程式配置完成。
成功完成 Oracle Net Services 配置。
退出程式碼是0
成功執行後,在/oracle/product/11.2.4/network/admin目錄下生成sqlnet.ora和listener.ora兩個文 件。
通過netstat -tlnp 命令,看到 tcp 0 0 :::1521 :::* LISTEN 5477/tnslsnr 說明監聽器已經在1521埠上開始工作了。
10.靜默建立新庫(同時也建立一個對應的例項)
cd /home/oracle/response
mv dbca.rsp dbca_hello.rsp //改名為dbca_資料庫名.rsp
如果只安裝資料庫軟體 不安裝資料庫時不需要執行這步(比如 dataguard備庫的資料庫搭建) 修改/home/oracle/response/dbca_hello.rsp,
設定如下:
OPERATION_TYPE = "createDatabase"
GDBNAME = "hello.dlxg.gov.cn" //資料庫的名字
SID = "hello" //對應的例項名字
TEMPLATENAME = "General_Purpose.dbc" //建庫用的模板檔案
SYSPASSWORD = "gnotsms" //SYS管理員密碼
SYSTEMPASSWORD = "gnotsms" //SYSTEM管理員密碼
DATAFILEDESTINATION = /oracle/oradata //資料檔案存放目錄
RECOVERYAREADESTINATION=/oracle/oradata_back //恢復資料存放目錄
CHARACTERSET = "AL32UTF8" //字符集,重要!!! 建庫後一般不能更改,所以建庫前要確 定清楚。
靜默建庫命令如下 $dbca -silent -responseFile /home/oracle/response/dbca_hello.rsp
執行後會實時顯示進度。
建庫後例項檢查: ps -ef |grep ora_ | grep -v grep | wc -l
21
ps-ef | grep ora_ | grep -v grep
...
檢視監聽狀態 lsnrctl status
此處資料庫以安裝完畢。接下來配置快捷啟動資訊與開機自啟動資料庫步驟
11.修改oracle啟動配置檔案
$vim /etc/oratab
hello:/opt/oracle/11.2.0:Y
這樣就可以通過dbstart 啟動此例項,也可以通過dbshut關閉此例項了。
$ dbshut /opt/oracle/11.2.0/
Processing Database instance "hello": log file /opt/oracle/11.2.0/shutdown.log
此時所有oracle的程序關閉,監聽器也停止。
$dbstart /opt/oracle/11.2.0/
Processing Database instance "hello": log file /opt/oracle/11.2.0/startup.log
此時監聽器工作,hello例項執行,再次檢視監聽器狀態。
$ lsnrctl status
12.開機自動啟動資料庫
vi /etc/init.d/oracle 建立oracle檔案
開頭的三行註釋不可缺少
#!/bin/sh
# chkconfig:345 99 10
# description: oracle auto start-stop script
ORA_HOME=/oracle/product/11.2.4/db_1
ORA_OWNER=oracle
if[! -f $ORA_HOME/bin/dbstart]
then
echo "Oracle startup:cannot start"
exit
fi
case "$1" in 'start')
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
touch /var/locl/subsys/oracle
;;
'stop')
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
rm -f /var/lock/subsys/oracle
;;
Esac
設定許可權,設定開機執行此檔案
chmod 750 /etc/init.d/oracle
chkconfig --add oracle
chkconfig oracle on
13.設定防火牆
編輯
vi /etc/sysconfig/iptables 檔案,
增加下列記錄
-A INPUT -p tcp -m state --state N EW -m tcp --dport 1521 -j ACCEPT
儲存新增的規則,以免下次重啟機器後,配置規則失效:
service iptables save
重啟iptables服務:
service iptables restart