CentOS 5.3 安裝配置Oracle 10g 手動啟動及自啟動服務

來源:互聯網
上載者:User

CentOS 5.3 安裝配置Oracle 10g 手動啟動及自啟動服務

下面是文字描述Oracle 10g,CentOS 5.3 上安裝過程

1,下載解壓10201_database_linux32.zip到database檔案,記憶體,swap是否合適請多查其他文章。

2,進入database目錄,可以查看welcom.html文檔裡面的 Documentation的Quick Installation GuideQuick
這裡就是參考上面的文檔。

3,檢查依賴檔案,文檔裡面有,請自己查看,沒有的yum一下,實在沒有的就不用去管他,安裝時的圖形介面需要libXp,這裡先yum -y install libXp

4,建立使用者和組群,如果原先就有,照做下面命令也沒衝突
$su -
#groupadd oinstall
#groupadd dba
#useradd -g oinstall -G dba oracle
#passwd oracle

5,安裝需要修改的核心參數
執行下面命令的時候,先自己對比一下文檔裡面的要求,不符合的才改。
#vi /etc/sysctl.conf
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=262144

修改完了
/sbin/sysctl -p
一下

6,安全限制
#vi /etc/security/limits.conf 末尾加上

#use for oracle
oracle soft    nproc   2047
oracle hard    nproc   16384
oracle soft    nofile 1024
oracle hard    nofile 65536

#vi /etc/pam.d/login 末尾加上

#use for oracle
session required /lib/security/pam_limits.so

#vi /etc/profile 末尾加上

#use for oracle
if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
        ulimit -p 16384
        ulimit -n 65536
    else
        ulimit -u 16384 -n 65536
    fi
    fi

7,修改.bash_profile 我這oracle安裝在/home/oracle/10G目錄,www.bkjia.com如果要安裝到/oracle/10G目錄,請用root使用者mkdir /oracle;mkdir /oracle/10G; chown -R oracle:oinstall /oracle
並對下面設定檔對ORACLE_BASE=/oracle做一下修改就是。

su - oracle
cd
vi .bash_profile 自己對照修改為

umask 022
ORACLE_BASE=/home/oracle
ORACLE_HOME=$ORACLE_BASE/10G
ORACLE_SID=orcl
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

export ORACLE_BASE
export ORACLE_HOME
export ORACLE_SID
export PATH

vi完後source .bash_profile一下

8,修改發行版本,centos是沒有通過oracle認證的,不過不修改好像也能通過,這個隨大家。
vi /etc/RedHat-release
將CentOS release 5.3 (Final) 修改成redhat-4
安裝完了再改回來就是

9,安裝oracle

su - oracle
cd到oracle 的 database安裝目錄

export LANG=en.UTF8
這條命令修改語言環境,是為瞭解決下面顯示問題
避免出現zh.GB2312的警告和亂碼

./runInstaller 或者sh runInstaller

到這就是圖形安裝介面,安裝過程中,如果配置通不過,oracle是不讓安裝的,針對錯誤對照官方文檔重先修改一下就是。安裝過程中會要求你用root使用者執行命令root.sh和orainstRoot.sh,自己照著提示的完整路徑做就是。

安裝完成oracle是預設啟動了的,後你就可以訪問下面的地址,請把下面yourIP替換成你的主機名稱 或者127.0.0.1 或者你的IP,推薦127.0.0.1
iSQL*Plus URL:
http://yourIP:5560/isqlplus

iSQL*Plus DBA URL:
http://yourIP:5560/isqlplus/dba

Enterprise Manager 10g Database Control URL:
http://yourIP:1158/em

8,oracle預設是不自啟動的,一旦重啟,oracle就需要手動啟動:

su - oracle

啟動資料庫 ,密碼就是安裝時你填的密碼
sqlpuls /nolog

sql> conn sys/密碼 as sysdbasql> startup
sql> exit

sqlpuls具體路徑為$ORACLE_HOME/bin/sqlplus
啟動監聽
lsnrctl start

lsnrctl具體路徑為$ORACLE_HOME/bin/lsnrctl

上面只是啟動了資料庫和監聽基本服務
要想啟動上面3個帶網頁地址訪問的服務,操作如下:

isqlplusctl start 啟動iSQL*Plus,可以訪問http://127.0.0.1:5560/isqlplus
或者http://127.0.0.1:5560/isqlplus/dba 這兩個地址,如果能開啟,則確定iSQL*Plus已經啟動
isqlplusctl具體路徑為$ORACLE_HOME/bin/isqlplusctl

