数据库为oracle 9i, 操作系统为Centos linux 4.7.
(1)修改Oracle系统配置文件/etc/oratab
/etc/oratab 格式为: SID:ORACLE_HOME:AUTO
把AUTO域设置为Y(大写),只有这样,oracle 自带的dbstart和dbshut才能够发挥作用。我的为:
huang:/u01/oracle:Y
(2)用root登录,在/etc/rc.d/init.d下创建名为dbora文件,用vi编辑,增加内容如下:
####################################
#!/bin/bash
# chkconfig: 35 95 1
# description: init script. to start/stop oracle database 10g, TNS listener, EMS
#
#
# match these values to your environment:
export ORACLE_BASE=/u01
export ORACLE_HOME=$ORACLE_BASE/oracle
export ORACLE_SID=huang
export PATH=/home/oracle/bin:$ORACLE_HOME/bin:$PATH
export ORACLE_USER=oracle
# see how we are called:
case $1 in
start)
su - "$ORACLE_USER"<
dbstart
EOS
emctl start dbconsole
EOO
;;
stop)
su - "$ORACLE_USER"<
dbshut
EOS
emctl stop dbconsole
EOO
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
###################################
打开终端执行:
cd /etc/rc.d/init.d/
chown oracle:oinstall dbora
chmod 755 dbora
使用chkconfig设置权限
chkconfig dbora reset
检查
chkconfig --list dbora
结果如下:
ora10 0:off 1:off 2:off 3:on 4:off 5:on 6:off
注意:当系统不在 runlevels 3 and 5时,使用
service dbora start 启动服务.
service dbora stop 停止服务.
(3)修改$ORACLE_HOME/bin/dbstart,在文件的最后加上
# Set this to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$ORACLE_HOME
(4)重新启动计算机,就可以了,启动时开户数据库,可能会比较慢
注:这样oracle的服务就添加到linux操作系统了,可以用root用户登录后,用以下命令来启动和关掉数据库
service dbora start
service dbora stop
因为我的数据库没有用到em,所以提示emctl的命令没找到,不管这个
附录:
常用手动控制数据库命令
打开em
emctl start dbconsole
关闭em
emctl stop dbconsole
启动listener
lsnrctl start <监听名>(默认是LISTENER,可省略)
关闭
lsnrctl stop
启动emagent
emctl start agent
关闭
emctl stop agent
启动实例
sqlplus /nolog
conn / as sysdba
startup
关闭
shutdown immediate
测试数据库是否通
tnsping
常用linux命令
df -h
ps -A
top
free
cat /proc/meminfo
uname
grep MemTotal /proc/meminfo
grep SwapTotal /proc/meminfo
hostname
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7865774/viewspace-609277/ ,如需转载,请注明出处,否则将追究法律责任。