Tạo Script: OraSRV
##########################################################
#!/bin/sh
#
# chkconfig: 345 99 01
# description: Start/Stop/Check Oracle Database
export ORACLE_SID=HIEUORA
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=/usr/local/bin:$ORACLE_HOME/bin:$PATH
export ORACLE_OWNER=oracle
case $1 in
'start')
su - $ORACLE_OWNER <<EOF
export ORACLE_SID=$ORACLE_SID
export ORACLE_HOME=$ORACLE_HOME
$ORACLE_HOME/bin/sqlplus /nolog
conn / as sysdba
startup
exit
EOF
RET=0
;;
'stop')
su - $ORACLE_OWNER <<EOF
export ORACLE_SID=$ORACLE_SID
export ORACLE_HOME=$ORACLE_HOME
$ORACLE_HOME/bin/sqlplus /nolog
conn / as sysdba
shutdown immediate
exit
EOF
RET=0
;;
'check')
# check for the existance of the smon process for $ORACLE_SID
# this check could be improved, but was kept short on purpose
found=`ps -ef | grep smon | grep $ORACLE_SID | wc -l`
if [ $found = 0 ]; then
RET=1
else
RET=0
fi
;;
*)
RET=0
;;
esac
# A 0 indicates success, return 1 for an error.
if [ $RET -eq 0 ]; then
exit 0
else
exit 1
fi
##########################################################
- Bỏ script này vào thư mục: /etc/rc.d/init.d
- Cấp quyền execute cho script này: #chmod a+x /etc/rc.d/init.d/OraSRV
- Thêm Service này vào linux và yêu cầu start khi hệ thống startup:
#chkconfig --add OraSRV
#chkconfig --level 345 OraSRV on
Start/Stop/Check Service:
#service OraSRV start
#service OraSRV stop
#service OraSRV check
Không có nhận xét nào:
Đăng nhận xét