Thực hiện trên
OS Oracle linux 5U9
Database 11gR2
Edit file /etc/oratab
Sửa dòng
RCAT:/home/oracle/app/oracle/product/11.2.0/dbhome_1:N
Thành
RCAT:/home/oracle/app/oracle/product/11.2.0/dbhome_1:Y
Tạo file oracle trong /etc/init.d/
#!/bin/sh
# chkconfig: 345 99 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=/home/oracle/app/oracle/product/11.2.0/dbhome_1
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:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
touch /var/lock/subsys/dbora
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
rm -f /var/lock/subsys/dbora
;;
esac
# chkconfig: 345 99 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=/home/oracle/app/oracle/product/11.2.0/dbhome_1
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:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
touch /var/lock/subsys/dbora
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
rm -f /var/lock/subsys/dbora
;;
esac
Phân quyền 755 cho file oracle
[root@TC-OSB init.d]# chmod 755 oracle
[root@TC-OSB init.d]# ls -al |grep oracle
-rwxr-xr-x 1
root root 1087 May 20 09:57 oracle
[root@TC-OSB init.d]#
Add service oracle để scritp chạy khi reboot lại
server
[root@TC-OSB ~]# chkconfig --add oracle
[root@TC-OSB ~]# chkconfig --list |grep oracle
oracle 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@TC-OSB ~]#
cũng có thể sử dụng lệnh
servcie oracle stop hoặc service oracle start để stop start lại database
[root@TC-OSB init.d]# service oracle stop
ORACLE_HOME_LISTNER is not SET, unable to auto-stop
Oracle Net Listener
Usage: /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/dbshut
ORACLE_HOME
Processing Database instance "RCAT": log
file /home/oracle/app/oracle/product/11.2.0/dbhome_1/shutdown.log
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on
20-MAY-2013 10:00:34
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=TC-OSB.localdomain)(PORT=1521)))
The command completed successfully
[root@TC-OSB init.d]# service oracle start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on
20-MAY-2013 10:00:40
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting
/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is
/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to
/home/oracle/app/oracle/diag/tnslsnr/TC-OSB/listener/alert/log.xml
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=TC-OSB.localdomain)(PORT=1521)))
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=TC-OSB.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version
11.2.0.1.0 - Production
Start Date 20-MAY-2013 10:00:40
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File
/home/oracle/app/oracle/diag/tnslsnr/TC-OSB/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=TC-OSB.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
ORACLE_HOME_LISTNER is not SET, unable to auto-start
Oracle Net Listener
Usage:
/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/dbstart ORACLE_HOME
Processing Database instance "RCAT": log
file /home/oracle/app/oracle/product/11.2.0/dbhome_1/startup.log
[root@TC-OSB init.d]#
No comments:
Post a Comment