A. linux如何設置Oracle實例和監聽自啟動
1.安裝好Oracle資料庫後: 執行 dbstart和dbshut會提示:
[oracle@oracle11g ~]$ dbstart
ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
Usage: /u01/app/oracle/oracle/proct/10.2.0/db_1/bin/dbstart ORACLE_HOME
錯誤原因是:dbstart和dbshut腳本文件中ORACLE_HOME_LISTNER的設置有問題,分別打開兩個文件找到:ORACLE_HOME_LISTNER=$1,修改為
ORACLE_HOME_LISTNER=$ORACLE_HOME,命令如下:
[oracle@oracle11g ~]$ vi $ORACLE_HOME/bin/dbstart
[oracle@oracle11g ~]$ vi $ORACLE_HOME/bin/dbshut
修改後保存退出,第一個問題已解決;
2.如何在Linux啟動時自動啟動Oracle監聽和實例
首先要解決上面的問題,才能繼續喲!
第一步:修改/etc/oratab文件,命令如下:
[oracle@oracle11g ~]$ vi /etc/oratab
找到:accp:/u01/oracle:N 修改為: accp:/u01/oracle:Y
第二步:把lsnrctl start和dbstart添加到rc.local文件中,命令如下:
[oracle@oracle11g ~]$ vi /etc/rc.d/rc.local
添加:
su oracle -lc "/u01/oracle/bin/lsnrctl start"
su oracle -lc /u01/oracle/bin/dbstart
注意:第一個命令有空格,所以要用引號的
重啟試試吧!
轉自ChinaUnix博客。
B. ORACLE如何在LINUX設置自動啟動
1. 寫一個啟動腳本,比如名字叫dbora,放到/etc/rc.d/init.d,內容可以參考(注意相關環境變數要修改):
#!/bin/bash
#
# chkconfig: 345 60 50
# description: Oracle auto start-stop script.
# Modify the variables $ORA_HOME, $ORA_OWNER and $LOG as appropriate for each server.
# - Nabeel Moi
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
# Modify the variables $ORA_HOME, $ORA_OWNER and $LOG as appropriate for each server.
# - Nabeel Moi
ORA_HOME=/u01/oracle/proct/10.2.0.1
ORA_OWNER=ora10g
LOG=$ORA_HOME/log/server/dbora/dbora.log
if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
start)
echo "$0: starting up" >> $LOG
# Start the Oracle databases:
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart &" >> $LOG
# Start Oracle listener
date >> $LOG
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >> $LOG 2>&1
touch /var/lock/subsys/dbora
echo "Refer to $LOG for details"
;;
stop)
echo "$0: stopping down" >> $LOG
date >> $LOG
# Stop Oracle Net
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >> $LOG 2>&1
# Stop the Oracle databases:
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut &" >> $LOG
rm -f /var/lock/subsys/dbora
;;
restart)
$0 stop
sleep 120
$0 start
;;
status)
if [ -f /var/lock/subsys/dbora ]; then
echo $0 started.
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl status"
else
echo $0 stopped.
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl status"
fi
;;
*)
echo "usage: dbora {start|stop|restart|status}"
exit 1
esac
exit 0
2. # chmod 755 /etc/rc.d/init.d/dbora
3. # chkconfig dbora on
4. 把 /etc/oratab中的N改為Y
C. linux下的oracle資料庫怎麼設置開機自啟動
寫一個腳本加入到/etc/rc.local里,比如: sh /etc/startora.sh /etc/startora.sh 內容如下(根據自己需要進行修改): su - oracle -c 'dbstart' 使用dbstart需要修改/etc/oratab文件最後一行,將N 改成Y orcl:/db/oracle/proct/11.2.0/db_1:Y
D. 如何在Linux中設置開機自動啟動oracle
對於LINUX 操作系統 有很多技術知識是我們需要學習的。這里我就給大家介紹Linux中設置oracle開機自動啟動的 方法 。一起來看看吧。
Linux中設置oracle開機自動啟動的方法
在terminal中切換到root用戶
查看/etc/oratab文件的內容,其內容如下
[root@golonglee ~]# cat /etc/oratab | grep -v ^$
#
# 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::
#
# 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.
#
#
oel63:/home/oracle/app/oracle/proct/11.2.0/dbhome_1:N
使用命令vi /etc/oratab編輯文件/etc/oratab,在最後添加如下內容
##### what I have written is as following
oel63:/home/oracle/app/oracle/proct/11.2.0/dbhome_1:Y
#####Finished wrote in 2015-12-24
說明:/home/oracle/app/oracle/proct/11.2.0/dbhome_1為oracle的安裝目錄,要根據實際情況進行修改。
(注意:圖中我用紅色標記的N要改成Y)
找到最後的內容
oel63:/home/oracle/app/oracle/proct/11.2.0/dbhome_1:N
復制該行oel63:/home/oracle/app/oracle/proct/11.2.0/dbhome_1:N並注釋掉
粘貼該行,並將該行
oel63:/home/oracle/app/oracle/proct/11.2.0/dbhome_1:N最後的N
改為Y
最後按2次ESC鍵,並輸入:wq並按下enter保存,退出
使用命令vi /etc/rc.d/rc.local編輯rc.local文件,添加如下內容
##### what I have written is as following
su oracle -lc "/home/oracle/app/oracle/proct/11.2.0/dbhome_1/bin/lsnrctl start"
su oracle -lc /home/oracle/app/oracle/proct/11.2.0/dbhome_1/bin/dbstart
#####Finished wrote in 2015-12-24
說明:因為第一行命令中有空格所以用雙引號(英文的雙引號)
/home/oracle/app/oracle/proct/11.2.0/dbhome_1為oracle的安裝目錄,要根據實際情況進行修改。
最後按2次ESC鍵,並輸入:wq並按下enter保存,退出,重啟機器,驗證成功。
是不是很簡單呢~快跟著我一起學習吧!!!如果覺得這篇 文章 不錯的話就給我點一個贊吧。
E. 如何在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
F. 怎樣在linux上配置oracle 11g 資料庫開機自啟動
root用戶登陸
編輯/etc/init.d/oracle文件,輸入以下內容(修改自己的ORACLE_BASE)
#!/bin/bash
# For RedHat and cousins:
# chkconfig: 2345 40 40
# description:
# processname:
# For SuSE and cousins
### BEGIN INIT INFO
# Provides: probe
# Required-Start: $syslog $remote_fs
# Should-Start: sendmail
# Required-Stop: $syslog $remote_fs
# Should-Stop: sendmail
# Default-Start: 2 3 5
# Default-Stop:
# Short-Description:
# Description:
# X-UnitedLinux-Default-Enabled: yes
### END INIT INFO
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/oracle
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_USER=oracle
export ORACLE_SID=dbbha
# see how we are called:
case $1 in
start)
su - "$ORACLE_USER"<<EOO
lsnrctl start
sqlplus /nolog<<EOS
connect / as sysdba
startup
EOS
emctl start dbconsole
EOO
touch /var/lock/subsys/$scriptname
;;
stop)
su - "$ORACLE_USER"<<EOO
lsnrctl stop
sqlplus /nolog<<EOS
connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
EOO
rm -f /var/lock/subsys/scriptname
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
設置oracle文件屬性:
linux-udly:~ # chown root.root /etc/init.d/oracle
linux-udly:~ # chmod 755 /etc/init.d/oracle
linux-udly:~ #
配置oracle服務
linux-udly:~ # service oracle start (啟動oracle服務)
linux-udly:~ # chkconfig oracle on (配置該服務系統重啟後有效)
G. linux開啟oracle服務命令是什麼
如果你的oracle安裝和配置都沒有問題的話:
#su - oracle
$sqlplus / as sysdba
>startup
>exit
$lsnrctl start
$ps -ef|grep oracle
H. Linux下如何啟動、關閉Oracle以及打開關閉監聽
1.用oracle用戶登錄linux系統,如果是遠程登錄的話,最好用xmanager,以便開啟圖形界面,如果是本地登錄,最好啟用linux圖形界面。
2.然後打開terminal,執行命令
netca,開啟監聽配置圖形界面
3.後面就和windows系統里的一樣了
I. 怎麼在linux中操作oracle資料庫
我用的是redhat
linux,用下面的步驟來啟動oracle資料庫。
首先使用oracle用戶登錄linux,然後在shell命令行中執行下面的命令:
第一步:打開oracle監聽
$
lsnrctl
start
第二步:進入sqlplus
$
sqlplus
/nolog
sql>
第三步:使用sysdab角色登錄sqlplus
sql>
conn
/as
sysdba
第四步:啟動資料庫
sql>
startup
經過上面的四個步驟,oracle資料庫就可以啟動了。