ITPub博客

首页 > 数据库 > Oracle > centos5+oracle11g+tomcat.txt+eclipse及远程布署

centos5+oracle11g+tomcat.txt+eclipse及远程布署

Oracle 作者:泉城老末 时间:2013-12-20 16:40:12 0 删除 编辑

[1] Install some packages 
先查需要的软件有无安装:rpm -q xxx
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh
 
[2] Edit Kernel parameter. 
vi /etc/sysctl.conf
# add at the last
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
(以上参数各安装文档都不相同,再自行调整吧)
sysctl -p (立即生效)
 
[3] Create a user for Oracle. 
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
Create the Oracle and change password
command: /usr/sbin/useradd -g oinstall -G dba -s /bin/bash oracle
         /usr/bin/passwd oracle
Validate the nobody user exists
command: /usr/bin/id nobody
results: this user is almost always created on a base CentOS installation
action : if this user is not created use the following command to create
         /usr/sbin/useradd nobody
vi /etc/pam.d/login
# near line 9: add
session   required   pam_selinux.so close
session  required  /lib/security/pam_limits.so
session   required   pam_limits.so
vi /etc/security/limits.conf
# add at the last
oracle          soft     nproc           2047
oracle          hard     nproc           16384
oracle          soft     nofile          1024
oracle          hard     nofile          65536
vi /etc/profile
# add at the last
if [ $USER = "oracle" ]; then
      if [ $SHELL = "/bin/ksh" ]; then
           ulimit -p 16384
           ulimit -n 65536
      else
           ulimit -u 16384 -n 65536
      fi
fi
 
[4] Switch to a user "Oracle" and configure some settings. 
mkdir /u11
chown -R oracle:oinstall /u11
chmod -R 775 /u11
su - oracle
cd /u11
mkdir oracle
vi ~/.bash_profile
# add at the last
umask 022
ORACLE_BASE=/u11/oracle
ORACLE_SID=ORCL
export ORACLE_SID ORACLE_BASE
=========================================远程xwindow==============================
通过XDMCP远程连接到Red Hat Eenterprise Linux 5 (CentOS 5)的配置不再向以前版本那样需要比较多的步骤,在RHEL5(CentOS 5)中只需要简单的两个步骤即可。
 
