欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Linux中Oracle服務(wù)啟動(dòng)和停止腳本與開(kāi)機(jī)自啟動(dòng)

 更新時(shí)間:2016年12月03日 11:02:47   作者:David_Tang  
這篇文章主要介紹了Linux中Oracle服務(wù)啟動(dòng)和停止腳本與開(kāi)機(jī)自啟動(dòng),有興趣的同學(xué)可以一起來(lái)了解一下。

在CentOS 6.3下安裝完Oracle 10g R2,重開(kāi)機(jī)之后,你會(huì)發(fā)現(xiàn)Oracle沒(méi)有自行啟動(dòng),這是正常的,因?yàn)樵贚inux下安裝Oracle的確不會(huì)自行啟動(dòng),必須要自行設(shè)定相關(guān)參數(shù),首先先介紹一般而言如何啟動(dòng)oracle。

一、在Linux下啟動(dòng)Oracle

登錄到CentOS,切換到oracle用戶權(quán)限

# su – oracle

接著輸入:

$ sqlplus "/as sysdba"

原本的畫(huà)面會(huì)變?yōu)?br /> SQL>

接著請(qǐng)輸入
SQL> startup

就可以正常的啟動(dòng)數(shù)據(jù)庫(kù)了。

另外停止數(shù)據(jù)庫(kù)的指令如下:

SQL> shutdown immediate

二、檢查Oracle DB監(jiān)聽(tīng)器是否正常

回到終端機(jī)模式,輸入:

$ lsnrctl status

檢查看看監(jiān)聽(tīng)器是否有啟動(dòng)

如果沒(méi)有啟動(dòng),可以輸入:

$ lsnrctl start

啟動(dòng)監(jiān)聽(tīng)器

SQL> conn sys@orcl as sysdba

然后輸入密碼,sys以sysdba身份登入數(shù)據(jù)庫(kù)。

三、啟動(dòng)emctl

另外也可以發(fā)現(xiàn)http://localhost.localdomain:1158/em 目前是沒(méi)有反應(yīng)的,這邊要另外啟動(dòng),啟動(dòng)的指令如下:

$ emctl start dbconsole

這個(gè)指令運(yùn)行時(shí)間較長(zhǎng),執(zhí)行完的畫(huà)面如下:

手動(dòng)啟動(dòng)Oracle數(shù)據(jù)庫(kù)完畢,下面創(chuàng)建系統(tǒng)自行啟動(dòng)Oracle的腳本。

四、Oracle啟動(dòng)&停止腳本

1. 修改Oracle系統(tǒng)配置文件:/etc/oratab,只有這樣,Oracle 自帶的dbstart和dbshut才能夠發(fā)揮作用。

# vi /etc/oratab
orcl:/opt/oracle/102:Y

# Entries are of the form:
#  $ORACLE_SID:$ORACLE_HOME:<N|Y>:

2. 在 /etc/init.d/ 下創(chuàng)建文件oracle,內(nèi)容如下:

#!/bin/sh
# chkconfig: 35 80 10
# description: Oracle auto start-stop script.

#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/opt/oracle/102
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
  echo "Oracle startup: cannot start"
  exit
fi
case "$1" in
'start')
# Start the Oracle databases:
echo "Starting Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
echo "Done"

# Start the Listener:
echo "Starting Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
echo "Done."
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;

'stop')
# Stop the Oracle Listener:
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle

# Stop the Oracle Database:
echo "Stoping Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
;;

'restart')
$0 stop
$0 start
;;
esac

3. 改變文件權(quán)限

# chmod 755 /etc/init.d/oracle

4. 添加服務(wù)

# chkconfig --level 35 oracle on

5. 需要在關(guān)機(jī)或重啟機(jī)器之前停止數(shù)據(jù)庫(kù),做一下操作

# ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle  //關(guān)機(jī)
# ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle  //重啟 

6. 使用方法

# service oracle start    //啟動(dòng)oracle
 # service oracle stop    //關(guān)閉oracle
 # service oracle restart   //重啟oracle

7. 測(cè)試

a. 開(kāi)機(jī)自啟動(dòng)

Last login: Mon Nov 26 19:57:06 2012 from 10.0.0.145
[root@ORS ~]# su - oracle
[oracle@ORS ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 26 20:07:33 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> set linesize 300;
SQL> set pagesize 30;
SQL> select * from scott.emp;

   EMPNO ENAME   JOB       MGR HIREDATE     SAL    COMM   DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
SMITH   CLERK      7902 17-DEC-80    800          20
ALLEN   SALESMAN    7698 20-FEB-81    1600    300     30
WARD    SALESMAN    7698 22-FEB-81    1250    500     30
JONES   MANAGER     7839 02-APR-81    2975          20
MARTIN   SALESMAN    7698 28-SEP-81    1250    1400     30
BLAKE   MANAGER     7839 01-MAY-81    2850          30
CLARK   MANAGER     7839 09-JUN-81    2450          10
SCOTT   ANALYST     7566 19-APR-87    3000          20
KING    PRESIDENT      17-NOV-81    5000          10
TURNER   SALESMAN    7698 08-SEP-81    1500     0     30
ADAMS   CLERK      7788 23-MAY-87    1100          20
JAMES   CLERK      7698 03-DEC-81    950          30
FORD    ANALYST     7566 03-DEC-81    3000          20
MILLER   CLERK      7782 23-JAN-82    1300          10
rows selected.

SQL>

b. service oracle stop

SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@ORS ~]$ logout
[root@ORS ~]# service oracle stop
Stoping Oracle Listeners ... 
Done.
Stoping Oracle Databases ... 
Done.

[root@ORS ~]# su - oracle
[oracle@ORS ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 26 20:17:20 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> set linesize 300;
SQL> set pagesize 30;
SQL> select * from scott.emp;
select * from scott.emp
*
ERROR at line 1:
ORA-01034: ORACLE not available


SQL>

c. service oracle start

SQL> Disconnected
[oracle@ORS ~]$ logout
[root@ORS ~]# service oracle start
Starting Oracle Databases ... 
Done
Starting Oracle Listeners ... 
Done.
[root@ORS ~]#

d. service oracle restart

[root@ORS ~]# service oracle restart
Stoping Oracle Listeners ... 
Done.
Stoping Oracle Databases ... 
Done.

Starting Oracle Databases ... 
Done
Starting Oracle Listeners ... 
Done.
[root@ORS ~]#

至此,Oracle服務(wù)啟動(dòng)&停止腳本與開(kāi)機(jī)自啟動(dòng)設(shè)置完畢。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論