测试运行dbshut,dbstart (1)修改dbstart和dbshut的日志文件的权限: 注:startup.log 和shutdown.log 可能没有,当你运行 ./dbstart 和 ./dbshut 之后才自动创建。 $su - root #cd $ORACLE_HOME #chown oracle:oinstall startup.log #chown oracle:oinstall shutdown.log (2)执行相应的脚本进行测试 #su oracle $cd $ORACLE_HOME/bin $./dbstart (./dbshut) $ ps -efw | grep ora_ $ lsnrctl status $ ps -efw | grep LISTEN | grep -v grep
[oracle@www ~]$ cat /home/oracle/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin #oracle profile TMP=/tmp;export TMP TMPDIR=$TMP;export TMPDIR ORACLE_BASE=/usr/app/oracle;export ORACLE_BASE TMP=/tmp;export TMP TMPDIR=$TMP;export TMPDIR ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_l; export ORACLE_HOME ORACLE_SID=orcl; TMP=/tmp;export TMP TMPDIR=$TMP;export TMPDIR export ORACLE_SID ORACLE_TERM=xterm; export ORACLE_TERM PATH=$PATH:$ORACLE_HOME/bin; export PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH #export DISPLAY=192.168.0.33:0.0 export DISPLAY=127.0.0.1:0.0 export LANG=AMRICAN export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #oracle profile end
[oracle@www ~]$ source /home/oracle/.bash_profile [oracle@www ~]$ host + +.localdomain has address 202.106.199.36 Host +.localdomain not found: 3(NXDOMAIN) Host +.localdomain not found: 3(NXDOMAIN)
[oracle@www init.d]$ cat /home/oracle/oradbstart #!/bin/bash # chkconfig: 345 99 10 # description: Startup Script for oracle Databases # /etc/rc.d/init.d/dbstart export ORACLE_BASE=/usr/app/oracle/ export ORACLE_HOME=/usr/app/oracle/product/10.2.0/db_l export ORACLE_SID=orcl export PATH=$PATH:$ORACLE_HOME/bin ORA_OWNR="oracle" # if the executables do not exist -- display error if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ] then echo "Oracle startup: cannot start" exit 1 fi # depending on parameter -- startup, shutdown, restart # of the instance and listener or usage display case "$1" in start) # Oracle listener and instance startup echo -n "Starting Oracle: " su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start " su $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart" touch /var/lock/oracle su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole" su $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl start" echo "OK" ;; stop) # Oracle listener and instance shutdown echo -n "Shutdown Oracle: " su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole" su $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl stop" su $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut" su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop" rm -f /var/lock/oracle echo "OK" ;; reload|restart) $0 stop $0 start ;; *) echo "Usage: `basename $0` start|stop|restart|reload" exit 1 esac exit 0 [oracle@www init.d]$ chkconfig --add oradbstart [oracle@www init.d]$ chkconfig --list oradbstart
测试服务(快速启动Oracle) /etc/rc.d/init.d/oradbstart stop /etc/rc.d/init.d/oradbstart start /etc/rc.d/init.d/oradbstart restart(或者reload)
重启linux reboot -n 在linux启动的时候,你就可以看到一个启动项oracle10g,出现[OK]的时候, 就表示你的数据库随系统启动了。
3.1 重启Linux后,查看进程 ps -ef|grep ora_|grep -v grep ps -ef|grep tnslsnr|grep -v grep
3.2 sqlplus测试进入 sqlplus '/as sysdba' |