注意:以下命令使用 root 用戶(hù)操作
安裝依賴(lài)包
主要思路為配置 oracle yum 倉(cāng)庫(kù),直接使用 yum 命令來(lái)安裝依賴(lài)包,避免手工逐個(gè)的安裝依賴(lài)包。
配置 yum 倉(cāng)庫(kù)以下載 orcale 依賴(lài)包
注意:這里是CentOS 6.X 的 oracle 依賴(lài)倉(cāng)庫(kù),其他版本不同的。
導(dǎo)入 GPG Keys
wget https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle --no-check-certificate
安裝 oracle 依賴(lài)
yum install oracle-rdbms-server-11gR2-preinstall
設(shè)置 hostname
打開(kāi)文件 /etc/sysconfig/network,并修改 HOSTNAME。
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oracle.buzheng.org
打開(kāi) /etc/host, 添加服務(wù)器本機(jī)IP地址 指向到 HOSTNAME
vi /etc/hosts
192.168.1.15 oracle.buzheng.org oracle
oracle 用戶(hù)設(shè)置
當(dāng)安裝好 oracle 依賴(lài)之后, oracle 用戶(hù)已經(jīng)創(chuàng)建好了,不需要手工創(chuàng)建 oracle 用戶(hù)和相關(guān)的用戶(hù)組。
修改 oracle 用戶(hù)密碼
[root@oracle ~]# passwd oracle
更改用戶(hù) oracle 的密碼 。
新的 密碼:
重新輸入新的 密碼:
passwd: 所有的身份驗(yàn)證令牌已經(jīng)成功更新。
修改系統(tǒng)限制
在文件 /etc/security/limits.d/90-nproc.conf 中添加如下的最后一行
[root@oracle ~]# vi /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 1024
root soft nproc unlimited
* - nproc 16384
修改 SELinux 為 permissive 模式
修改文件 /etc/selinux/config 如下所示
[root@oracle ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
重啟機(jī)器
創(chuàng)建 oracle 安裝目錄,并授權(quán)
[root@oracle]# mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
[root@oracle]# chown -R oracle:oinstall /u01
[root@oracle]# chmod -R 775 /u01
授權(quán) oracle 用戶(hù)能夠訪(fǎng)問(wèn) X Server
[root@oracle]# xhost + # 要在主機(jī)上運(yùn)行,不能是遠(yuǎn)程 shell
注意:以下命令使用 oracle 用戶(hù)操作
配置 oracle 安裝環(huán)境變量
切換到 oracle 用戶(hù), 編輯 .bash_profile 文件, 如下所示, 添加環(huán)境配置。
[root@oracle]# su oracle
[oracle@oracle]# vi .bash_profile
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=oracle.buzheng.org; export ORACLE_HOSTNAME
ORACLE_UNQNAME=orcl; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH export PATH
下載 oracle 安裝文件,解壓縮后安裝
下載 oracle
打開(kāi) oracle 下載頁(yè)面,http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html , 下載下面兩個(gè)文件到 /home/oracle
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
解壓縮文件并運(yùn)行
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
cd database
./runInstaller
若為中文系統(tǒng),安裝界面會(huì)出現(xiàn)中文亂碼,需要先將環(huán)境變?yōu)橛⑽模诎惭b
export LANG=en_US
./runInstaller
沒(méi)有截圖, 安裝步驟大致包括以下幾步:
- Create and configure a database
- Server Class
- Single instance database installation
- Advanced install
- Language: English
- Enterprise Edition
- database type: General Purpose / Transaction Processing
- Memory: Enable Automatic Memory Management
- Character sets: Use Unicode(AL32UTF8)
圖性界面安裝最后會(huì)提示以ROOT 執(zhí)行下面兩個(gè)腳本
[root@oracle ~]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@oracle ~]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
出現(xiàn)的問(wèn)題
1, 當(dāng)環(huán)境變量中的 ORACLE_SID 與 安裝時(shí)實(shí)際配置不一致時(shí),會(huì)導(dǎo)致 startup 出錯(cuò),出錯(cuò)信息如下:
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initDB11G.ora'
2, 如果遠(yuǎn)程客戶(hù)端連接是報(bào)錯(cuò):ora-12514 tns 監(jiān)聽(tīng)程序當(dāng)前無(wú)法識(shí)別連接描述符中請(qǐng)求的服務(wù),則需要配置 listener.ora,添加如下節(jié)點(diǎn):
SID_LIST_LISTENER =
(SID_LIST=
(SID_DESC =
(SID_NAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)
好了,到此已經(jīng)安裝完成,通過(guò)訪(fǎng)問(wèn) web 管理界面可驗(yàn)證。下面步驟也很重要,請(qǐng)繼續(xù)。
注意:以下命令使用 root 用戶(hù)操作
配置防火墻規(guī)則,開(kāi)放偵聽(tīng)端口
將 1521(你配置的 oracle 偵聽(tīng)端口) 端口添加到防火墻規(guī)則,以便遠(yuǎn)程用戶(hù)能順利的訪(fǎng)問(wèn)到 oracle 服務(wù)。
iptables -I INPUT 4 -m state --state NEW -p tcp --dport 1521 -j ACCEPT
service iptables save
service iptables reload
設(shè)置 oracle 自動(dòng)啟動(dòng)
完成 oracle 安裝后,我們可以通過(guò)命令啟動(dòng)停止數(shù)據(jù)庫(kù),但是當(dāng)機(jī)器重啟時(shí)并不能隨機(jī)器啟動(dòng),這也給我們帶來(lái)了一些不便,下面記錄了,如何將 oralce 加入服務(wù)中,并隨機(jī)機(jī)器啟動(dòng)。
修改配置文件 /etc/oratab
修改 /etc/oratab 的最后一行的最后一個(gè)字符,將 N 修改為 Y。此舉主要是為了使 oracle 的 dbstart 命令能在系統(tǒng)啟動(dòng)時(shí)能運(yùn)行。如下所示:
[root@oracle ~]# vi /etc/oratab
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
orcl:/u01/app/oracle/product/11.2.0/dbhome_1:Y
創(chuàng)建 /etc/init.d/oracle
在 /etc/init.d/下創(chuàng)建文件 oracle,此為 oracle 自啟動(dòng)腳本。內(nèi)容如下:
#!/bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g R2 AutoRun Servimces
# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f "$ORACLE_HOME/bin/dbstart" ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# parameter: start, stop, restart
case "$1" in
start)
# Oracle listener and instance startup
su $ORA_OWNR -s /bin/bash $ORACLE_HOME/bin/dbstart $ORACLE_HOME
echo "Oracle Start Succesful!OK."
;;
stop)
# Oracle listener and instance shutdown
su $ORA_OWNR -s /bin/bash $ORACLE_HOME/bin/dbshut $ORACLE_HOME
echo "Oracle Stop Succesful!OK."
;;
restart)
$0 stop
$0 start
;;
*)
echo $"Usage: `basename $0` {start|stop|restart}"
exit 1
esac
exit 0
賦予啟動(dòng)腳本執(zhí)行權(quán)限并鏈接好:
# chmod 750 /etc/init.d/oracle
# ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle
# ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
啟動(dòng)腳本設(shè)置好了之后,可以使用 service 命令來(lái)啟動(dòng)停止 oracle 了,這時(shí)候 oracle 已經(jīng)是系統(tǒng)服務(wù)了。
service oracle start
service oracle stop
service oracle restart
設(shè)置 oracle 服務(wù)為自啟動(dòng)
# chkconfig --add oracle
# chkconfig --level 345 oracle on
總結(jié)
好了,重啟機(jī)器試試吧。以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問(wèn)大家可以留言交流。
您可能感興趣的文章:- centos7下安裝oracle11gR2的詳細(xì)步驟
- Linux下安裝Oracle(CentOS-Oracle 12c)的方法
- CentOS命令行下裝oracle 12c的方法(命令行模式安裝)
- CentOS系統(tǒng)上安裝配置Oracle數(shù)據(jù)庫(kù)的詳細(xì)教程
- CentOS下PHP安裝Oracle擴(kuò)展
- CentOS6.2上安裝Oracle10g報(bào)ins_emdb.mk錯(cuò)誤處理方法
- CentOS 6.3下安裝部署Oracle服務(wù)器圖文教程
- Linux+php+apache+oracle環(huán)境搭建之CentOS下安裝Oracle數(shù)據(jù)庫(kù)
- Linux+php+apache+oracle環(huán)境搭建之CentOS下源碼編譯安裝PHP
- centos下Oracle11G圖文安裝教程