啟動oracle資料庫步驟:x0dx0a首先使用oracle用戶登錄Linux,然後在shell命令行中執行下面的命令:x0dx0a第一步:打開Oracle監聽x0dx0a$ lsnrctl startx0dx0a第二步:進入sqlplusx0dx0a$ sqlplus /nologx0dx0aSQL>x0dx0a第三步:使用sysdab角色登錄sqlplusx0dx0aSQL> conn /as sysdbax0dx0a第四步:啟動資料庫x0dx0aSQL> startupx0dx0a經過上面的四個步驟,oracle資料庫就可以啟動了。x0dx0a關閉資料庫用 shutdown 是要等待事物結束才關閉,強制關閉用 shutdown abort。
2. 如何在LINUX下啟動ORACLE
手動啟動:
用 oracle用戶登錄(或su - oracle)
lsnrctl start
sqlplus / as sysdba
startup
exit
自動啟動,要編寫一個啟動腳本,用root用戶拷到/etc/init.d下,取名叫oracle
然後, chkconfig oracle on,即可加入服務列表
/etc/init.d/oracle start #啟動
/etc/init.d/oracle stop #停止
腳本的示例(裡面的變數要按實際情況修改):
#!/bin/bash
#
# chkconfig: 345 99 01
# description: This is a program that is responsible for taking care of
# configuring the Oracle Database 11g Stardard/Enterprise Edition and its associated
# services.
#
# Source fuction library
if [ -f /lib/lsb/init-functions ]
then
. /lib/lsb/init-functions
elif [ -f /etc/init.d/functions ]
then
. /etc/init.d/functions
fi
# Set path if path not set (if called from /etc/rc)
case $PATH in
"") PATH=/bin:/usr/bin:/sbin:/etc
export PATH ;;
esac
# Save LD_LIBRARY_PATH
SAVE_LLP=$LD_LIBRARY_PATH
RETVAL=0
ORACLE_OWNER=oracle
ORACLE_OWNER_HOME=/opt/oracle
ORACLE_BASE=$ORACLE_OWNER_HOME/app/oracle
ORACLE_HOME=$ORACLE_BASE/proct/11.2.0/dbhome_1
ORACLE_SID=orcl
ORACLE_UNQNAME=$ORACLE_SID
LSNR=$ORACLE_HOME/bin/lsnrctl
SQLPLUS=$ORACLE_HOME/bin/sqlplus
STARTDB_SQL=$(mktemp /tmp/start.XXXXXX)
echo -e "startup;\nquit;\n" > $STRTDB_SQL
STOPDB_SQL=$(mktemp /tmp/stop.XXXXXX)
echo -e "shutdown immediate;\nquit;\n" > $STOPDB_SQL
SU=/bin/su
export ORACLE_HOME
export ORACLE_SID
export PATH=$ORACLE_HOME/bin:$PATH
LOG="$ORACLE_HOME_LISTNER/listener.log"
export LC_ALL=C
if [ $(id -u) != "0" ]
then
echo "You must be root to run the configure script. Login as root and then run the
configure script."
exit 1
fi
if [ -f /etc/redhat-release ]
then
. /etc/init.d/functions
init_status()
{
return 0
}
exit_status()
{
exit $?
}
success_status()
{
success
echo
}
failure_status()
{
failure $?
echo
}
elif [ -f /etc/SuSE-release ]
then
. /etc/rc.status
init_status()
{
rc_reset
}
success_status()
{
echo "OK"
return 0
}
failure_status()
{
echo "Failed"
return 1
}
exit_status()
{
exit $?
}
else
if [ -d /etc/default ]
then
CONFIGURATION="/etc/default/$CONFIG_NAME"
fi
init_status()
{
return 0
}
success_status()
{
echo "OK"
return 0
}
failure_status()
{
echo "Failed"
return 0
}
exit_status()
{
exit $?
}
fi
init_status
start() {
status=`ps -ef | grep tns | grep oracle`
if [ "$status" == "" ]
then
if [ -f $ORACLE_HOME/bin/tnslsnr ]
then
echo "Starting Oracle Net Listener."
$SU -s /bin/bash $ORACLE_OWNER -c "$LSNR start" # > /dev/null 2>&1
fi
fi
echo "Starting Oracle Database 11g Instance."
$SU -s /bin/bash $ORACLE_OWNER -c "$SQLPLUS -s /nolog @${STARTDB_SQL}" # > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
echo
else
echo Failed to start Oracle Net Listener using $ORACLE_HOME/bin/tnslsnr\
and Oracle Database using $ORACLE_HOME/bin/sqlplus.
RETVAL=1
return $RETVAL
fi
}
startconsole() {
$SU -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole &" # > /dev/null 2>&1
RETVAL=$?
return $RETVAL
}
stop() {
# Stop Oracle 11g Database and Listener
$SU -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole &" # > /dev/null 2>&1
echo Shutting down Oracle Database 11g Instance.
$SU -s /bin/bash $ORACLE_OWNER -c "$SQLPLUS -s /nolog @${STOPDB_SQL}" # > /dev/null 2>&1
echo Stopping Oracle Net Listener.
$SU -s /bin/bash $ORACLE_OWNER -c "$LSNR stop" # > /dev/null 2>&1
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$LSNR
then
return $RETVAL
fi
}
stopconsole() {
# Stop Oracle 11g Database and Listener
$SU -s /bin/bash $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole &" # > /dev/null 2>&1
RETVAL=$?
return $RETVAL
}
# See how we were called
case "$1" in
start)
start
;;
startconsole)
startconsole
;;
stop)
stop
;;
stopconsole)
stopconsole
;;
restart|reload|force-reload)
stop
start
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
exit 1
esac
3. Linux下查看監聽狀態的命令lsnrctl status,如何根據返回結果判斷監聽是正常啟動
用 oracle:~ # lsof -i:1521 如果有返回信息,就說明偵聽是啟用的,如果沒有返回任何信息說明偵聽是停用的,或者你用 lsnrctl start。
oracle@oracle:~> lsnrctl start
LSNRCTL for Linux: Version 11.2.0.3.0 - Proction on 04-JUL-2014 18:28:35
Copyright (c) 1991, 2011, Oracle. All rights reserved.
TNS-01106: Listener using listener name LISTENER has already been started
返回以上信息,說明是啟用的。
方法1::
看 oracle監聽是否啟動 在CMD下運行如下命令就可以 lsnrctl status
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=spcc)(PORT=1525)))
TNS-12541: TNS:無監聽器
TNS-12560: TNS: 協議適配器錯誤
TNS-00511: 無監聽器
32-bit Windows Error: 61: Unknown error
LSNRCTL> start listener1
啟動tnslsnr:請稍候...
這表示沒有啟動。。
方法2:
如果是LINUX系統可以通過如下命令看進程在不在
ps -ef|grep lsn
看 oracle監聽是否啟動 在CMD下運行如下命令就可以
lsnrctl status
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=spcc)(PORT=1525)))
TNS-12541: TNS:無監聽器。TNS-12560: TNS: 協議適配器錯誤。TNS-00511: 無監聽器
32-bit Windows Error: 61: Unknown error
LSNRCTL> start listener1
啟動tnslsnr:請稍候...。這表示沒有啟動。。
如果是LINUX系統可以通過如下命令看進程在不在
ps -ef|grep lsn
4. 如何在linux下啟動和關閉ORCALE資料庫
1. linux下啟動oraclex0dx0asu - oraclex0dx0asqlplus /nologx0dx0aconn /as startx0dx0aexitx0dx0a2. linux下關閉oraclex0dx0asu - oraclex0dx0asqlplus /nologx0dx0aconn /as sysdbax0dx0ashutdown stopx0dx0aexitx0dx0a3、啟動監聽器x0dx0aoracle@suse92:~> lsnrctl startx0dx0a4、停止監聽器x0dx0aoracle@suse92:~> lsnrctl stopx0dx0a5、查看監聽器狀態x0dx0aoracle@suse92:~> lsnrctlx0dx0aLSNRCTL> statusx0dx0aLSNRCTL> exitx0dx0a6.# setup 可以設置防火牆等信息x0dx0a7.安裝監聽器x0dx0a運行 netca 命令x0dx0alsnrctl startx0dx0alsnrctl stopx0dx0areload listener 重新載入x0dx0aservice listenerx0dx0ahelp 幫助x0dx0aquit 退出x0dx0avi etc/hostsx0dx0a添加 192.168.0.100 chsylinuxx0dx0a資料庫關閉死掉還可以STARTUP FORCEx0dx0a,再糟糕的情況用SHUTDOWN ABORT。
5. linux怎麼看資料庫監聽是否啟動
查看Oracle資料庫監聽是否啟動應使用lsnrctl命令,命令如下
$lsnrctlstatus
Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle.domain)(PORT=1521)))
STATUSoftheLISTENER
————————
AliasLISTENER
VersionTNSLSNRforLinux:Version10.2.0.1.0–Proction
StartDate17-MAY-201121:03:40
Uptime0days0hr.2min.49sec
TraceLeveloff
SecurityON:LocalOSAuthentication
SNMPOFF
ListenerParameterFile/u01/app/oracle/proct/10.2.1/db/network/admin/listener.ora
ListenerLogFile/u01/app/oracle/proct/10.2.1/db/network/log/listener.log
ListeningEndpointsSummary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1600)))
ServicesSummary…
Service「POD」has1instance(s).
Instance「POD」,statusREADY,has1handler(s)forthisservice…
Service「POD1″has1instance(s).
Instance「POD」,statusUNKNOWN,has1handler(s)forthisservice…
Service「PODS」has1instance(s).
Instance「POD」,statusREADY,has2handler(s)forthisservice…
Service「pod_XPT」has1instance(s).
Instance「POD」,statusREADY,has1handler(s)forthisservice…
Service「repos」has2instance(s).
Instance「repos」,statusUNKNOWN,has1handler(s)forthisservice…
Instance「repos」,statusREADY,has1handler(s)forthisservice…
Service「repos_XPT」has1instance(s).
Instance「repos」,statusREADY,has1handler(s)forthisservice…
lsnrctl命令常用參數:
$lsnrctlstatus:檢查當前監聽器的狀態
$lsnrctlstart[listener-name]啟動所有的監聽器,可以指定名字來啟動特定的監聽器
$lsnrctlstop[listener-name]關閉所有的監聽器,可以指定名字來關閉特定的監聽器
$lsnrctlreload重啟監聽器,此命令可以代替lsnrctlstop,lsnrctlstart
$lsnrctlhelp可以顯示所有可用的監聽器命令
6. linux 下的oracle怎麼啟動
1、首先打開命令行窗口,切換到su - oracle,啟動資料庫監聽。
7. 如何在linux下重啟oracle資料庫
1、打開一個terminal切換到oracle用戶,用oracle用戶修改以下內容,注意要用oraclee用戶編輯,CD到oracle的安裝目錄的bin目錄。