前面已经安装好了oracle数据库,那么在这一节我要写的是系统启动时,自动启动oracle监听和启动oracle数据库。
1 写数据库启动和停止脚本
[oracle@zjk ~]$ vim shutdown11g
#!/bin/bash
source /home/oracle/.db11g
sqlplus / as sysdba << EOF
shutdown immediate
EOF
lsnrctl stop
[oracle@zjk ~]$ chmod u+x shutdown11g
[oracle@zjk ~]$ vim start11g
#!/bin/bash
source /home/oracle/.db11g
lsnrctl start
sqlplus / as sysdba << EOF
startup
EOF
[oracle@zjk ~]$ chmod u+x start11g
2 把启动和停止脚本添加到系统服务中
[root@zjk init.d]# cp /etc/init.d/network /etc/init.d/oracle
[root@zjk init.d]# vim oracle
#! /bin/bash
#
# oracle Bring up/down oracle
#
# chkconfig: 2345 90 1
# description: Activates/Deactivates aoracle configured to \
# start at boot time.
#
# Source function library.
. /etc/init.d/functions
# See how we were called.
case "$1" in
start)
su - oracle -c "/home/oracle/start11g"
;;
stop)
su - oracle -c "home/oracle/shutdown11g"
;;
*)
echo $"Usage: $0 {start|stop}"
exit 2
esac
[root@zjk init.d]# chmod u+x /etc/init.d/oracle
[root@zjk init.d]# chkconfig oracle on
这样就完成了系统启动,然后可以自动启动oracle数据库监听和启动oracle数据库的功能了。
3 使sqlplus可以上下翻命令的方法
tar -zxvf rlwrap-0.37.tar.gz
./configure
make
make install
rlwrap sqlplus / as sysdba
这个rlwrap-0.37.tar.gz包网上可以下载到的。
希望我的这三篇数据库安装的文章对刚学数据库安装有帮助。