1.配置XDM
对GDM的配置:
打开/etc/gdm/custom.conf 配置文件,在第46行[xdmcp]选项下面新增加一行Enable=1,保存退出,如下图
2.启动X WINDOW(init 5)
使用root权限,在CLI执行init 5或者startx。
如果要每次开机都自动启动X WINDOW需要配置/etc/inittab文件第18行,将id:3:initdefault:改成id:5:initdefault:,保存退出,如下图。
gdm-restart
gdm默认是不允许root用户登录的,如果需要启用允许root用户登录,则可在custom.conf中如此修改
[security]
AllowRemoteRoot=true
=================================================================================
[5] 解压安装文件,以oracle登录,运行./runInstaller 
[6] Oracle Installer starts like follows. First, Set your email address and password for receiving some infomation from Oracle like security issues and so on.
此处会有错误connection failed:When you provide both the e-mail address and password, Oracle Configuration Manager checks for connectivity to verify the credentials specified. If there is no direct connectivity to Oracle, the Connection Failed dialog box appears with the Proxy connection method selected . If you want to configure Oracle Configuration Manager to connect to Oracle using an Oracle Support Hub, you must select the Oracle Support Hub radio button . Either of these methods enable you to define a connection to Oracle.
If no connection is possible, check the I want to remain uninformed of critical security issues in my configuration check box on the Connection Failed dialog box. This causes Oracle Configuration Manager to be installed in disconnected mode.
[7] Select "Install database software only".
[8] For this example, select "Single Instance ***". 
[9] Select your language 增加简体中文
[10] Select which edition you install.:Enterprise Edition
[11] Specify base directory and files for Oracle:默认值即可
[12] Specify priviledged group.
[13] Checking settings runs automatically for requirements of installing Oracle. 按要求检查sysctl.conf参数即可,swap不够可忽略。
[14] 按提示以root权限执行相关文件. 
[15] Installation completed. Click "Close" button.
[16] Configure some settings for Oracle user.
vi ~/.bash_profile
# add at the last line
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
========================================配置网络监听====================================
[1] Login as Oracle user and input a command "netca".Check a box "Listener Configuration" and go next.
选取默认即可。
=======================================创建数据库=======================================
[1] Login as a Oracle user and Input a Command "dbca". Click "Next" to proceed. 
字符集:zhs16gbk,连接模式:共享服务器,共享服务器数一般为连接数的1/10。
安装完后提示:Database Control URL 为 https://xxx.yyy.zzz:1158/em
=======================================修改参数命令启动=================================
vi /etc/oratab,将ORCL:/u11/oracle/product/11.2.0/dbhome_1:N改为Y
可用dbstart,dbshut启动关闭数据库,lsnrctl start,lsnrctl stop启动关闭监听
使用dbstart $ORACLE_HOME,dbshut $ORACLE_HOME可同时开启关闭监听及数据库
企业管理器:首先在linux终端输入emctl start dbconsole启动企业管理服务,,然后仔细看下下面的信息提示,有个
https://..../em/aboutApplcation
之类的这个东西。你就把这个COPY到浏览器里就可以了。。
注意:EM要正常使用,需开启监听,同时用火狐浏览器(这个问题搞了半天,IE不行,居然是这个破问题)
======================================打补丁===========================================
Download latest patch: 11.2.0.x
This patch is easy because it is a full installation, therefore you just install the software (with Oracle Universal Installer) in a new Oracle home, stop db, start db using new home and use dbua (upgrade assistant) to upgrade the db.
先安装完整版补丁(和新装类似,需选update,且安装目录需另定一个新目录如:/u11/oracle/product/11.2.0/dbhome_2),安装完成后会启动dbua继续升级工作,按提示选择即可。
升级完成后,需修改oralce的环境变量ORACLE_HOME至新目录:/u11/oracle/product/11.2.0/dbhome_2
======================================中止nmz进程======================================
Oracle database create steps includes an option to configure Enterprise Manager. If you have selected check box to configure Enterprise Manager then Oracle run nmz process.
as well as add the job in oracle cron to start enterprise manger as follows
0,15,30,45 * * * * /u01/app/oracle/product/11.2.0/< Oracle_SID>/ccr/bin/emCCR -cron -silent start
To stop nmz proces you have to run following command:-
/u01/app/oracle/product/11.2.0/< Oracle_SID>/ccr/bin/emCCR stop
Shutdown database process or emctl does not stop emCCR process.
======================================安装tomcat7.x=====================================
1、下载JDK:http://www.oracle.com/technetwork/java/javase/downloads/index.html
tomcat7.x需要JDK至少1.6版,如果需要websocket功能则需1.7版
rpm -ivh jdk-7u45-linux-i586.rpm
2、下载tomcat7.x编译版,解压并置于某处,如:/export/tomcat7
3、设置环境变量:
vi /etc/profile 增加
export CATALINA_HOME=/export/tomcat7
export JAVA_HOME=/usr/java/jdk1.7.0_45
使设置立即生效:source /etc/profile
4、启动tomcat:$CATALINA_HOME/bin/startup.sh
======================================JSP/SEVRLET相关学习===============================
开启web应用管理:编辑conf/tomcat-users.xml,添加:
< role rolename="manager-gui"/>
< user username="tomcat" password="tomcat" roles="manager-gui"/>
后,重启服务,通过:http://xxx.yyy.xxx:8080/manager/登录进入。
编辑manager/context.xml,修改RemoteHostValve可限定访问IP。
修改conf/server.xml:
 < Host name="localhost"  appBase="webapps" unpackWARs="true" >
可设置是否自动发布
修改运行内存:设置环境变量JAVA_OPTS="-Xms128m -Xmx128m"
增加运行安全,以非root帐号运行tomcat
1、添加tomcat帐号及群:
groupadd tomcat
useradd -s /bin/bash -g tomcat tomcat
2、修改tomcat目录所有者
chown -Rf tomcat.tomcat /export/tomcat7
3、切换至tomcat启动或关闭进程
su tomcat startup.sh或su tomcat shutdown.sh
4、由于非root运行tomcat不能以低于1024的端口启动,如要改至80端口需配置防火墙
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -p udp -m udp --dport 80 -j REDIRECT --to-ports 8080
创建虚拟主机
修改conf/server.xml,在Engine单元下增加Host,如:
< Host name= appBase="test1" >< /Host>
=====================================设置tomcat+jdbc+oracle11g===========================
1、修改META-INFO/context.xml,新增内容格式如下:
< Context>
< Resource name="jdbc/oldsix" auth="Container"
              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@127.0.0.1:1521:ORCL"
              username="xxxx" password="xxxx" maxActive="20" maxIdle="10"
              maxWait="-1"/>
