|
|
用户名:studyrhce 笔名:大懒猫 地区: 辽宁-大连 行业:其他 |
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
欢迎访问rhce的博客
rhel5.2安装xmms
ubuntu 8.04 vim E185: Cannot find color scheme murphy
Install VMware Server 1.0.6 on Ubuntu 8.04 “Hardy”
Downloading the Requirements
The first step, of course, is to download VMware Server 1.0.6. You’ll want to download the .tar.gz version. This command can be used for a direct download:
wget -c http://download3.vmware.com/software/vmserver/VMware-server-1.0.6-91891.tar.gzThe second step is to install some development tools that we’ll need to get things running. Use the following command or click the package names to install the requirements:
sudo aptitude install build-essential linux-kernel-devel linux-headers-generic xinetdYou will also need to generate a serial number to run VMware Server. Visit this link to register and generate the number of codes you might want. Remember to print the codes or write them down because in my experience they are not emailed to you.
OK, at this point we should have all of the requirements, now we can get to work…
Installation and Configuration
Let’s unpack the VMware archive that we downloaded and run the VMware installer.
tar xf VMware-server-1.0.6-*.tar.gz
cd vmware-server-distrib
sudo ./vmware-install.pl
The Last Step
If you attempt to run vmware at this point you might notice that it spits out some nasty errors and complains at you. There is one more thing we need to setup.
Basically VMware is missing and complaining about some cairo libraries and gcc. So, the simple fix for this is to point to them by using a symbolic link:
sudo ln -sf /usr/lib/gcc/i486-linux-gnu/4.2.3/libgcc_s.so /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1
sudo ln -sf /usr/lib/libpng12.so.0 /usr/lib/vmware/lib/libpng12.so.0/libpng12.so.0At this point you should be able to launch vmware and enjoy some virtualization goodness. Enjoy!
FORWARD:http://ubuntu-tutorials.com/2008/05/30/install-vmware-server-106-on-ubuntu-804-hardy/
CentOS的yum加速
CentOS 5.x下 安装 yum-fastestmirror (yum install yum-fastestmirror)
CentOS 4.x下 安装 yum-plugin-fastestmirror (yum install yum-plugin-fastestmirror)
确保/etc/yum.conf里有 plugins=1 一行
转自:http://tb.blog.csdn.net/TrackBack.aspx?PostId=2194749
Tips: find到带空格文件名用xargs处理的技巧
转自:http://blog.leirahua.com/articles/tips-find%e5%88%b0%e5%b8%a6%e7%a9%ba%e6%a0%bc%e6%96%87%e4%bb%b6%e5%90%8d%e7%94%a8xargs%e5%a4%84%e7%90%86%e7%9a%84%e6%8a%80%e5%b7%a7.html
find和xargs是最好的组合,可以说是linux shell下的瑞士军刀,用xargs配合find,比直接用find的-exec参数,速度更快,用法也更直观。
基本的用法比如:
find ./ -name '*.bak' | xargs rm -rf
一般情况,上面这个命令运行的很好,但是如果找到的文件名代空格,上面的命令运行就可能会出问题了。
find有一个参数-print0,于默认的-print相比,输出的序列不是以空格分隔,而是以null字符分隔。而xargs也有一个参数-0,可以接受以null而非空格间隔的输入流。所以说xargs简直就是为find而生的。上面的问题就很好解决了:
find ./ -name '*.bak' -print0 | xargs -0 rm -rf
Tomcat+Jsp经典配置
Tomcat下JSP、Servlet和JavaBean环境的配置
经常看到jsp的初学者问tomcat下如何配置jsp、servlet和bean的问题,于是总结了一下如何tomcat下配置
jsp、servlet和ben,希望对那些初学者有所帮助。
一、开发环境配置
第一步:下载j2sdk和tomcat:到sun官方站
(java.sun.com/j2se/1.5.0/download.jsp">http://java.sun.com/j2se/1.5.0/download.jsp)下载j2sdk
,注意下载版本为Windows Offline Installation的SDK,同时最好下载J2SE 1.5.0 Documentation,然后到
tomcat官方站点(cgi">http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi)下载
tomcat(下载最新5.5.9版本的tomcat);
第二步:安装和配置你的j2sdk和tomcat:执行j2sdk和tomcat的安装程序,然后按默认设置进行安装即可。
1.安装j2sdk以后,需要配置一下环境变量,在我的电脑->属性->高级->环境变量->系统变量中添加以下环境
变量(假定你的j2sdk安装在c:\j2sdk1.5.0):
JAVA_HOME=c:\j2sdk1.5.0
classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;(.;一定不能少,因为它代表当前路径
)
path=%JAVA_HOME%\bin
接着可以写一个简单的java程序来测试J2SDK是否已安装成功:
public class Test{
public static void main(String args[]){
System.out.println("This is a test program.");
}
}
将上面的这段程序保存为文件名为Test.java的文件。
然后打开命令提示符窗口,cd到你的Test.java所在目录,然后键入下面的命令
javac Test.java
java Test
此时如果看到打印出来This is a test program.的话说明安装成功了,如果没有打印出这句话,你需要仔细
检查一下你的配置情况。
2.安装Tomcat后,在我的电脑->属性->高级->环境变量->系统变量中添加以下环境变量(假定你的tomcat安装
在c:\tomcat):
CATALINA_HOME=c:\tomcat
CATALINA_BASE=c:\tomcat
然后修改环境变量中的classpath,把tomat安装目录下的common\lib下的(可以根据实际追加)servlet.jar追
加到classpath中去,修改后的classpath如下:
classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%
\common\lib\servlet.jar;
接着可以启动tomcat,在IE中访问http://localhost:8080,如果看到tomcat的欢迎页面的话说明安装成功了
。
第三步:建立自己的jsp app目录
1.到Tomcat的安装目录的webapps目录,可以看到ROOT,examples, tomcat-docs之类Tomcat自带的的目录;
2.在webapps目录下新建一个目录,起名叫myapp;
3.myapp下新建一个目录WEB-INF,注意,目录名称是区分大小写的;
4.WEB-INF下新建一个文件web.xml,内容如下:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"java.sun.com/dtd/web-app_2_3.dtd">http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Web Application</display-name>
<description>
A application for test.
</description>
</web-app>
5.在myapp下新建一个测试的jsp页面,文件名为index.jsp,文件内容如下:
<html><body><center>
Now time is: <%=new java.util.Date()%>
</center></body></html>
6.重启Tomcat
7.打开浏览器,输入jsp">http://localhost:8080/myapp/index.jsp 看到当前时间的话说明就成功了。
第四步:建立自己的Servlet:
1.用你最熟悉的编辑器(建议使用有语法检查的java ide)新建一个servlet程序,文件名为Test.java,文
件内容如下:
package test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Test extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out=response.getWriter();
out.println("<html><body><h1>This is a servlet test.</h1></body></html>");
out.flush();
}
}
2 .编译
将Test.java放在c:\test下,使用如下命令编译:
C:\Test>javac Test.java
然后在c:\Test下会产生一个编译后的servlet文件:Test.class
3 .将结构test\Test.class剪切到%CATALINA_HOME%\webapps\myapp\WEB-INF\classes下,也就是剪切那个
test目录到classes目录下,如果classes目录不存在,就新建一个。 现在webapps\myapp\WEB-INF\classes
下有test\Test.class的文件目录结构
4 .修改webapps\myapp\WEB-INF\web.xml,添加servlet和servlet-mapping
编辑后的web.xml如下所示,红色为添加的内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"java.sun.com/dtd/web-app_2_3.dtd">http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Web Application</display-name>
<description>
A application for test.
</description>
<servlet>
<servlet-name>Test</servlet-name>
<display-name>Test</display-name>
<description>A test Servlet</description>
<servlet-class>test.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/Test</url-pattern>
</servlet-mapping>
</web-app>
这段话中的servlet这一段声明了你要调用的Servlet,而servlet-mapping则是将声明的servlet"映射"到地
址/Test上
5 .好了,重启动Tomcat,启动浏览器,输入http://localhost:8080/myapp/Test 如果看到输出This is a
servlet test.就说明编写的servlet成功了。
注意:修改了web.xml以及新加了class,都要重启Tomcat
第四步:建立自己的Bean:
1.用你最熟悉的编辑器(建议使用有语法检查的java ide)新建一个java程序,文件名为TestBean.java,文
件内容如下:
package test;
public class TestBean{
private String name = null;
public TestBean(String strName_p){
this.name=strName_p;
}
public void setame(String strName_p){
this.name=strName_p;
}
public String getName(){
return this.name;
}
}
2 .编译
将TestBean.java放在c:\test下,使用如下命令编译:
C:\Test>javac TestBean.java
然后在c:\Test下会产生一个编译后的bean文件:TestBean.class
3 .将TestBean.class文件剪切到 %CATALINA_HOME%\webapps\myapp\WEB-INF\classes\test下,
4 .新建一个TestBean.jsp文件,文件内容为:
<%@ page import="test.TestBean" %>
<html><body><center>
<%
TestBean testBean=new TestBean("This is a test java bean.");
%>
Java bean name is: <%=testBean.getName()%>
</center></body></html>
5 .好了,重启Tomcat,启动浏览器,输入jsp">http://localhost:8080/myapp/TestBean.jsp 如果看到输出
Java bean name is: This is a test java bean.就说明编写的Bean成功了。
这样就完成了整个Tomcat下的jsp、servlet和javabean的配置。接下来需要做的事情就是多看书、多读别人
的好代码,自己多动手写代码以增强自己在这方面开发的能力了。
jvm应填写到
c:\j2sdk\bin
给你一个简单的配置::::
JSP环境配置心得
首先要说的是,使用jdk+tomcat完全可以配置我们的jsp服务器,不再需要其实任何东东,有很多文章介绍了
Apache,其实根本用不着,一般的学习调试tomcat完全可以胜任了。
安装jdk后,tomcat在安装之前会自动找到jdk的安装路径,一路点击"下一步",经过一段时间的文件复制,
最后"close",完成comcat的安装。
您最好去下载一个版本较高的tomcat,比如4.1以上的,因为它不需要设置太多的系统变量,右击"我的电脑"
,选择"属性"->"高级"->"环境变量"->"系统变量",新建一个TOMCAT_HOME,值设置成你的tomcat所在的路径
,比如:D:\Program Files\Apache Group\Tomcat 5.5,配置完成。
从开始菜单中找到tomcat选项,一般打开顺序是:开始->程序->Apache Tomcat 5.5,选择"Start Tomcat",
让jsp服务器开始运行,此时会打开一个类似Dos的窗口,会显示一些相关的信息。
如果您使用代理上网,一定要先撤掉代理,不然您的jsp程序永远也得不到执行。如果不是代理的,这一步就
跳过了。
打开浏览器,在地址栏中输入:http://localhost:8080,如果看到有老虎(我也不知道是老虎还是猫)的画
面,恭喜您,您成功了一半。
先来享受一下成功的喜悦吧,请输入下面的代码:
<html>
<head>
<title>First Page</title>
</head>
<body>
<H3>Today is: h
<%= new java.util.Date() %>
</H3>
</body>
</html>
将该程序保存为:First.jsp,放到Tomcat的ROOT目录下,然后在浏览器的地址栏中输入:
jsp">http://localhost:8080/First.jsp,(First.jsp跟我们保存的文件名的大小写要一致)回车,如果不出
意外,应该可以看到形如Today is: h Fri Apr 11 08:32:38 CST 2003 的结果。
注意:ROOT是tomcat的默认虚拟目录,如果要改成自己的虚拟目录怎么办呢?请继续往下看吧。
要改成自己的虚拟目录,就要请出server.xml来了,该文件是一个配置文件,在Tomcat\conf目录下,使用任
何文本编辑软件都能打开它,我们先找到下面一句:
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />
这里的port="8080"就是端口,我们完全可以用别的端口来代替,但不能是被系统占用的端口(0--1023),
这里简单提一下。
下面我们再往下找,会发现以下的语句:
</Context>
</Host>
我们就应该找到这两个语句,如果不懂E文,您就认定这两个语句好了。然后我们将该语句更改如下:
</Context>
<Context path="/myjsp" debug="0" docBase="e:\myjsp" reloadable="true">
</Context>
</Host>
这里的path="/myjsp"就是我们就配置的虚拟目录了,以后在地址栏中输入
jsp">http://localhost:8080/myjsp即可。而docBase="e:/myjsp" 则是机器本地路径,他们通过这个语句形
成一个映射关系,其它照抄。
将上面的First.jsp文件放到e:/myjsp目录下,输入
jsp/First.jsp">http://localhost:8080/myjsp/First.jsp,是不是有一种喜上眉梢的感觉?
在论坛里我见得最多的就是很多人不知道javaBean文件放到哪里,老实说开始我也不知道,更令人不解的是
,十个人有九种不同的说法,这更让我们茫然。其实这问题也不是我们想像的那么复杂,我们以一个例子说明:
先建立一个java程序,代码如下:
package hall;
public class SimpleBean {
private String message = "No message specified";
public String getMessage() {
return(message);
}
public void setMessage(String message) {
this.message = message;
}
}
保存为SimpleBean.java,编译后会生成一个包,其实就相当于一个目录,也就是SimpleBean.class会存放在hall目录中,暂且保存起来,将来备用。
再输入以下代码:
<HTML>
<HEAD>
<TITLE>Reusing JavaBeans in JSP</TITLE>
</HEAD>
<BODY>
<CENTER>
<TABLE BORDER=5>
<TR><TH CLASS="TITLE">
Reusing JavaBeans in JSP</TABLE>
</CENTER>
<P>
<jsp:useBean id="test" class="hall.SimpleBean" />
<jsp:setProperty name="test" property="message" value="Hello WWW" />
<H1>Message: <I>
<jsp:getProperty name="test" property="message" />
</I></H1>
</BODY>
保存在我们刚才建立的虚拟目录e:/myjsp下面,并命名为:BeanTest.jsp。
现在我们应该将hall(包)目录放在哪儿呢?别急,我们先在e:/myjsp下建立一个文件夹WEB-INF,然后再在
WEB-INF下建立一个classes文件夹,最后将hall目录放到classes下,当然,hall下的字节码文件
SimpleBean.class也一并要移过来,而SimpleBean.java就和BeanTest.jsp放到同一目录吧(可以不需要放的,自己试试)。
好了,大功告成了,重新启动机器(如果您试了好多次都不行,这一步一定要做),在浏览器中输入:
jsp/BeanTest.jsp">http://localhost:8080/myjsp/BeanTest.jsp,您看到了什么?呵,别告诉我您什么都
没看到,那肯定是您设置的问题了。
好了,文章写完了,我也只是一只菜鸟,所以有写的不准备的地方请多多指教。祝您jsp之旅一路顺风!!!
Java学习 - 技术文章中心
初学者问的诸如:《怎样配置环境变量》《怎样运行Servlet》啊?这样的问题太多了,现在我写一个初学者入门必读,以便对初学者有指导作用!
首先是下载工具:
我建议初学者用Editplus+JDK,我觉得如果用例如JB,Eclipse,JCreator,虽然刚开始的时候比较方便,
但是确使初学者门不知道怎样配置环境变量,
从而难以达到知其然,知其所以然的地步
可以通过如下地址下载:
Editplus(最新版本是v2.11):http://image.chinaitpower.com/files/20050701/13368.exe(要照注册码就自己找吧,网上很多的)
JDK(最新版本是Java2sdk1_5_0):http://image.chinaitpower.com/files/20050701/13370.exe(这是For Windows)
然后就是安装JDK,我是把它装到从c:\JDK目录下面:
然后就是CLASSPATH的问题了:
正如操作系统利用PATH来搜索可执行程序一样,Java运行环境也会遍历CLASSPATH来查找类,即便是
HelloWorld这样简单的程序,JVM也会遍历
CLASSPATH定义的每一个路径,直到找到相应的文件为止。
相信大家用的系统不是2k就是XP,然后就应当如下设置Path:
我的电脑->属性->高级->环境变量
然后在环境变量的Path后面追加: C:\JDK\bin;.;C:\JDK\lib
也可以这样配置:C:\JDK\bin;.;C:\JDK\lib\dt.jar;C:\JDK\lib\tools.jar
★记住:环境变量中的 . 切记不能少,它表示当前路径,如果少掉出现的错误等会就说!
dt.jar是关于运行环境的类库,tools.jar是关于一些工具的类库
如果没有配置:C:\JDK\bin,则会出现 " javac′ 不是内部或外部命令,也不是可运行的程序或批处理文件
小写:
public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello,World!");
}
}
然后把这个文件保存(ctrl + s)到HelloWorld.java,记住大小写一定要分清,是HelloWorld.java不是helloworld.java或者其它的下面就该运行了,开始->运行->cmd
在控制台中把目录切换到当前目录:
javac HelloWorld.java
java HelloWorld
你就会在控制台上看见输出的Hello,World!(没出来?我把电脑吃了:))
javac是编译命令,它把HelloWorld.java编译成HelloWorld.class
java就是解释命令,JVM把HelloWorld.class解释执行.
在这个时候:
1。如果出现Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
那就是你在环境变量中没有加上那个.(dot)
2。如果出现Exception in thread "main" java.lang.NoSuchMethodError: main
或者HelloWorld.java:1: Public class helloworld must be defined in a file called
"HelloWorld.java".
那就是你没有分清大小写的写入这个HelloWorld,或者保存得时候没有保存为HelloWorld.java
这个名字一定要跟public class的名字一样
对于环境变量的问题就说到这里,下面我先所说怎么在Editplus里面编译和运行,在Tools->参数设置->配置用户工具
1.添加工具(添加应用程序)
菜单文字:Compile Java Program
程序:C:\JDK\bin\javac.exe
参数:文件名称
初始目录:文件目录
2.添加工具(添加应用程序)
菜单文字:Run Java Program
程序:C:\JDK\bin\java.exe
参数:文件名称(不含扩展名)
初始目录:文件目录
工具组名称可以随便添,比如Debug Java Program
然后在Tools的下拉菜单中,你就会看见Compile Java Program以及Run Java Program这两个选项,以后你就
可以利用ctrl + 1编译和ctrl +2运行程序了
下面就讨论Servlet的运行:
首先要运行Servlet,则需要JSP/Servlet container,我建议初学者用Tomcat
Tomcat(最新版本5.5):http://image.chinaitpower.com/files/20050701/13377.exe然后把这个压缩包解
压到:
C:\Tomcat
然后再配置环境变量: 添加三个系统变量:
JAVA_HOME: C:\JDK
TOMCAT_HOME: C:\Tomcat
CLASSPATH: %JAVA_HOME%\lib;%TOMCAT_HOME%\lib
Tomcat的环境变量就配置完毕了,下面检验Tomcat是否能够运行:
在控制台中转到C:\Tomcat\bin这个目录,运行startup,然后回出现一个窗口,连跳一大串东西,最后表示Server已经运行
在浏览器中输入http://localhost:8080,出现欢迎界面,则表示Tomcat没问题了
然后和上面一样,写入你的第一个Servlet
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws
ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head><title>");
out.println("This is my first Servlet");
out.println("</title></head><body>");
out.println("<h1>Hello,World!</h1>");
out.println("</body></html>");
}
}
然后照样用javac HelloWorld.java来编译这个文件,如果出现无法import javax.servlet.*
那么就是应该把C:\Tomcat\common\lib里面的servlet.jar(根据实际来看)文件拷贝到C:\JDK\jre\lib\ext中,再次编译,就没有问题了!
然后在Tomcat目录里面的C:\Tomcat\webapps\ROOT里面按如下的文件结构:
ROOT\index.html
ROOT\welcome.jsp
ROOT\WEB-INF\lib\MyServlet.jar(如果你的servlet的.class打成了.jar文件,则放在lib下面)
ROOT\WEB-INF\classes\HelloWorld.class(把上面生成的HelloWorld.class文件放在这个里面)
然后在浏览器中输入http://localhost:8080/servlet/HelloWorld,于是Server众望所归的报错了:Error
404--Not Found
怎么回事呢?
Servlet必须使用C:\Tomcat\webapps\ROOT\WEB-INF这个目录下面的web.xml文件进行注册,用EP打开这个web.xml文件,在里面加入
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/helloworld</url-pattern>
</servlet-mapping>
这样的结构
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
表示指定包含的servlet类.
而以下的结构
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>
表示指定HelloServlet应当映射到哪一种URL模式。
在修改web.xml完毕过后,重新启动Server,然后再输入http://localhost:8080/servlet/HelloWorld,那么偌大一个Hello,World!等着你呢,恭喜你摆平了:)
转自:http://blog.chinaunix.net/u1/56882/showart.php?id=442106
Linux下自动启动数据库脚本
注意文章最后,替换dbstart里的ORACLE_HOME_LISTNER变量!!!
Next, create a file called "/etc/init.d/dbora" as the root user, containing the following.TSH1:/u01/app/oracle/product/92.0:Y
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/u01/app/oracle/product/9.2.0
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
;;
esacUse the chmod command to set the privileges to 750.Associate the dbora service with the appropriate run levels and set it to auto-start using the following command.chmod 750 /etc/init.d/dbora
The relevant instances should now startup/shutdown automatically at system startup/shutdown.chkconfig --level 345 dbora on
dbstart and dbshut lines. The lines to start and stop the listener can be removed under Oracle 10g release 2, as the dbstart command includes an automatic start of the listener.#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/u01/app/oracle/product/10.2.0/db_1
#ORA_HOME=/u01/app/oracle/product/11.1.0/db_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
;;
esacdbstart command includes an automatic start of the listener, so there are some differences between the two versions, but the following represents the preferred method for Oracle 10g.Next, create a file called "/etc/init.d/dbora" as the root user, containing the following.TSH1:/u01/app/oracle/product/9.2.0:Y
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle
PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH
#
if [ ! "$2" = "ORA_DB" ] ; then
if [ "$PLATFORM" = "HP-UX" ] ; then
remsh $HOST -l $ORACLE -n "$0 $1 ORA_DB"
exit
else
rsh $HOST -l $ORACLE $0 $1 ORA_DB
exit
fi
fi
#
case $1 in
'start')
$ORACLE_HOME/bin/dbstart $ORACLE_HOME
;;
'stop')
$ORACLE_HOME/bin/dbshut $ORACLE_HOME
;;
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exitUse the chmod command to set the privileges to 750.Associate the dbora service with the appropriate run levels and set it to auto-start using the following command.chmod 750 /etc/init.d/dbora
The relevant instances should now startup/shutdown automatically at system startup/shutdown.chkconfig --level 345 dbora on
This can be quite problematic when attempting to use this method under FC5 and FC6, where rsh is deprecated. As a result, I prefer to use the "su" command method.# Install the rhs and rsh-server packages from the OS CD/DVD. rpm -Uvh --force rsh-* # Enable rsh and rlogin. chkconfig rsh on chkconfig rlogin on service xinetd reload
dbstart might result in the following error message:This is due to a hard coded path in theFailed to auto-start Oracle Net Listener using /ade/vikrkuma_new/oracle/bin/tnslsnr
dbstart script. To correct this, edit the "$ORACLE_HOME/bin/dbstart" script and replace the following line (approximately line 78):With this:ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
TheORACLE_HOME_LISTNER=$ORACLE_HOME
dbstart script shold now start the listener as expected.
Fedora 7下安装ORACLE 10g R2
You should now have a single directory containing installation files. Depending on the age of the download this may either be named "db/Disk1" or "database".unzip 10201_database_linux32.zip
<IP-address> <fully-qualified-machine-name> <machine-name>
Run the following command to change the current kernel parameters:kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 # semaphores: semmsl, semmns, semopm, semmni kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default=262144 net.core.rmem_max=262144 net.core.wmem_default=262144 net.core.wmem_max=262144
Add the following lines to the /etc/security/limits.conf file:/sbin/sysctl -p
Add the following line to the /etc/pam.d/login file, if it does not already exist:* soft nproc 2047 * hard nproc 16384 * soft nofile 1024 * hard nofile 65536
Disable secure linux by editing the /etc/selinux/config file, making sure the SELINUX flag is set as follows:session required /lib/security/pam_limits.so
Alternatively, this alteration can be done using the GUI tool (Desktop > System Settings > Security Level). Click on the SELinux tab and disable the feature.SELINUX=disabled
Create the new groups and users:# From Fedora 7 DVD cd /media/dvd/Fedora rpm -Uvh setarch-* rpm -Uvh --force tcl-* rpm -Uvh compat-db-* rpm -Uvh --force libXau-devel-* # Not available on Fedora 7 DVD, but available from standard yum repository. yum install libXp libaio yum install compat-libstdc++* compat-libf2c* compat-gcc* compat-libgcc*
Create the directories in which the Oracle software will be installed:groupadd oinstall groupadd dba groupadd oper useradd -g oinstall -G dba oracle passwd oracle
Login as root and issue the following command:mkdir -p /u01/app/oracle/product/10.2.0/db_1 chown -R oracle.oinstall /u01
Edit the /etc/redhat-release file replacing the current release information (Fedora release 7 (Moonshine)) with the following:xhost +<machine-name>
Login as the oracle user and add the following lines at the end of the .bash_profile file:redhat-4
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=TSH1; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; 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
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fiStart the Oracle Universal Installer (OUI) by issuing the following command in the database directory:DISPLAY=<machine-name>:0.0; export DISPLAY
Enter the appropriate ORACLE_HOME and name then continue with the installation../runInstaller
Finally edit the /etc/oratab file setting the restart flag for each instance to 'Y':Fedora release 7 (Moonshine)
TSH1:/u01/app/oracle/product/10.2.0/db_1:Y
[转贴]sed学习笔记
sed学习笔记 |
|---|
| 作者:佚名 来源:Linux时代 (2007-02-08 17:22:25) |
++sed 编辑指令的格式如下 : [address1[,address2]]function[argument] #address1/2可为行数或regular expression, 函数参数 function[argument] 为 sed 的内定函数 #/apple/,/orange/d 表示删除含有 "apple" 至 "orange" 字符串的数据行 ++函数参数 功能列表: label 建立 script file 内指令互相参考的位置。 # 建立批注 { } 集合有相同位址参数的指令。 ! 不执行函数参数。 = 印出资料行数( line number )。 a\ 添加使用者输入的数据。 b label 将执行的指令跳至由 : 建立的参考位置。 c\ 以使用者输入的数据取代数据。 d 删除数据。 D 删除 pattern space 内第一个 newline 字母 \ 前的数据。 g 拷贝数据从 hold space。 G 添加资料从 hold space 至 pattern space 。 h 拷贝数据从 pattern space 至 hold space 。 H 添加资料从 pattern space 至 hold space 。 l 印出 l 资料中的 nonprinting character 用 ASCII 码。 i\ 插入添加使用者输入的数据行。 n 读入下一笔资料。 N 添加下一笔资料到 pattern space。 p 印出资料。 P 印出 pattern space 内第一个 newline 字母 \ 前的数据。 q 跳出 sed 编辑。 r 读入它檔内容。 s 替换字符串。 t label 先执行一替换的编辑指令 , 如果替换成牛p>则将编辑指令跳至 : label 处执行。 w 写资料到它文件内。 x 交换 hold space 与 pattern space 内容。 y 转换(transform)字符。 ++ 函数参数 s 表示替换(substitute)文件内字符串。其指令格式如下 : [address1[ ,address2]] s/pattern/replacemen/[flag] #flag : 主要用它来控制一些替换情况 : 当 flag 为 g 时 , 代表替换所有符合(match)的字符串 。 当 flag 为十进制数 m 时 , 代表替换行内第 m 个符合的字符串。 当 flag 为 p 时 , 代表替换第一个符合 pattern 的字符串后 , 将数据输出标准输出文件。 当 flag 为 w wfile 时 , 代表替换第一个符合 pattern 的字符串后 , 输出到 wfile 檔内(如果 wfile 不存在 , 则会重新开启名为 wfile 的档案)。 #数据文件的 "test" 被替换成 "test my car" sed -e 's/test/& my car/' filename ## &:代表其前 pattern 字符串 #数据文件的 "test my car" 被替换成 "[my car test]" sed -e 's/\(test\) \(my\) \(car\)/[\2 \3 \1]/' filename #\n代表pattern中被第 n 个 \(XX\)所括起来的字符串 ++函数参数 d 表示删除数据行 , 其指令格式如下: [address1[ ,address2]] d ++函数参数 a 表示将资料添加到文件中。其指令格式如下: [address1] a\ 使用者所输入的数据 sed -e '/美国人/a\中国人' filename #添加 "中国人" 在含 "美国人" 字符串的数据行后 #如果需要插入多行,可以加\n ++函数参数 i 表示将资料插入文件中。其指令格式如下: [address1] i\ 使用者所输入的数据 ++函数参数 r 表示读入它档案内容到檔中。其指令格式如下 : [address1] r 它檔名称 ++函数参数 w 表示将檔中的写到它檔内。其指令格式如下 : [address1[ ,address2]] w 它檔名称 ++函数参数 y 表示转换数据中的字符。其指令格式如下 : [address1[ ,address2]]y /xyz…/abc…/ #其中 abc… 与 xyz… 的字符数必须相同,a字符转换成x字符、b转成y、c转成z… sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' input.dat #字母大小的转换。 ++函数参数 ! 表示不执行函数参数。当有如下指令时 , [address1[ , address2]] ! 函数参数 sed -e '/1996/!d' input.dat #删除 除了含 "1996" 字符串外的所有行 ++参数n表示读入下一行资料。其指令格式如下: [address1[ ,address2]] n sed -n -e 'n' -e 'p' infro.dat #输出 input.dat 文件内偶数行资料 ++函数参数 q 表示跳离 sed 。其指令格式如下: [address1] q ++函数参数 = 表示印出资料的行数。其指令格式如下: [address1 ,[address2]] = sed -e '=' input.dat #印出资料的行数 ++ 函数参数#后的文字为注解,当注解超过多行时,其行间须以"\"换行字符相隔 ++函数参数 N 表示添加下一笔资料在 pattern space 内。其指令格式如下: [address1 ,[address2]] N #将下述两行数据合并。假设 input.dat 的内容如下 : #The UNIX #Operating System sed -e 'N' -e 's/\n/ /' input.dat ++函数参数 D 表示删除 pattern space 内的第一行资料。其指令格式如下: [address1,address2]D #函数参数 D 与 d 的比较如下 : 当 pattern space 内只有一数据行时 , D 与 d 作用相同。 当 pattern space 内有多行资料行时 D 表示只删除 pattern space 内第一行资料 ; d 则全删除。 D 表示执行删除后 , pattern space 内不添加下一笔数据 , 而将剩下的数据重新执行 sed script ; d 则读入下一行后执行 sed script。 ++函数参数 P 表示印出 pattern space 内的第一行资料。其指令格式如下: [address1,address2] P ++输出 input.dat 文件内奇数行资料。假设 input.dat 檔内容如下: #The #UNIX #System sed -n -e 'N' -e 'P' infro.dat #说明: 在命令列上 #以选项 -n , 将数据输出的控制权(参照[section2.5])转给指令。 #利用函数参数 N 将偶数行添加至 pattern space 内奇数行后。 #利用函数参数 P 将 pattern space 内的第一行(奇数行)输出。 #在奇数行输出后 , pattern space 内剩下的数据行(偶数行)则被放弃输出。最后 , 整个输出只有原先的奇数行数据。 ++函数参数 h 表示暂存 pattern space 的资料至 hold space。其指令格式如下: [address1 ,[address2]] h #函数参数H与h唯一差别是,sed执行h时,数据盖掉(overwrite) hold space内原来的数据,而H,数据则是"添加(append)"在 hold space 原来数据后. ++函数参数 g 表示与函数参数 h 相反的动作 , 它表示将 hold space 内资料放回 pattern space 内。其指令格式如下 : [address1,address2]g #函数参数G与g唯一差别是,sed 执行g时,数据盖掉(overwrite) pattern space内原来的数据,而G,数据则是"添加(append)"在 pattern space原来数据后. ++函数参数 x 表示交换 hold space 与 pattern space 内的数据。其指令格式如下 : [address1 ,[address2]] x sed -e '1h' -e '3x' input.dat #将 input.dat 文件内第 1 行资料取代第 3 行资料 #以函数参数 h 将第 1 资料存入 hold space ; 当第 3 行数据出现在 pattern space , 以函数参数 x 交换 hold space 与 pattern space 的内容。如此 , 第 3 行资料就被第 1 资料替代。 ++ b、:label 函数参数 : 与函数参数 b 可在 sed script 内建立类似 BASIC 语言中 GOTO 指令的功能。其中 , 函数参数 : 建立标记;函数参数 b 将下一个执行的指令 branch 到标记处执行。函数参数 : 与 b , 在 script file 内配合的情况如下 编辑指令m1 :记号 编辑指令m2 [address1,[address2]]b [记号] 其中 , 当 sed 执行至指令 [address1,[address2]]b [记号] 时 , 如 pattern space 内的数据符合地址参数 , 则 sed 将下一个执行的位置 branch 至由 :记号(批注[14])设定的标记处 , 也就是再由 "编辑指令m2" … 执行。另外 , 如果指令中函数参数 b 后没有记号 , 则 sed 将下一个执行的指令 branch 到 script file 的最后 , 利用此可使 sed script 内有类似 C 语言中的 case statement 结构。 #将 input.dat 文件内数据行的开头字母重复印 40 次。假设 input.dat 檔的内容如下 : A B C #sed 命令列如下 : sed -e '{ :p1 /A/s/A/AA/ /B/s/B/BB/ /C/s/C/CC/ /[ABC]\{40\}/b b p1 }' input.dat ++基本上 , 函数参数 t 与 函数参数 b 的功能类似 , 除了在执行 t 的 branch 前 , 会先去测试其前的替换指令有没有执行替换成功外。在 script file 内的情况如下: 编辑指令m1 :记号 编辑指令m2 s/…/…/ [address1,[address2]]t [记号] 编辑指令m3 其中 , 与函数参数 b 不同处在于 , 执行函数参数 t branch 时 , 会先检查其前一个替换指令成功与否。如成功 , 则执行 branch ; 不成功 , 则不 branch , 而继续执行下一个编辑指令 ##将 input.dat 文件中资料 A1 替换成 C1、C1 替换成 B1、B1 替换成 A1。input.dat 檔的内容如下: 代号 B1 A1 B1 C1 A1 C1 说明 : input.dat 文件中全部数据行只需要执行一次替换动作 , 但为避免数据被替换多次 , 所以利用函数参数 t 在 sed script 内形成一类似 C 语言中 case statement 结构 , 使每行数据替换一次后能立即用函数参数 t 跳离替换编辑。 sed 命令列 : sed -e '{ s/A1/C1/ t s/C1/B1/ t s/B1/A1/ t }' input.dat ++常用的 regular expression 普通字符 由普通字符所组成的 regular expression 其意义与原字符串字面意义相同。 ^字符串 限制字符串必须出现于行首 $字符串 限制字符串必须出现行尾。 . 表示任意一字符。 […] 字符集合, 用以表示两中括号间所有字符当中的任一个 ,如 [^…]表示两中括号间所有字符以外的字符。 -& 字符集合中可用"&"指定字符的范围。 * 用以形容其前的字符(或字符集合)可重复任意多次 。 \n 表示嵌入新行字符(imbedded new line character)。 \(…\) 于 regular expression 中使用"\(" "\)"来括住一部份的 regular expression ; 其后可用"\1"来表示第一个被"\(" "\)"括住的部份。若 regular expression 中使用数次的"\(" "\)"来括住不同的部份 , 则依次使用"\1","\2","\3",…(最多可到"\9")。 (http://www.fanqiang.com) |