1、 修改Oracle系统配置文件/etc/oratab
/etc/oratab 格式为: SID:ORACLE_HOME:AUTO
把AUTO域设置为Y(大写),只有这样,oracle 自带的dbstart和dbshut才能够发挥作用。我的为:
ora9i:/home/oracle/ora/products/9.2.0:Y
2、 编写服务脚本:
如下
#!/bin/bash
#
#################FUNCTION#############
#
# AutoStart Oracle and listener
# AutoStop Oracle and listener
#
#####################################
#
# Created by ZhouYS 2003-11-26
#
case "$1" in
start)
echo "Starting Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Databasee as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - oracle -c "dbstart" >> /var/log/oracle
echo "Done."
echo "Starting Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - oracle -c "lsnrctl start" >> /var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
stop)
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - oracle -c "lsnrctl stop" >> /var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
echo "Stoping Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - oracle -c "dbshut" >>/var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: oracle {start|stop|restart}"
exit 1
esac
将脚本命名为oracle,保存在/etc/rc.d/init.d下
改变文件属性:chmod 755 oracle
注意:在windows下编辑此文件时有DOS格式字符导致在linux下不能够正常运行,建议用gedit 或用 vi编辑
3、建立服务连接:
系统启动时启动数据库,我们需要以下连结∶
--------------------------------------------------------------------------------
$ ln -s ../init.d/oracle /etc/rc.d/rc2.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc3.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc5.d/S99oracle #rc4.d unused
--------------------------------------------------------------------------------
要在重新启动时停止数据库,我们需要以下连结∶
--------------------------------------------------------------------------------
$ ln -s ../init.d/oracle /etc/rc.d/rc0.d/K01oracle # 停止
$ ln -s ../init.d/oracle /etc/rc.d/rc6.d/K01oracle # 重新启动
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class GetMobileUserAgent {
protected boolean ifBlock;
public GetMobileUserAgent()
{
ifBlock=true;
}
public boolean blockUpBlackUa(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException
{
String userAgent = request.getHeader("User-Agent").toLowerCase();
String white_gateway[]={"12.25.203.11","202.108.235.154"};
String black_userAgent[]={"opera","msie","opmv-sdk","m3gate","up.browser"};
String remote_ip = request.getRemoteAddr();
for(int i=0;i
{
userAgent=userAgent.toLowerCase();
if(userAgent.indexOf(black_userAgent[i])>-1)
{
ifBlock=false;
i=black_userAgent.length;
}
else
continue;
}
for(int i=0;i
{
if(remote_ip.equals(white_gateway[i]))
{
i=white_gateway.length;
ifBlock=true;
}
else
continue;
}
if(!ifBlock)
{
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("
");
out.println("对不起,没有适配您的终端型号的内容。
");
out.println("梦网首页
");
}
return ifBlock;
}
public static void getUserAgent(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException, NoSuchElementException
{
Enumeration enum_header=request.getHeaderNames();
StringBuffer tmpStr=new StringBuffer("");
String String_uaAll=null;
String cur_header ="test";
PrintWriter out = response.getWriter();
String userAgent = request.getHeader("User-Agent").toLowerCase();
userAgent = userAgent.substring(0,userAgent.indexOf("/"));
String path = "d:\\product\\view_cm\\webapps\\root\\mobile_ua\\"+userAgent+ ".txt";
try{
while (enum_header.hasMoreElements())
{
cur_header = enum_header.nextElement().toString();
if(cur_header==null || cur_header.equals(""))
{
new Exception("get the header's name as null!");
}
tmpStr.append(cur_header+"\n\r") ;
Enumeration enum_value = request.getHeaders(cur_header);
while (enum_value.hasMoreElements())
{
tmpStr.append(enum_value.nextElement().toString()+"\n\r");
}
}
tmpStr.append(request.getRemoteAddr()+"\n\r");
tmpStr.append(request.getRemoteHost()+"\n\r");
tmpStr.append(request.getProtocol()+"\n\r");
String_uaAll = tmpStr.toString();
FileWriter fw=new FileWriter(path,false);
fw.write(String_uaAll);
fw.close();
}
catch (Exception e)
{e.printStackTrace();}
}
}