< /Context>
部分参数解释:name--------------------jdbc/oldsix中oldsix为你要连接的数据库的名字。
              driverClassName----JDBC驱动类的完整的名称;
              maxActive---------------同时能够从连接池中被分配的可用实例的最大数
              maxIdle------------------可以同时闲置在连接池中的连接的最大数;
              maxWait------------------最大超时时间,以毫秒计;
              password----------------用户密码;
              url--------------------------到JDBC的URL连接,最后面的mysid为你安装时数据库实例的名称;
              username---------------用户名称
其他参数详见:http://commons.apache.org/proper/commons-dbcp/configuration.html
2、修改WEB-INFO/web.xml,新增内容如下:
< resource-ref>
 < description>Oracle Datasource example< /description>
 < res-ref-name>jdbc/oldsix< /res-ref-name>
 < res-type>javax.sql.DataSource< /res-type>
 < res-auth>Container< /res-auth>
< /resource-ref>
3、将安装的oracle11g目录jdbc下的ojdbc6.jar拷贝至$CATALINA_HOME/lib目录下
4、测试代码:
< %@ page contentType="text/html; charset=UTF-8" %>
< %@ page import="java.sql.*"%>
< %@ page import="javax.sql.*"%>
< %@ page import="javax.naming.*"%>
< %
Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/oldsix");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
     ResultSet rst = stmt.executeQuery(" select * from dual");
      while (rst.next()) {
    out.println("< br>");
out.println(""+rst.getString("DUMMY")+"< br>");
    }
    conn.close();
%>
5、说明:第1、2两步修改,只需修改应用目录下的配置文件即可,不需修改$CATALINA_HOME/conf下的。
6、Tomcat JDBC connection pool:按文档,此连接池比上面使用的DBCP性能要好,配置基本相同,只需Resource中增加:
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
即可。
=====================================eclipse在远程tomcat7发布================================
1、修改tomcat的conf/tomcat-users.xml,新增
< role rolename="manager-script"/>
< user username="tomcat" password="xxxx" roles="manager-script"/>
使用此账号做远程发布
2、下载eclipse java EE 版
创建maven project,选archetype-webapp。
3、修改pom.xml文件,增加:
        < plugins>
            < plugin>
                < groupId>org.codehaus.cargo< /groupId>
                < artifactId>cargo-maven2-plugin< /artifactId>
                < version>1.0.6< /version>
                < configuration>
                    < container>
                        < containerId>tomcat6x< /containerId>
                        < type>remote< /type>
                    < /container>
                    < configuration>
                        < type>runtime< /type>
                        < properties>
                            < !-- keep in mind that for tomcat7 the url changed to /manager/text -->
                            < cargo.tomcat.manager.url>http://127.0.0.1:8080/manager/text< /cargo.tomcat.manager.url>
                            < cargo.remote.username>tomcat< /cargo.remote.username>
                            < cargo.remote.password>xxxx< /cargo.remote.password>
                        < /properties>
                    < /configuration>
                    < deployer>
                        < type>remote< /type>
                        < deployables>
                            < deployable>
                                < groupId>${project.groupId}< /groupId>
                                < artifactId>${project.artifactId}< /artifactId>
                                < type>war< /type>
                                < properties>
                                    < context>${project.artifactId}< /context>
                                < /properties>
                            < /deployable>
                        < /deployables>
                    < /deployer>
                < /configuration>
                < executions>
                    < execution>
                        < id>redeploy-war-file-to-tomcat< /id>
                        < phase>install< /phase>
                        < goals>
                            < goal>redeploy< /goal>
                        < /goals>
                    < /execution>
                < /executions>
            < /plugin>
        < /plugins>
4、Run=>Run As=>Maven Install,即可将项目发布到远程tomcat上。
eclipse新装,可能相关需要的插件还需下载,所以可以先创maven项目后,Build一下,以便eclipse自动下载。
pom.xml中添加的有关cargo插件,会在Build时自动下载。

 

 

最后一个问题:为何新浪左尖括号后不能直接跟字符,会被直接吃掉???我只好在< 后空一空格才能显示,不会这么烂吧。。。

<!-- 正文结束 -->

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29072223/viewspace-1116177/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2013-07-25