其实最重要的就是yum源吗。SL自带的里面既没有nginx也没有tomcat7。
1,搞定nginx,她家自己有源的:
- rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
- yum info nginx
- yum -y install nginx
- rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
- yum -y install yum-priorities #这个是jpackage依赖的包要先装
- rpm -Uvh http://mirrors.dotsrc.org/jpackage/6.0/generic/free/RPMS/jpackage-release-6-3.jpp6.noarch.rpm
- yum -y install tomcat7 tomcat7-webapps tomcat7-admin-webapps tomcat-native
注意了,其中有一个tomcat7-lib-7.0.34-3.jpp6.noarch.rpm 似乎只有哈佛大学有源,速度时快时慢有时候会断,这个时候用向上键重新运行yum命令,也许要数次,它会断点续传的最终会传完并安装。
启用tomcat-pool
我的server.xml
- <?xml version='1.0' encoding='utf-8'?>
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <!-- Note: A "Server" is not itself a "Container", so you may not
- define subcomponents such as "Valves" at this level.
- Documentation at /docs/config/server.html
- -->
- <Server port="8005" shutdown="SHUTDOWN">
- <!-- Security listener. Documentation at /docs/config/listeners.html
- <Listener className="org.apache.catalina.security.SecurityListener" />
- -->
- <!--APR library loader. Documentation at /docs/apr.html -->
- <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
- <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
- <Listener className="org.apache.catalina.core.JasperListener" />
- <!-- Prevent memory leaks due to use of particular java/javax APIs-->
- <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
- <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
- <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
- <!-- Global JNDI resources
- Documentation at /docs/jndi-resources-howto.html
- -->
- <GlobalNamingResources>
- <!-- Editable user database that can also be used by
- UserDatabaseRealm to authenticate users
- -->
- <Resource name="UserDatabase" auth="Container"
- type="org.apache.catalina.UserDatabase"
- description="User database that can be updated and saved"
- factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
- pathname="conf/tomcat-users.xml" />
- </GlobalNamingResources>
- <!-- A "Service" is a collection of one or more "Connectors" that share
- a single "Container" Note: A "Service" is not itself a "Container",
- so you may not define subcomponents such as "Valves" at this level.
- Documentation at /docs/config/service.html
- -->
- <Service name="Catalina">
- <!--The connectors can use a shared executor, you can define one or more named thread pools-->
- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
- maxThreads="2000" minSpareThreads="100"/>
- <!-- A "Connector" represents an endpoint by which requests are received
- and responses are returned. Documentation at :
- Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
- Java AJP Connector: /docs/config/ajp.html
- APR (HTTP/AJP) Connector: /docs/apr.html
- Define a non-SSL HTTP/1.1 Connector on port 8080
- -->
- <!--
- <Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" />
- -->
- <!-- A "Connector" using the shared thread pool-->
- <Connector executor="tomcatThreadPool"
- port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
- connectionTimeout="20000"
- redirectPort="8443" />
- <!-- Define a SSL HTTP/1.1 Connector on port 8443
- This connector uses the JSSE configuration, when using APR, the
- connector should be using the OpenSSL style configuration
- described in the APR documentation -->
- <!--
- <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
- maxThreads="150" scheme="https" secure="true"
- clientAuth="false" sslProtocol="TLS" />
- -->
- <!-- Define an AJP 1.3 Connector on port 8009 -->
- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
- <!-- An Engine represents the entry point (within Catalina) that processes
- every request. The Engine implementation for Tomcat stand alone
- analyzes the HTTP headers included with the request, and passes them
- on to the appropriate Host (virtual host).
- Documentation at /docs/config/engine.html -->
- <!-- You should set jvmRoute to support load-balancing via AJP ie :
- <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
- -->
- <Engine name="Catalina" defaultHost="localhost">
- <!--For clustering, please take a look at documentation at:
- /docs/cluster-howto.html (simple how to)
- /docs/config/cluster.html (reference documentation) -->
- <!--
- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
- -->
- <!-- Use the LockOutRealm to prevent attempts to guess user passwords
- via a brute-force attack -->
- <Realm className="org.apache.catalina.realm.LockOutRealm">
- <!-- This Realm uses the UserDatabase configured in the global JNDI
- resources under the key "UserDatabase". Any edits
- that are performed against this UserDatabase are immediately
- available for use by the Realm. -->
- <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
- resourceName="UserDatabase"/>
- </Realm>
- <Host name="localhost" appBase="webapps"
- unpackWARs="true" autoDeploy="true">
- <!-- SingleSignOn valve, share authentication between web applications
- Documentation at: /docs/config/valve.html -->
- <!--
- <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
- -->
- <!-- Access log processes all example.
- Documentation at: /docs/config/valve.html
- Note: The pattern used is equivalent to using pattern="common" -->
- <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="localhost_access_log." suffix=".txt"
- pattern="%h %l %u %t "%r" %s %b" />
-
- </Host>
- </Engine>
- </Service>
- </Server>
应用里面的DataAccessContext.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jee="http://www.springframework.org/schema/jee"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
- <property name="jndiName">
- <value>java:comp/env/jdbc/orcl</value> #应用里面定义好自己数据源的名字
- </property>
- </bean>
- <bean id="DbTxnManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource" />
- <!--<property name="dataSource" ref="jndiDataSource" />-->
- </bean>
- <!-- app container connection and transaction -->
- <jee:jndi-lookup id="jndiDataSource" jndi-name="jdbc/orcl" /> #这里也是,我反正就写着两个地方就行了
- <!-- jta Transaction for websphere v4,v5,v6 -->
- <bean id="wsJtaTm" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean"/>
- <bean id="JtaTxnManager" class="org.springframework.transaction.jta.JtaTransactionManager">
- <property name="transactionManager" ref="wsJtaTm"/>
- </bean>
- <bean id="NoContainedTxnManager" class="com.infoservice.framework.util.WebsphereNoContainedTransactionManager">
- <property name="jndiUserTransaction"><value>jta/usertransaction</value></property>
- </bean>
- <!-- other <bean/> definitions here -->
- <!-- other <bean/> definitions here -->
- <bean id="DBInfo" class="com.infoservice.po3.core.context.DBInfo">
- <property name="defTxnMng"><value>DbTxnManager</value></property>
- <!-- <property name="defDataSource"><value>jndiDataSource</value></property> -->
- <property name="defDataSource"><value>dataSource</value></property>
- <property name="noContainedTxnMng"><value>DbTxnManager</value></property>
- <property name="dbTypeMaps">
- <map>
- <entry key="dataSource"><value>oracle</value></entry>
- <entry key="jndiDataSource"><value>oracle</value></entry>
- </map>
- </property>
- </bean>
- <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor" lazy-init="true">
- <property name="defTxnMng"><value>DbTxnManager</value></property>
- <property name="defDataSource"><value>jndiDataSource</value></property>
- <!-- <property name="defDataSource"><value>dataSource</value></property> -->
- <property name="noContainedTxnMng"><value>DbTxnManager</value></property>
- <property name="dbTypeMaps">
- <map>
- <entry key="dataSource"><value>oracle</value></entry>
- <entry key="jndiDataSource"><value>oracle</value></entry>
- </map>
- </property>
- </bean>
- </beans>
特色是最后部分的蓝色字体,这个据说是Tomcat7开始有的数据源池,专门针对早期弱点开发的性能优秀。
- <?xml version='1.0' encoding='utf-8'?>
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <!-- The contents of this file will be loaded for each web application -->
- <Context>
- <!-- Default set of monitored resources -->
- <WatchedResource>WEB-INF/web.xml</WatchedResource>
- <!-- Uncomment this to disable session persistence across Tomcat restarts -->
- <!--
- <Manager pathname="" />
- -->
- <!-- Uncomment this to enable Comet connection tacking (provides events
- on session expiration as well as webapp lifecycle) -->
- <!--
- <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
- -->
- <Resource name="jdbc/orcl" #这里对应上应用里面的数据源名字
- auth="Container"
- type="javax.sql.DataSource"
- factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
- testWhileIdle="false"
- testOnBorrow="false"
- testOnReturn="false"
- validationQuery="SELECT 1"
- validationInterval="30000"
- timeBetweenEvictionRunsMillis="30000"
- maxActive="500"
- minIdle="50"
- maxWait="10000"
- initialSize="50"
- removeAbandonedTimeout="60"
- removeAbandoned="true"
- logAbandoned="true"
- minEvictableIdleTimeMillis="30000"
- jmxEnabled="true"
- jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
- org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
- username="orcl_user"
- password="password"
- driverClassName="oracle.jdbc.driver.OracleDriver"
- url="jdbc:oracle:thin:@192.168.100.200:1521:orcl"/>
- </Context>
这样装出来的Tomcat7有service,启停 service tomcat7 start/stop/restart
如果想给JVM增加内存就不知道如何动手了,没有startup.sh/catalina.sh可用来配置JAVA_OPTS!
仔细查看了/etc/rc.d/init.d/tomcat7,嘿嘿,发现了/etc/tomcat7/tomcat7.conf,请自行理解里面的东东啦!