1.sqlplus的使用
在使用sqlplus总是让人很苦恼:因为如果我们在sqlplus里敲SQL命令或者语句时,不一小心敲错一个字母这个时候会发现回退建(Backspace)不好使,只能回车重新敲一遍;有时候我们想看上一次我们敲的是什么或者我们想重新执行上一句的命令(当然也可以用"/"),我们一般都会使用键盘上的上下建,但是当你按上下建的时候,你会发现上下建也不好使或者看不到我们以前敲的一些东西。因此,在这里给大家介绍一个小工具:rlwrap。有了这个小工具之后,我们再也不会因此而苦恼啦。(看到这句时你会不会想到某句广告词:XXX点读机,妈妈再也不用担心我的学习啦!

)
好了,接下来就教大家怎么使用吧。其实这个很简单,就是安装--->使用(

这不是废话吗)
[root@dba ~]# rpm -ivh rlwrap-0.30-1.el5.i386.rpm
当然你也可以去网上下载源码包,然后./configure--->make--->make install
切换到oracle用户 添加命令别名
vim .bashrc
alias sql='rlwrap sqlplus'
alias sqlplus='rlwrap sqlplus'
alias lsnrctl='rlwrap lsnrctl'
alias rman='rlwrap rman'
:wq
加载 source .bash_profile
好了,大功告成。
2.添加oracle随系统启动的脚本
启动脚本已随安装的软件安装到系统 不需要自己编写
脚本位置:
$ORACLE_HOME/bin/dbstart
$ORACLE_HOME/bin/dbshut
启动脚本中有一个路径变量值设置错误 要手动修正
[oracle@dba ~]$ sed -n '78p' $ORACLE_HOME/bin/dbstart
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
[oracle@dba ~]$ sed -i 's!/ade/vikrkuma_new/oracle!$ORACLE_HOME!' $ORACLE_HOME/bin/dbstart
[oracle@dba ~]$ sed -n '78p' $ORACLE_HOME/bin/dbstart
ORACLE_HOME_LISTNER=$ORACLE_HOME
[oracle@dba ~]$
要想使dbstart命令生效 还需要修改/etc/oratab里的内容
[oracle@dba ~]$ grep $ORACLE_SID /etc/oratab
ora10g:/u01/oracle/product/10.2.0:N
[oracle@dba ~]$
改成
ora10g:/u01/oracle/product/10.2.0:Y
之后就可以使用dbstart和dbshut来启停数据库了
[oracle@dba ~]$ ps -ef | grep ora_ | grep -v grep
[oracle@dba ~]$ dbstart
Processing Database instance "ora10g": log file /u01/oracle/product/10.2.0/startup.log
[oracle@dba ~]$ ps -ef | grep ora_ | grep -v grep
oracle 12359 1 0 07:24 ? 00:00:00 ora_pmon_ora10g
oracle 12361 1 0 07:24 ? 00:00:00 ora_psp0_ora10g
oracle 12363 1 1 07:24 ? 00:00:00 ora_mman_ora10g
oracle 12365 1 0 07:24 ? 00:00:00 ora_dbw0_ora10g
oracle 12367 1 1 07:24 ? 00:00:00 ora_lgwr_ora10g
oracle 12369 1 0 07:24 ? 00:00:00 ora_ckpt_ora10g
oracle 12371 1 3 07:24 ? 00:00:00 ora_smon_ora10g
oracle 12373 1 0 07:24 ? 00:00:00 ora_reco_ora10g
oracle 12375 1 1 07:24 ? 00:00:00 ora_cjq0_ora10g
oracle 12377 1 7 07:24 ? 00:00:00 ora_mmon_ora10g
oracle 12379 1 0 07:24 ? 00:00:00 ora_mmnl_ora10g
oracle 12381 1 0 07:24 ? 00:00:00 ora_d000_ora10g
oracle 12383 1 0 07:24 ? 00:00:00 ora_s000_ora10g
oracle 12388 1 1 07:24 ? 00:00:00 ora_qmnc_ora10g
oracle 12394 1 12 07:24 ? 00:00:00 ora_j000_ora10g
[oracle@dba ~]$ dbshut
[oracle@dba ~]$ ps -ef | grep ora_ | grep -v grep
[oracle@dba ~]$
借助这两个命令结合shell_script写个自己的脚本
[oracle@dba ~]$ cat /etc/rc.d/init.d/oracle
#!/bin/bash
# chkconfig: 35 85 90
# description: Oracle auto start-stop script.
# AUTH:seker
. /etc/init.d/functions
start(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n $"cannot start database: database is already running."
failure $"cannot start database: database is already running."
echo
exit 1
else
echo -n $"Starting Database: "
daemon su - $ORA_OWNER -c "dbstart" && touch /var/lock/subsys/`basename $0`
echo
fi
}
stop(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n $"Stoping Database: "
daemon su - $ORA_OWNER -c "dbshut" && rm -f /var/lock/subsys/`basename $0`
echo
else
echo -n $"cannot stop database:Database is not already running."
failure $"cannot stop database:Database is not already running."
echo
exit 1
fi
}
ORA_OWNER=oracle
case "$1" in
start)
start
;;
stop)
stop
;;
emstart)
su - $ORA_OWNER -c 'emctl status dbconsole &>/dev/null && echo "OEM is already running" || emctl start dbconsole'
;;
emstop)
su - $ORA_OWNER -c 'emctl status dbconsole &>/dev/null && emctl stop dbconsole || echo "OEM is not running"'
;;
isqlstart)
su - $ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null || isqlplusctl start'
;;
isqlstop)
su - $ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null && isqlplusctl stop || echo "isqlplus is not running"'
;;
lsnstart)
su - $ORA_OWNER -c 'lsnrctl status &>/dev/null && echo "listen is already running" || lsnrctl start &>/dev/null'
;;
lsnstop)
su - $ORA_OWNER -c 'lsnrctl status &>/dev/null && lsnrctl stop &>/dev/null || echo "lsnrctl is not already running"'
;;
*)
echo "USAGE: $0 {start|stop|lsnstart|lsnstop|emstart|emstop|isqlstart|isqlstop}"
echo -e "\tstart : database start"
echo -e "\tstop : database stop"
echo -e "\tlsnstart : listen start"
echo -e "\tlsnstop : listen stop"
echo -e "\temstart : OEM start"
echo -e "\temstop : OEM stop"
echo -e "\tisqlstart : isqlplus start"
echo -e "\tisqlstop : isqlplus stop"
esac
添加到启动脚本目录
[root@dba ~]# chmod +x /etc/rc.d/init.d/oracle
[root@dba ~]# chkconfig --add oracle
也可以使用service调用
[root@dba ~]# service oracle stop
[root@dba ~]# service oracle start
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26052382/viewspace-731009/
,如需转载,请注明出处,否则将追究法律责任。