emctl start dbconsole 啟動Enterprise Manager 10g Database Control
可以訪問http://127.0.0.1:1158/em能開啟,則確定Enterprise Manager 10g Database Control已經啟動。這個服務啟動有點慢恩,慢慢等恩。
emctl具體路徑為$ORACLE_HOME/bin/emctl

當然,oracle自己也有啟動指令碼dbstart和關閉指令碼dbshut
先修改vi /etc/oratab
將最後一行N變成Y
然後修該$ORACLE_HOME/bin/dbstart內容

ORACLE_HOME_LISTNER=$ORACLE_HOME

su - oracle

dbstart 就可以啟動oracle了,這個也只是啟動oracle資料庫和監聽基本服務,不帶3個網頁的服務,相當於上面的sqlplus 和 lsnrctl start兩個操作

dbshut 就可以停止oracle了。

不過要注意的是startup.log和shutdown.log最好確認一下他們的所有者是不是oracle
最好可以chown oracle.oinstall startup.log
    chown oracle.oinstall shutdown.log一下,不然服務自啟動的時候會報一些錯

9,把oracle添加為自啟動服務dbstart,root使用者進行如下操作
su - root
cd /etc/rc.d/init.d/
gedit dbstart

複製如下指令碼1或者指令碼2內容到dbstart檔案:指令碼1包括資料庫和監聽基本服務,iSQL*Plus,Enterprise Manager 10g Database Control所有服務

指令碼1(啟動所有服務)

#!/bin/bash

# chkconfig: 345 99 10

# description: Startup Script for oracle Databases

# /etc/rc.d/init.d/dbstart


export ORACLE_BASE=/home/oracle

export ORACLE_HOME=/home/oracle/10G

export ORACLE_SID=orcl

export PATH=$PATH:$ORACLE_HOME/bin


ORA_OWNR="oracle"

# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]

then

     echo "Oracle startup: cannot start"

     exit 1

fi

# depending on parameter -- startup, shutdown, restart

# of the instance and listener or usage display

case "$1" in

   start)

     # Oracle listener and instance startup

     echo -n "Starting Oracle: "

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"

     touch /var/lock/oracle

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl start"

    su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"


     echo "OK"

     ;;

   stop)

     # Oracle listener and instance shutdown

     echo -n "Shutdown Oracle: "

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl stop"

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"

     rm -f /var/lock/oracle

     echo "OK"

     ;;

   reload|restart)

     $0 stop

     $0 start

     ;;

   *)

     echo "Usage: `basename $0` start|stop|restart|reload"

     exit 1

esac

exit 0

指令碼2:(只啟動資料庫和監聽)


#!/bin/bash

# chkconfig: 345 99 10

# description: Startup Script for oracle Databases

# /etc/rc.d/init.d/dbstart

export ORACLE_BASE=/home/oracle

export ORACLE_HOME=/home/oracle/10G

export ORACLE_SID=orcl

export PATH=$PATH:$ORACLE_HOME/bin

case "$1" in

start)

su oracle -c $ORACLE_HOME/bin/dbstart

touch /var/lock/oracle

echo "OK"

;;

stop)

echo -n "Shutdown oracle: "

su oracle -c $ORACLE_HOME/bin/dbshut

rm -f /var/lock/oracle

echo "OK"

;;

*)

echo "Usage: 'basename $0' start|stop"

exit 1

esac

exit 0

上面兩個指令碼如果

export ORACLE_BASE=/home/oracle

export ORACLE_HOME=/home/oracle/10G

和你所安裝的oracle路徑不相同,請參考修改就是,然後


chown oracle.oinstall /etc/rc.d/init.d/dbstart

chmod 775 /etc/rc.d/init.d/dbstart

/sbin/chkconfig --add dbstart

/sbin/chkconfig --list dbstart
運行結果:
dbstart         0:關閉 1:關閉 2:關閉 3:啟用 4:啟用 5:啟用 6:關閉
可以
/sbin/service dbstart start
看看是否能啟動

重啟看看
然後自己可以測試下oracle所有服務是否啟動
具體可以測試三個網頁地址
sqlplus登入下等

好了,本文只是本人用來解決遺忘的記錄,等不了幾天我又忘很多了,希望也對你有所協助,安裝過程中出現錯誤的話多google,baidu下,學linux就需要一天100個google,200個baidu的精神。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.