﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Sealyu-随笔分类-web服务器</title><link>http://www.blogjava.net/sealyu/category/30745.html</link><description>--- The devil's in the Details</description><language>zh-cn</language><lastBuildDate>Fri, 11 Jun 2010 18:14:32 GMT</lastBuildDate><pubDate>Fri, 11 Jun 2010 18:14:32 GMT</pubDate><ttl>60</ttl><item><title>JBossCache- TreeCache体验(转)</title><link>http://www.blogjava.net/sealyu/archive/2010/05/18/321225.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Mon, 17 May 2010 20:19:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2010/05/18/321225.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/321225.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2010/05/18/321225.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/321225.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/321225.html</trackback:ping><description><![CDATA[<div>
TreeCache是一种结构化的、基于复制的事务缓存。TreeCache是JBoss应用服务器中集群服务—包括JNDI集群、HTTP和EJB的
Sesssion集群、JMS集群—的基础框架。其可以单独使用，可以集成到JBossAS应用，也可以集成到其他的应用服务器上。TreeCache是
一种树状结构，每个节点拥有一个名字和多个或者没有子节点，除跟节点没有子节点其他节点有且只有一个父母节点，可以通过路径名来访问子节点
（FQN：Full Qualified
Name），在一个TreeCache中可以存在多棵树，，即可以有多个根节点。当应用于分布式环境时，由于TreeCache是基于复制的，每个子节点
的值必须是可序列化的。
<br />
&nbsp;&nbsp;&nbsp;&nbsp;
在下面中，将通过例子来了解TreeCache的功能及其配置，使用JBossCache1.4和JDK5.0。首先是一个最基本使用TreeCache
的程序例子并配置一个TreeCache的配置骨架（各种常用的配置可参见jboss-cache-dist-1.4.0.CR1版本的etc目录，如下
各种配置参考也可见该目录下的范例配置，以下不再强调），见下：
<br />
<br />
treecache.xml：
<br />
<br />
<br />
&lt;server&gt;
<br />
&nbsp;&nbsp;&nbsp; &lt;mbean code="org.jboss.cache.TreeCache"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="jboss.cache:service=TreeCache"&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;depends&gt;jboss:service=Naming&lt;/depends&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;depends&gt;jboss:service=TransactionManager&lt;/depends&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute
name="ClusterName"&gt;TreeCache-Cluster&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute name="ClusterConfig"&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;config&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;UDP mcast_addr="228.1.2.3" mcast_port="48866"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ip_ttl="64" ip_mcast="true"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mcast_send_buf_size="150000"
mcast_recv_buf_size="80000"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ucast_send_buf_size="150000"
ucast_recv_buf_size="80000"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; loopback="false"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;PING timeout="2000" num_initial_members="3"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; up_thread="false" down_thread="false"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;MERGE2 min_interval="10000"
max_interval="20000"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FD_SOCK/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;VERIFY_SUSPECT timeout="1500"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; up_thread="false" down_thread="false"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pbcast.NAKACK gc_lag="50"
retransmit_timeout="600,1200,2400,4800"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max_xmit_size="8192" up_thread="false"
down_thread="false"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;UNICAST timeout="600,1200,2400"
window_size="100" min_threshold="10"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; down_thread="false"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pbcast.STABLE desired_avg_gossip="20000"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; up_thread="false" down_thread="false"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FRAG frag_size="8192"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; down_thread="false" up_thread="false"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pbcast.GMS join_timeout="5000"
join_retry_timeout="2000"
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shun="true" print_local_addr="true"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pbcast.STATE_TRANSFER up_thread="true"
down_thread="true"/&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/config&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp; &lt;/mbean&gt;
<br />
&lt;/server&gt;
<br />
&nbsp;&nbsp;
其中ClusterConfig配置在前面JavaGroups的介绍详细介绍，其它配置比较简单，需要进一步了解请参见TreeCache文档。
<br />
&nbsp;&nbsp; 一、Cache分类
<br />
&nbsp;&nbsp;
TreeCache按功能分为三类：本地(Local)Cache、复制(Replication)Cache和失效
(Invalidation)Cache。本地Cache只应用于本地环境，后两个Cache可应用于分布式环境，其中，在分布式环境中，复制Cache
当一个Cache实例的一个节点值发生变化时会将变化复制到其它实例中，而失效Cache是当一个Cache实例的一个节点值发生变化时会将其它实例的相
应节点的值设为空，让其重新去获得该值，可通过这种方式缓存大对象以减少在实例中复制对象的代价。分布式Cache（复制和失效Cache）又分为两种，
同步（REPL_ASYNC）和异步（REPL_SYNC），同步Cache是在一个Cache实例做修改时，等待变化应用到其它实例后才返回，而异步
Cache是在一个Cache实例做修改时，即刻返回。其配置见下：
<br />
!--
<br />
&nbsp; Valid modes are LOCAL
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; REPL_ASYNC
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; REPL_SYNC
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INVALIDATION_ASYNC
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INVALIDATION_SYNC
<br />
-&gt;
<br />
attribute name="CacheMode"&gt;REPL_SYNC&lt;/attribute&gt;
<br />
<br />
&nbsp;&nbsp; 二、事务和并行(Transaction And Concurrent)
<br />
&nbsp;&nbsp;
TreeCache是一种事务Cache，与JDBC一样，其包括两方面内容：锁和隔离级别。锁分为悲观锁和乐观锁，当使用悲观锁时，分为五个隔离级别，
分别是SERIALIZABLE、REPEATABLE_READ
(default)、READ_COMMITTED、READ_UNCOMMITTED和NONE，隔离级别逐步减弱。乐观锁也叫版本锁，其对数据进行操
作时，将其复制到临时区，操作之后将版本与原有数据比较，如果一致则将递增版本并写回，如果不一致则回滚，由于乐观锁仅在复制出数据和提交数据时对数据加
锁，所以并行度更高，但如果写操作比较频繁地话则容易出现冲突导致回滚。TreeCache默认使用悲观锁。使用TreeCache时，需要使用容器提供
的事务管理器，一般使JBossTransactionManagerLookup和GenericTransactionManagerLookup，
前者应用于JBOSS服务器，后者应用于其他服务器，也可使用DummyTransactionManagerLookup用于测试。如上介绍的配置如
下：
<br />
attribute name="NodeLockingScheme"&gt;OPTIMISTIC&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute
name="IsolationLevel"&gt;REPEATABLE_READ&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute
name="TransactionManagerLookupClass"&gt;org.jboss.cache.DummyTransactionManagerLookup&lt;/attribute&gt;
<br />
<br />
<br />
&nbsp;&nbsp; 三、逐出策略(Eviction Policy)
<br />
&nbsp;&nbsp;
由于内存数量的局限，不可能将所有的Cache数据存放在内存中，但使用内存达到一定极限时，会将部分数据清除出内存，保存到其它持久媒质中，定义的什么
时候清除、如何清除的策略就是逐出策略。自定义一个逐出策略需要实现org.jboss.cache.eviction.EvictionPolicy、
org.jboss.cache.eviction.EvictionAlgorithm、
<br />
g.jboss.cache.eviction.EvictionQueue
和org.jboss.cache.eviction.EvictionConfiguration四个接口，系统提供了LRU(Least
recently used，最近最少使用)、LFU(Least Frequently Used最不经常使用)、FIFO(First In
First Out先进先出)、MRU(Most Recently
Used最近最经常使用)四种实现，详细参见org.jboss.cache.eviction包的源代码。配置如下：
<br />
&lt;attribute name="EvictionPolicyConfig"&gt;
<br />
&nbsp;&nbsp; &lt;config&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute
name="wakeUpIntervalSeconds"&gt;5&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;region name="/_default_"&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute name="maxNodes"&gt;5000&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute
name="timeToLiveSeconds"&gt;1000&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/region&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;region name="/org/jboss/data"
<br />
policyClass="org.jboss.cache.eviction.FIFOPolicy"&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute name="maxNodes"&gt;5000&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/region&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;region name="/test/"
policyClass="org.jboss.cache.eviction.MRUPolicy"&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute name="maxNodes"&gt;10000&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/region&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;region name="/maxAgeTest/"&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute name="maxNodes"&gt;10000&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute
name="timeToLiveSeconds"&gt;8&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute name="maxAgeSeconds"&gt;10&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/region&gt;
<br />
&nbsp;&nbsp; &lt;/config&gt;
<br />
&lt;/attribute&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp; 四、Cache加载
<br />
&nbsp;
由于逐出策略的存在，那么当我们重新需要获得一个原来在缓存中但确由内存原因被逐出的数据时，就需要定义一种加载策略，使地可以重新找回数据，同
时，Cache加载也肩负在将数据逐出时将数据保存到持久媒质的责任。
<br />
&nbsp;
根据将数据保存媒质的不同，Cache加载包括FileCacheLoader、JDBCCacheLoader等等，可以同时使用多种加载器来灵活定制
加载策略。例见下：
<br />
&lt;attribute name="CacheLoaderConfiguration"&gt;
<br />
&nbsp;&nbsp;&nbsp; &lt;config&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;passivation&gt;false&lt;/passivation&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;preload&gt;/&lt;/preload&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;shared&gt;true&lt;/shared&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cacheloader&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;class&gt;org.jboss.cache.loader.ClusteredCacheLoader&lt;/class&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;properties&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timeout=1000
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/properties&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;async&gt;true&lt;/async&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;fetchPersistentState&gt;false&lt;/fetchPersistentState&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ignoreModifications&gt;false&lt;/ignoreModifications&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;purgeOnStartup&gt;false&lt;/purgeOnStartup&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/cacheloader&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cacheloader&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;class&gt;org.jboss.cache.loader.JDBCCacheLoader&lt;/class&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;properties&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.table.name=jbosscache
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.table.create=true
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.table.drop=true
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.table.primarykey=jbosscache_pk
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.fqn.column=fqn
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.fqn.type=varchar(255)
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.node.column=node
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.node.type=longblob
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.parent.column=parent
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.driver=com.mysql.jdbc.Driver
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.user=root
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cache.jdbc.password=
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/properties&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;async&gt;true&lt;/async&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;fetchPersistentState&gt;false&lt;/fetchPersistentState&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;purgeOnStartup&gt;false&lt;/purgeOnStartup&gt;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/cacheloader&gt;
<br />
&nbsp;&nbsp;&nbsp; &lt;/config&gt;
<br />
&lt;/attribute&gt;
<br />
<br />
我们将通过定制如上的配置信息以更有效地使用JBossCache。详细情况可参考JBoss TreeCache参考文档和范例。
<br />
<br />
TreeCache tree = new TreeCache();
<br />
tree.setClusterProperties("treecache.xml"<img src="http://liwanchun-xd.javaeye.com/images/wink.gif"  alt="" />;
<br />
tree.createService();
<br />
tree.startService();
<br />
tree.put("/a/b/c", "name", "Ben"<img src="http://liwanchun-xd.javaeye.com/images/wink.gif"  alt="" />;
<br />
tree.put("/a/b/c/d", "uid", new Integer(322649));
<br />
Integer tmp = (Integer) tree.get("/a/b/c/d", "uid"<img src="http://liwanchun-xd.javaeye.com/images/wink.gif"  alt="" />;
<br />
tree.remove("/a/b"<img src="http://liwanchun-xd.javaeye.com/images/wink.gif"  alt="" />;
<br />
tree.stopService();
<br />
tree.destroyService();
<br />
</div>
<script type="text/javascript"><!--
google_ad_client = "pub-1076724771190722";
/* JE个人博客468x60 */
google_ad_slot = "5506163105";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script>google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad)</script>
<img src ="http://www.blogjava.net/sealyu/aggbug/321225.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2010-05-18 04:19 <a href="http://www.blogjava.net/sealyu/archive/2010/05/18/321225.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat配置SSL后使用代理碰到的问题</title><link>http://www.blogjava.net/sealyu/archive/2010/01/13/309293.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Wed, 13 Jan 2010 04:49:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2010/01/13/309293.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/309293.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2010/01/13/309293.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/309293.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/309293.html</trackback:ping><description><![CDATA[在按照一些文档配置了SSL后，在本地测试，成功通过。<br />
但是在别的机子上访问时总是报错： <br />
网络访问消息: 无法显示此页 <br />
&nbsp;<br />
技术信息(供支持人员使用) <br />
错误代码: 502 Proxy Error。The specified Secure Sockets Layer (SSL) port is not allowed. ISA Server is not configured to allow SSL requests from this port. Most Web browsers use port 443 for SSL requests. (12204) <br />
IP 地址: xxx.xx.xxx.xx<br />
日期: 2010-1-13 4:35:17 [GMT] <br />
服务器: isa-srv.xxxx.com <br />
<br />
其中的IP地址是我们公司代理的地址，服务器是公司代理服务器。<br />
在网上没有找到解决方法，经过分析错误信息，发现很多实用443端口而不是tomcat的8443端口来访问SSL网址，修改了tomcat下的server.xml文件，果然问题解决。<br />
<br />
<img src ="http://www.blogjava.net/sealyu/aggbug/309293.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2010-01-13 12:49 <a href="http://www.blogjava.net/sealyu/archive/2010/01/13/309293.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Apache Tomcat 6.0 SSL Configuration HOW-TO</title><link>http://www.blogjava.net/sealyu/archive/2010/01/13/309265.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Wed, 13 Jan 2010 00:43:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2010/01/13/309265.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/309265.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2010/01/13/309265.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/309265.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/309265.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Apache Tomcat 6.0SSL Configuration HOW-TO                        Quick Start                                        IMPORTANT NOTE: This Howto refers to usage of JSSE, that comes inc...&nbsp;&nbsp;<a href='http://www.blogjava.net/sealyu/archive/2010/01/13/309265.html'>阅读全文</a><img src ="http://www.blogjava.net/sealyu/aggbug/309265.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2010-01-13 08:43 <a href="http://www.blogjava.net/sealyu/archive/2010/01/13/309265.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat SSL配置大全（转）</title><link>http://www.blogjava.net/sealyu/archive/2010/01/13/309264.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Wed, 13 Jan 2010 00:29:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2010/01/13/309264.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/309264.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2010/01/13/309264.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/309264.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/309264.html</trackback:ping><description><![CDATA[<p>一、准备工作<br />
&nbsp;&nbsp;&nbsp; 1). 安装JDK 1.5 或更高版本， 并配置JAVA_HOME 环境变量;<br />
&nbsp;&nbsp;&nbsp; 2). 安装tomcat 6 ;<br />
&nbsp;&nbsp; <br />
二、配置过程<br />
&nbsp;&nbsp;&nbsp; 1.生成 server key ：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 以命令行方式切换到目录%tomcat_HOME%，在command命令行输入如下命令（jdk1.4以上带的工具）： <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keytool -genkey -alias tomcat -keyalg RSA -keypass changit -storepass changit -keystore server.keystore -validity 3600 <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用户名输入域名，如localhost（开发或测试用）或hostname.domainname(用户拥有的域名)，其它全部以 enter 跳过，最后确认，<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 此时会在%JAVA_HOME%/bin下生成server.keystore 文件。<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：参数 -validity 指证书的有效期(天)，缺省有效期很短，只有90天。<br />
&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; 2.将证书导入的JDK的证书信任库中:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
这步对于tomcat的SSL配置不是必须，但对于CAS
SSO是必须的，否则会出现如下错误：edu.yale.its.tp.cas.client.CASAuthenticationException:
Unable to validate ProxyTicketValidator。。。<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 导入过程分2步，第一步是导出证书，第二步是导入到证书信任库，命令如下：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keytool -export -trustcacerts -alias tomcat -file server.cer -keystore&nbsp; server.keystore -storepass changit<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
keytool -import -trustcacerts -alias tomcat -file server.cer -keystore&nbsp;
%JAVA_HOME%/jre/lib/security/cacerts -storepass changeit<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果有提示，输入Y就可以了。<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;其他有用keytool命令（列出信任证书库中所有已有证书，删除库中某个证书）：<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;keytool -list -v -keystore %JAVA_HOME%/jre/lib/security/cacerts<br />
&nbsp;&nbsp;&nbsp;keytool -delete -trustcacerts -alias tomcat&nbsp; -keystore&nbsp; %JAVA_HOME%/jre/lib/security/cacerts -storepass changit</p>
<p>&nbsp;&nbsp;3.配置tomcat :<br />
&nbsp;&nbsp;&nbsp;修改%TOMCAT_HOME%"conf"server.xml，以文字编辑器打开，查找这一行：<br />
&nbsp;&nbsp;&nbsp;xml 代码<br />
&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;将之后的那段的注释去掉，并加上 keystorePass及keystoreFile属性。<br />
&nbsp;&nbsp;&nbsp;注意，tomcat不同版本配置是不同的:<br />
&nbsp;&nbsp;&nbsp;tomcat4.1.34配置：<br />
&nbsp;&nbsp;&nbsp;xml
代码&nbsp;&nbsp;&nbsp;&nbsp; &lt;Connector
className="org.apache.coyote.tomcat4.CoyoteConnector"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
port="8443" enableLookups="true" scheme="https"
secure="true"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acceptCount="100"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
useURIValidationHack="false" disableUploadTimeout="true"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
clientAuth="false" sslProtocol="TLS"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
keystoreFile="server.keystore"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
keystorePass="changit"/&gt;&nbsp; tomcat5.5.9配置：<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;xml 代码<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&lt;Connector port="8443" maxHttpHeaderSize="8192"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxThreads="150" minSpareThreads="25" maxSpareThreads="75"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enableLookups="false" disableUploadTimeout="true"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acceptCount="100" scheme="https" secure="true"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clientAuth="false" sslProtocol="TLS"&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keystoreFile="server.keystore"&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keystorePass="changit"/&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;tomcat5.5.20配置(此配置同样可用于tomcat6.0)：<br />
&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;xml 代码<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&lt;Connector protocol="org.apache.coyote.http11.Http11Protocol"&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; port="8443" maxHttpHeaderSize="8192"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxThreads="150" minSpareThreads="25" maxSpareThreads="75"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enableLookups="false" disableUploadTimeout="true"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acceptCount="100" scheme="https" secure="true"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clientAuth="false" sslProtocol="TLS"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keystoreFile="server.keystore"&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keystorePass="changit"/&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;tomcat6.0.10配置：<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;xml 代码<br />
&nbsp;&nbsp;&nbsp;&lt;Connector protocol="org.apache.coyote.http11.Http11NioProtocol"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; port="8443" minSpareThreads="5" maxSpareThreads="75"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enableLookups="true" disableUploadTimeout="true"&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acceptCount="100"&nbsp; maxThreads="200"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scheme="https" secure="true" SSLEnabled="true"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clientAuth="false" sslProtocol="TLS"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keystoreFile="server.keystore"&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keystorePass="changit"/&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;tomcat6支持3种，请参考以下文档：<br />
&nbsp;&nbsp;&nbsp;<a href="http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html">http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html</a> <br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;4.验证配置<br />
&nbsp;&nbsp;&nbsp;访问 <a href="https://localhost:8443/">https://localhost:8443/</a><br />
&nbsp;&nbsp;&nbsp;&lt;connector protocol="org.apache.coyote.http11.Http11NioProtocol"&gt;&lt;/connector&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;5. 如果默认想用HTTPS 方式进行网站, 可以作如下配置:<br />
&nbsp;&nbsp;一般Tomcat默认的SSL端口号是8443，但是对于SSL标准端口号是443，<br />
&nbsp;&nbsp;这样在访问网页的时候，直接使用https而不需要输入端口号就可以访问，如<a href="https://localhost/">https://localhost</a><br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;1).non-SSL HTTP/1.1 Connector定义的地方，一般如下：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Connector port="80" maxHttpHeaderSize="8192"&nbsp; scheme="https" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxThreads="500" minSpareThreads="25" maxSpareThreads="75" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enableLookups="false" redirectPort="443" acceptCount="100" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connectionTimeout="20000" disableUploadTimeout="true" /&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将其中的redirectPort端口号改为：443 </p>
<p>&nbsp;&nbsp; 2).SSL HTTP/1.1 Connector定义的地方，修改端口号为：443，如下：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Connector&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; port="443" maxHttpHeaderSize="8192" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxThreads="150" minSpareThreads="25" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxSpareThreads="75" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enableLookups="false" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; disableUploadTimeout="true" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acceptCount="100" scheme="https" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; secure="true" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clientAuth="false" sslProtocol="TLS" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SSLEnabled="true"&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keystoreFile="e:/server.keystore" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keystorePass="changit" /&gt;<br />
&nbsp;&nbsp;&nbsp; 3).AJP 1.3 Connector定义的地方，修改redirectPort为443，如下：&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;Connector port="8009" <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enableLookups="false" redirectPort="443" protocol="AJP/1.3" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;如上配置好后便可以用 <a href="https://localhost/">Https://localhost</a> 方式直接访问,无需输入端口号;</p>
<p>三、参考资料<br />
&nbsp;&nbsp;1. Keytool使用指南：<br />
&nbsp;&nbsp;&nbsp; <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/keytool.html">http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/keytool.html</a><br />
&nbsp;<br />
&nbsp;&nbsp;2. tomcat-ssl配置指南：<br />
&nbsp;&nbsp;&nbsp; <a href="http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html">http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html</a><br />
&nbsp;&nbsp;&nbsp; <a href="http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html">http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html</a></p>
<img src ="http://www.blogjava.net/sealyu/aggbug/309264.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2010-01-13 08:29 <a href="http://www.blogjava.net/sealyu/archive/2010/01/13/309264.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何穿过防火墙调用JBoss(转)</title><link>http://www.blogjava.net/sealyu/archive/2009/10/29/300136.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 29 Oct 2009 02:19:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2009/10/29/300136.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/300136.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2009/10/29/300136.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/300136.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/300136.html</trackback:ping><description><![CDATA[<p>1.首先修改jboss-service.xml，在ejb端口1098附近，修改CallByValue值为true<br />
&lt;attribute name="CallByValue"&gt;true&lt;/attribute&gt;</p>
<p>2.然后修改ejb3.deployer中jboss-service.xml文件，主要是添加域名到3873的调用中<br />
&nbsp;&nbsp; &lt;mbean code="org.jboss.remoting.transport.Connector"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmbean-dd="org/jboss/remoting/transport/Connector.xml"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;depends&gt;jboss.aop:service=AspectDeployer&lt;/depends&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;attribute name="Configuration"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<strong><span style="color: #ff0000;">&lt;config&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;invoker transport="socket"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;attribute name="numAcceptThreads"&gt;1&lt;/attribute&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;attribute name="maxPoolSize"&gt;300&lt;/attribute&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;attribute name="clientMaxPoolSize" isParam="true"&gt;50&lt;/attribute&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;attribute name="timeout" isParam="true"&gt;60000&lt;/attribute&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;attribute name="serverBindAddress"&gt;${jboss.bind.address}&lt;/attribute&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;attribute name="serverBindPort"&gt;3873&lt;/attribute&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- that's the important setting --&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;attribute name="clientConnectAddress"&gt;10.104.46.119&lt;/attribute&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;attribute name="clientConnectPort"&gt;3873&lt;/attribute&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;attribute name="backlog"&gt;200&lt;/attribute&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/invoker&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;handlers&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;handler subsystem="AOP"&gt;org.jboss.aspects.remoting.AOPRemotingInvocationHandler&lt;/handler&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/handlers&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/config&gt;<br />
</span></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/attribute&gt;<br />
&nbsp;&nbsp; &lt;/mbean&gt;</p>
<p>3.设置java启动选项，添加rmi-server的外部地址和禁用本地域名解析到启动脚本<br />
Windows脚本例：set JAVA_OPTS=-Djava.rmi.server.hostname=&nbsp;external IP&nbsp;-Djava.rmi.server.useLocalHostname=false<br />
Unix脚本例：添加到jboss启动配置文件run.conf中即可。</p>
<p>4.用run.sh --host=192.168.1.25启动服务或添加--host=192.168.1.25到启动脚本。</p>
<p>1.在使用<span style="background-color: #ffff00;">Jboss</span> 4.2GA 遇到的问题. 以下是以default 模式启动的<span style="background-color: #ffff00;">Jboss</span> .启动参数 -c default /all<br />
(1). localhost可以访问与本机IP不能访问 <br />
解决方式： <br />
修改JBOSS_HOME"server"default"deploy"<span style="background-color: #ffff00;">jboss</span>-web.deployer下的server.xml 将address改为0.0.0.0或者你的实际IP 重启 <span style="background-color: #ffff00;">JBOSS</span> 然后就可以通过ip访问。</p>
<p>(3)在windows 客户端调用 Linux 服务端 遇到org.<span style="background-color: #ffff00;">jboss</span>.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://127.0.0.1:<span style="background-color: #aaffaa;">3873</span>/]<br />
解决方法: 修改 JBOSS_HOME/server/default/deploy/ejb3.deployer/META-INF/<span style="background-color: #ffff00;">jboss</span>-services.xml 文件中的${<span style="background-color: #ffff00;">jboss</span>.bind.address}:<span style="background-color: #aaffaa;">3873</span> 为linux_home_ip:<span style="background-color: #aaffaa;">3873<br />
</span></p>
<p>以上两个问题也可以通过以下设置解决： <br />
For Windows, use<br />
run.bat -b 0.0.0.0</p>
<p>for Linux use <br />
run.sh -b 0.0.0.0</p>
<img src ="http://www.blogjava.net/sealyu/aggbug/300136.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2009-10-29 10:19 <a href="http://www.blogjava.net/sealyu/archive/2009/10/29/300136.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tomcat错误：SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to xxxx</title><link>http://www.blogjava.net/sealyu/archive/2009/10/20/299061.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Tue, 20 Oct 2009 08:44:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2009/10/20/299061.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/299061.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2009/10/20/299061.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/299061.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/299061.html</trackback:ping><description><![CDATA[出现SetPropertiesRule警告的原因是因为Tomcat在server.xml的Context节点中不支持source属性
<br />
<br />
&lt;Context docBase="..." path="/cont" source="org.eclipse.jst.j2ee.server:*"/&gt;
<br />
<br />
解决方法是在Server的配置界面中选中"Publish module contexts to separate XML files"选项。
<script type="text/javascript"><!--
google_ad_client = "pub-4348265167276910";
/* 468x60, 个人博客 */
google_ad_slot = "2046406163";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script>google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);</script>
<img src ="http://www.blogjava.net/sealyu/aggbug/299061.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2009-10-20 16:44 <a href="http://www.blogjava.net/sealyu/archive/2009/10/20/299061.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JBOSS维护经验（转）</title><link>http://www.blogjava.net/sealyu/archive/2009/09/22/296024.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Tue, 22 Sep 2009 06:48:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2009/09/22/296024.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/296024.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2009/09/22/296024.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/296024.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/296024.html</trackback:ping><description><![CDATA[<h1 style="margin: 17pt 0cm 16.5pt;"><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">1.JBOSS</span><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">服务的启动与关闭</span></h1>
<h2 style="margin: 13pt 0cm;"><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">1.1 </span><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">确认JDK安装配置</span></h2>
<p style="margin: 0cm 0cm 6pt;"><span style="font-size: 10.5pt; font-family: 宋体;">在启动JBOSS节点前，</span><span style="font-size: 10.5pt; font-family: 宋体;">要正确</span><span style="font-size: 10.5pt; font-family: 宋体;">安装SUN JDK1.5</span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">并设置环境变量$JAVA_HOME</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">解压缩JBOOS-TGZ包</font></span></p>
<h2 style="margin: 13pt 0cm;"><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">1.2 </span><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">运行JBOSS</span></h2>
<p style="margin: 0cm 0cm 6pt;"><span style="font-size: 10.5pt; font-family: 宋体;">cd $JBOSS_HOME/bin</span></p>
<p style="margin: 0cm 0cm 6pt;"><span style="font-size: 10.5pt; font-family: 宋体;">nohup ./run.sh -c </span><span style="font-size: 10.5pt; font-family: 宋体;">vcom</span><span style="font-size: 10.5pt; font-family: 宋体;"> -b 0.0.0.0 </span><span style="font-size: 10.5pt; font-family: 宋体;">&#8211;u 229.12.12.12</span><span style="font-size: 10.5pt; font-family: 宋体;">&amp;</span></p>
<p style="margin: 0cm 0cm 6pt;"><span style="font-size: 10.5pt; font-family: 宋体;">参数说明：</span></p>
<p style="margin: 0cm 0cm 6pt;"><span style="font-size: 10.5pt; font-family: 宋体;">-c: </span><span style="font-size: 10.5pt; font-family: 宋体;">指定运行的配置，default配置不带集群支持</span><span style="font-size: 10.5pt; font-family: 宋体;">,all </span><span style="font-size: 10.5pt; font-family: 宋体;">和自定义的vcom目录配置带有集群支持功能</span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">-b: </span><span style="line-height: 150%; font-family: 宋体;">指定服务绑定的IP地址，即对外服务的IP地址，0.0.0.0表示对机器上所有的IP提供服务</span></font></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">-u </span><span style="line-height: 150%; font-family: 宋体;">指定服务使用的UDP组播地址</span></font></p>
<h2 style="margin: 13pt 0cm;"><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">1.3 </span><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">关闭JBOSS服务</span></h2>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">编写脚本内容如下：</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">#!/bin/bash</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">for i in ` ps -ef | grep -w java |grep -v grep |awk '{print $2 ""t"$3}'`;do kill -9 $i</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">done</font></span></p>
<h1 style="margin: 17pt 0cm 16.5pt;"><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">2.jmx-console</span><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">控制台</span></h1>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 仿宋_GB2312;">&nbsp;</span><span style="font-size: 12pt; line-height: 150%; font-family: 宋体;">&nbsp;</span><span style="line-height: 150%; font-family: 宋体;">安装好jboss并启动jboss后，在浏览器窗口的地址栏里键入 http://localhost:8080/jmx-console</span><span style="line-height: 150%; font-family: 宋体;">（jboss默认的端口号为8080,可以自定义修改）。</span><span style="line-height: 150%; font-family: 宋体;">就可以浏览 jboss的部署管理的一些信息，默认情况下不键入任何用户名和密码就可以进入此页面，方便是方便，但真正使用起来还是有点安全隐患，因为不管任何人只要知道server的ip 都可以进去访问。下面我们针对此问题对jboss进行配置，使得访问jmx-console也必须 要知道用户名和密码才可进去访问. </span></font></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><strong><span style="font-size: 15pt; line-height: 150%; font-family: 宋体;">&nbsp;2.1 </span></strong><strong><span style="font-size: 15pt; line-height: 150%; font-family: 宋体;">设置jmx-console安全设置</span></strong></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">&nbsp;1. </span><span style="line-height: 150%; font-family: 宋体;">进入jmx-console.war，通常此目录在$JBOSS_HOME/server/vcom/deploy目录下。</span></font></p>
<p style="margin: 0cm 0cm 0pt 5.25pt; text-indent: -5.25pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">&nbsp;2. </span><span style="line-height: 150%; font-family: 宋体;">编辑该目录下的/WEB-INF/web.xml，把&lt;security-constraint&gt;部分注释去掉 3.</span><span style="line-height: 150%; font-family: 宋体;">编辑$jboss_home/server/vcom/conf/props目录下的jmx-console-roles.properties和jmx-console-users.properties；</span></font></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1) users.properties</span><span style="line-height: 150%; font-family: 宋体;">文件里定义用户名和密码，格式为username=password。可以依照此格式添加多个用户。 </span></font></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 36.75pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">2) roles.propertie</span><span style="line-height: 150%; font-family: 宋体;">文件里定义用户名和角色，格式为username=role。这里的role必须和web.xml文件里的&lt;role-name&gt;相对应。 </span></font></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">4. </span><span style="line-height: 150%; font-family: 宋体;">编辑/WEB-INF/jboss-web.xml文件，打开&lt;security-domain&gt;部分注释；这里&lt;security- domain&gt;内容对应的security-domain对应$jboss_home"server"vcom"conf"login-config.xml这个jaas配置文件里的某个application-policy。 </span></font></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">如: </font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">&lt;security-domain&gt;java:/jaas/jmx-console&lt;/security-domain&gt; <br />
</span><span style="line-height: 150%; font-family: 宋体;">在login-config.xml里对应有：</span></font></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&lt;application-policy name = "jmx-console"&gt; </font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&lt;authentication&gt; </font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&lt;login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag = "required" /&gt; </font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&lt;/authentication&gt; </font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&lt;/application-policy&gt; </font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">5</span><span style="line-height: 150%; font-family: 宋体;">．重启jboss，在浏览器中键入控制台地址，就会出现输入username和password的提示窗口。 </span></font></p>
<h2 style="margin: 13pt 0cm;"><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">2.2 </span><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">监控集群状况和session复制情</span><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">况</span></h2>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">使用<a href="http://localhost:8080/jmx-console"><font color="#0000ff">http://localhost:8080/jmx-console</font></a>,使用名为jboss.cache:service=TomcatClustering MBean Members可以查看当前机群节点成员信息，使用jboss.cache:service=TomcatClustering，可以看到当前集群的节点ip,在member 一项中，可以观察到当前集群中节点ip,如图：</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><font size="3"><span style="font-family: 宋体;">在此页面下找到</span><span style="font-family: 宋体;">java.lang.String printDetails()&nbsp;</span><span style="font-family: 宋体;">，</span></font></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><font size="3"><span style="font-family: 宋体;">invoke the printDetails</span><span style="font-family: 宋体;">操作，点击invoke，可以对session复制进行监控。</span></font></p>
<h1 style="margin: 17pt 0cm 16.5pt;"><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">3</span><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">、配置JBOSS应用数据库连接</span></h1>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 12pt; line-height: 150%; font-family: 宋体;">目前应用使用的数据库连接是应用程序自带的JDBC （API）接口，配置如下：</span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 12pt; line-height: 150%; font-family: 宋体;">Cd /$JBOSS_HOME/server/vcom/deploy/*.war/WEB-INF/class/</span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 12pt; line-height: 150%; font-family: 宋体;">Vi proxool.xml</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 12pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 12pt; line-height: 150%; font-family: 宋体;">&nbsp;&lt;</span><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">?xml version="1.0" encoding="UTF-8"?&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&lt;datasource&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&lt;proxool&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp; &lt;alias&gt;pool&lt;/alias&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp; &lt;driver-url&gt;jdbc:oracle:thin:@192.168.104.32:1521:cportal&lt;/driver-url&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp; &lt;driver-class&gt;oracle.jdbc.driver.OracleDriver&lt;/driver-class&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp; &lt;driver-properties&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name="user" value="cportal"/&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name="password" value="cportal"/&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp; &lt;/driver-properties&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp; &lt;house-keeping-sleep-time&gt;30000&lt;/house-keeping-sleep-time&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp; &lt;minimum-connection-count&gt;0&lt;/minimum-connection-count&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp; &lt;maximum-connection-count&gt;300&lt;/maximum-connection-count&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&nbsp;&nbsp; &lt;house-keeping-test-sql&gt;select CURRENT_DATE&lt;/house-keeping-test-sql&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&nbsp;&lt;/proxool&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; text-indent: 9pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">&lt;/datasource&gt;</span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">(1) </span><span style="line-height: 150%; font-family: 宋体;">jdbc:oracle:thin:@192.168.104.32:1521:cportal</span><span style="line-height: 150%; font-family: 宋体;">，oracle服务端口是1521，cportal为数据库的实例名即sid。</span></font></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">(2) </span><span style="line-height: 150%; font-family: 宋体;">&lt;property name="user" value="cportal"/&gt;</span></font></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><font face="宋体"><span style="color: #333333;">&nbsp;&lt;property name="password" value="cportal"/&gt; </span><span style="color: #333333; font-family: 宋体;">为数据库的用户名和密码</span></font></font></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">（3）</span><font face="宋体">&lt;maximum-connection-count&gt;300&lt;/maximum-connection-count&gt;<span style="font-family: 宋体;">为客户端</span> </font><span style="font-family: 宋体;">最大的数据库连接数</span></font></p>
<h1 style="margin: 17pt 0cm 16.5pt;"><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">4.</span><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">修改jboss服务端口号</span></h1>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">使用JBOSS中间件时,默认的访问端口是8080，可以修改问你想使用的端口，修改步骤如下：</font><br />
<font size="3">打开JBOSS目录$JBOSS_HOME/server/vcom/deploy/jboss-web.deployer/下的server.xml文件,搜索8080,将8080改为新的端口号,保存文件,重启应用服务器即可.访问时使用新的端口号</font><font size="3">. <br />
&lt;Connector port="80" address="${jboss.bind.address}"&nbsp;&nbsp;&nbsp; </font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxThreads="150" maxHttpHeaderSize="8192"</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; emptySessionPath="true" protocol="HTTP/1.1"</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enableLookups="false" redirectPort="8443" acceptCount="100"</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connectionTimeout="20000" disableUploadTimeout="true" /&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">其中150是JVM中启动的最大线程数，100 为JVM达到最大线程阀值时，可以放在队列中的HTTP请求数</font></span></p>
<h1 style="margin: 17pt 0cm 16.5pt;"><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">5.JBOSS</span><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">服务状态监控（web-console）</span></h1>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">&nbsp;</span><span style="line-height: 150%; font-family: 宋体;">如果需要监控jboss的系统资源，如：jboss的基本配置情况，jvm的利用率，线程池的使用情况，可以使用web-console进行监控。</span></font></p>
<h2 style="margin: 13pt 0cm;"><span style="font-size: 14pt; line-height: 173%; font-family: 宋体;">5.1</span><span style="font-size: 14pt; line-height: 173%; font-family: 宋体;">配置web-console</span></h2>
<p style="text-indent: 21pt;"><span style="font-size: 10.5pt;"><font face="宋体">具体方法同jmx-console，就是位置不同，具体方法参考jmx-console配置：</font></span></p>
<p style="margin: 0cm 0cm 0pt 47.25pt; text-indent: -18pt; text-align: left;" align="left"><span style="font-size: 10pt; font-family: Symbol;">&#183;&nbsp;</span><font size="3"><span style="font-family: 宋体;">jboss-web.xml</span><span style="font-family: 宋体;">、web.xml在$JBOSS_HOME/vcom/deploy/management/console-mgr.sar/web-console.war/WEB-INF下；</span></font></p>
<p style="margin: 0cm 0cm 0pt 47.25pt; text-indent: -18pt; text-align: left;" align="left"><span style="font-size: 10pt; font-family: Symbol;">&#183;&nbsp;</span><font size="3"><span style="font-family: 宋体;">login-config.xml</span><span style="font-family: 宋体;">还是原来的那个，把application-policy名为$webConsoleDomain的部分改成你需要的web-console；</span></font></p>
<p style="margin: 0cm 0cm 0pt 47.25pt; text-indent: -18pt; text-align: left;" align="left"><span style="font-size: 10pt; font-family: Symbol;">&#183;&nbsp;</span><font size="3"><span style="font-family: 宋体;">web-console-users.properties</span><span style="font-family: 宋体;">、web-console-roles.properties定义了访问 web-console的用户、用户角色，具体位置自己去找，使用find /jboss -name web-console-users.properties 找到以后可以修改用户名、密码。</span></font></p>
<h2 style="margin: 13pt 0cm;"><span style="font-size: 14pt; line-height: 173%; font-family: 宋体;">5.2 </span><span style="font-size: 14pt; line-height: 173%; font-family: 宋体;">监控</span></h2>
<p style="margin: 0cm 0cm 0pt; text-indent: 21pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">使用http://localhost:8080/web-console/ 中，获取当前JBOSS-WEB应用模块的负载分担情况，并可以查看到当前JAVA虚拟机的内存使用情况，及线程池使用情况。</font></span></p>
<p style="margin: 0cm -22.55pt 0pt 0cm; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">使用<a href="http://localhost:8080/web-console/status"><font color="#0000ff">http://localhost:8080/web-console/status</font></a>，可以进一步监控到每个线程的状态。</font></span></p>
<h1 style="margin: 17pt 0cm 16.5pt;"><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">6.</span><span style="font-size: 16pt; line-height: 240%; font-family: 宋体;">系统日志分析</span></h1>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">在</span><span style="line-height: 150%; font-family: 宋体;">$JBOSS_HOME /server/vcom/log</span><span style="line-height: 150%; font-family: 宋体;">下，有关于jboss的日志记录， 其中server.log是用来记录JBOOS运行过程的日志记录,boot.log用来记录JBOOS启动信息的，出现问题时可以通过sever.log对jboss进行分析。</span></font></p>
<h2 style="margin: 13pt 0cm;"><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">&nbsp;6.1 JBOSS</span><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">的日志配置文件</span></h2>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">$JBOSS_HOME /server/vcom/conf</span><span style="line-height: 150%; font-family: 宋体;">下的jboss-log4j.xml，可以对日志的来源和级别进行定义，也可以定义日志的记录方式。</span></font></p>
<h2 style="margin: 13pt 0cm;"><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">6.2 </span><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">产生cluster.log</span></h2>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">可以把jboss-log4j.xml中最后有关cluster.log的APPENDER注释掉，系统运行时会在log目录下产生cluster.log文件，可以通过此文件对集群故障进行分析。在测试调试过程可以使用此日志</font></span></p>
<h2 style="margin: 13pt 0cm;"><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">6.3 </span><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;">更改日志记录方式</span></h2>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><font size="3"><span style="line-height: 150%; font-family: 宋体;">Jboss</span><span style="line-height: 150%; font-family: 宋体;">日志记录方式有2种：</span></font></p>
<p style="margin: 0cm 0cm 0pt 36pt; text-indent: -36pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">1．</font><span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="line-height: 150%; font-family: 宋体;"><font size="3">按日期进行记录</font></span></p>
<p style="margin: 0cm 0cm 0pt 36pt; text-indent: -36pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">2．</font><span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="line-height: 150%; font-family: 宋体;"><font size="3">按日志文件的大小进行记录</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="line-height: 150%; font-family: 宋体;"><font size="3">目前使用的是按照大小信息记录。如果要修改记录方式，直接编辑jboss-log4j.xml文件，将此段注释去掉。</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&lt;!-- A time/date based rolling appender --&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp; &lt;appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender"&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="File" value="${jboss.server.log.dir}/server.log"/&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="Append" value="false"/&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!-- Rollover at midnight each day --&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="DatePattern" value="'.'yyyy-MM-dd"/&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/layout&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp; &lt;/appender&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; line-height: 150%; text-align: left;" align="left"><span style="font-size: 12pt; line-height: 150%; font-family: 宋体;">同时将下段注释掉</span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&lt;!-- A size based file rolling appender--&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp; &lt;appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender"&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp; &lt;errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="File" value="${jboss.server.log.dir}/server.log"/&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="Append" value="false"/&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="MaxFileSize" value="500KB"/&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="MaxBackupIndex" value="1"/&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</font></span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">&nbsp;&nbsp;&nbsp;&nbsp; &lt;/layout&gt;</font></span></p>
<p style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">&nbsp;&nbsp; &lt;/appender&gt;</span></font></p>
<font size="3"><span style="font-family: 宋体;">下。</span></font>
<img src ="http://www.blogjava.net/sealyu/aggbug/296024.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2009-09-22 14:48 <a href="http://www.blogjava.net/sealyu/archive/2009/09/22/296024.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Seam 项目部署在 tomcat 中(转)</title><link>http://www.blogjava.net/sealyu/archive/2009/08/26/292632.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Wed, 26 Aug 2009 04:36:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2009/08/26/292632.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/292632.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2009/08/26/292632.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/292632.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/292632.html</trackback:ping><description><![CDATA[<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;JBoss&nbsp;Tools&nbsp;<font face="宋体">生成的&nbsp;</font><font face="Times New Roman">Seam&nbsp;</font><font face="宋体">项目（新建项目时，服务器选择&nbsp;</font><font face="Times New Roman">tomcat</font><font face="宋体">），会生成一些必要的文件，如：连接数据库的数据源文件，如：</font><font face="Times New Roman">project-ds.xml&nbsp;</font><font face="宋体">（但它只能在&nbsp;</font><font face="Times New Roman">Jboss&nbsp;as&nbsp;</font><font face="宋体">的环境中运行，不适用于&nbsp;</font><font face="Times New Roman">tomcat</font><font face="宋体">），要想很我们的项目（</font><font face="Times New Roman">war</font><font face="宋体">）运行于&nbsp;</font><font face="Times New Roman">tomcat&nbsp;</font><font face="宋体">中的，我们得对它自动生成的文件做一些必要的修改。</font></span>
<p><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;一、<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">修改数据库的连接方式</span></span></p>
<p><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1、采用数据源的形式<br />
</span></span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">在&nbsp;<font face="Times New Roman">tomcat&nbsp;</font><font face="宋体">中配置数据源方式如下:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></span></span></span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">在生成的项目同级目录中找此文件：&nbsp;<font face="Times New Roman">context.xml&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">Servers/Tomcat&nbsp;<font face="宋体">。。。</font><font face="Times New Roman">/context.xml&nbsp;&nbsp;</font><font face="宋体">作如下配置：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">在标签&nbsp;<font face="Times New Roman">&lt;Context&gt;&nbsp;</font><font face="宋体">中间加入:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">&lt;Resource&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">name="</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">jdbc</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">/demo"&nbsp;</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">auth</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">="Container"&nbsp;</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">type="</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">javax</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">.</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">sql</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">.DataSource"&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">maxActive="30" </span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">maxIdle="5" </span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">maxWait="10000" </span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">username</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">="root"&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></font></span></span></span></span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><font face="宋体"><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">password="</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">admin</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">"&nbsp;</span></font></span></span></span></span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><font face="宋体"><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">driverClassName="</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">com</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">.</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">mysql</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">.</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">jdbc</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">.Driver"&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';"><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">url</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">="jdbc:mysql://</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New'; text-decoration: underline;">localhost</span><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">:3306/demo?useUnicode=true&amp;amp;characterEncoding=UTF-8"&gt;</span></span></font></span></span></span></span></p>
<p><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><font face="宋体"><span style="font-size: 10.5pt; color: #3f5fbf; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/Resource&gt;</span>&nbsp;</font></span></span></span></span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></p>
<p><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2、<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">使用非数据源的形式<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">在文件：<font face="Times New Roman">persistence.xml&nbsp;</font><font face="宋体">中添加</font><font face="Times New Roman">hibernate&nbsp;</font><font face="宋体">的连接数据库的方式，如下：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 10.5pt; color: #008080; font-family: 'Courier New';">&lt;</span><span style="font-size: 10.5pt; color: #3f7f7f; font-family: 'Courier New';">property</span>&nbsp;<span style="font-size: 10.5pt; color: #7f007f; font-family: 'Courier New';">name</span><span style="font-size: 10.5pt; color: #000000; font-family: 'Courier New';">=</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"hibernate.connection.username"</span>&nbsp;<span style="font-size: 10.5pt; color: #7f007f; font-family: 'Courier New';">value</span><span style="font-size: 10.5pt; color: #000000; font-family: 'Courier New';">=</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"root"</span><span style="font-size: 10.5pt; color: #008080; font-family: 'Courier New';">/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></font></span></span></span></span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><font face="宋体"><span style="font-size: 10.5pt; color: #008080; font-family: 'Courier New';">&lt;</span><span style="font-size: 10.5pt; color: #3f7f7f; font-family: 'Courier New';">property</span>&nbsp;<span style="font-size: 10.5pt; color: #7f007f; font-family: 'Courier New';">name</span><span style="font-size: 10.5pt; color: #000000; font-family: 'Courier New';">=</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"hibernate.connection.password"</span>&nbsp;<span style="font-size: 10.5pt; color: #7f007f; font-family: 'Courier New';">value</span><span style="font-size: 10.5pt; color: #000000; font-family: 'Courier New';">=</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"admin"</span><span style="font-size: 10.5pt; color: #008080; font-family: 'Courier New';">/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-size: 10.5pt; color: #008080; font-family: 'Courier New';">&lt;</span><span style="font-size: 10.5pt; color: #3f7f7f; font-family: 'Courier New';">property</span>&nbsp;<span style="font-size: 10.5pt; color: #7f007f; font-family: 'Courier New';">name</span><span style="font-size: 10.5pt; color: #000000; font-family: 'Courier New';">=</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"hibernate.connection.driver_class" </span><span style="font-size: 10.5pt; color: #7f007f; font-family: 'Courier New';">value</span><span style="font-size: 10.5pt; color: #000000; font-family: 'Courier New';">=</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"com.mysql.jdbc.Driver"</span><span style="font-size: 10.5pt; color: #008080; font-family: 'Courier New';">/&gt;<br />
</span><span style="font-size: 10.5pt; color: #008080; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="font-size: 10.5pt; color: #3f7f7f; font-family: 'Courier New';">property</span>&nbsp;<span style="font-size: 10.5pt; color: #7f007f; font-family: 'Courier New';">name</span><span style="font-size: 10.5pt; color: #000000; font-family: 'Courier New';">=</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"hibernate.connection.url"</span><span style="font-size: 10.5pt; font-family: 'Courier New';">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></font></span></span></span></span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><font face="宋体"><span style="font-size: 10.5pt; color: #7f007f; font-family: 'Courier New';">value</span><span style="font-size: 10.5pt; color: #000000; font-family: 'Courier New';">=</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"jdbc:mysql://localhost:3306/</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: '宋体';">demo</span><span style="font-size: 10.5pt; color: #2a00ff; font-style: italic; font-family: 'Courier New';">?useUnicode=true&amp;characterEncoding=UTF-8"</span><span style="font-size: 10.5pt; color: #008080; font-family: 'Courier New';">/&gt;</span></font></span></span></span></span></p>
<p><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;二、<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">修改&nbsp;<font face="Times New Roman">JPA&nbsp;</font><font face="宋体">配置文件&nbsp;</font><font face="Times New Roman">persistence.xml</font></span></span></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">1、</span><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">如果数据的连接方式采用数据源的形式，则只需修改里面数据源的名称，如：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">&lt;</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #3f7f7f; font-family: 'Courier New';">jta-data-source</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">&gt;</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: '宋体';">java:comp/env/jdbc/demo</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">&lt;/</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #3f7f7f; font-family: 'Courier New';">jta-data-source</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">&gt;</span></span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2、如果采用<font face="Times New Roman">hibernate&nbsp;</font><font face="宋体">的连接方式，则把此行删了。</font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3、<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">删除里面的此行配置：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">&lt;</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #3f7f7f; font-family: 'Courier New';">property</span>&nbsp;<span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #7f007f; font-family: 'Courier New';">name</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #000000; font-family: 'Courier New';">=</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"hibernate.transaction.manager_lookup_class"</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; font-family: 'Courier New';">&nbsp;<br />
</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #7f007f; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #000000; font-family: 'Courier New';">=</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"org.hibernate.transaction.JBossTransactionManagerLookup"</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">/&gt;</span></span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4、修改事务的策略方式为 <em><font color="#2a00ff" face="Courier New">RESOURCE_LOCAL</font></em> ：&nbsp;</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">&lt;</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #3f7f7f; font-family: 'Courier New';">persistence-unit</span>&nbsp;<span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #7f007f; font-family: 'Courier New';">name</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #000000; font-family: 'Courier New';">=</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"demo"</span>&nbsp;<span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #7f007f; font-family: 'Courier New';">transaction-type</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #000000; font-family: 'Courier New';">=</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"RESOURCE_LOCAL"</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">&gt;</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;三、<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">配置&nbsp;<font face="Times New Roman">Seam&nbsp;</font><font face="宋体">的事务管理器<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">在&nbsp;<font face="Times New Roman">component.xml&nbsp;</font><font face="宋体">文件加入：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">&lt;</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #3f7f7f; font-family: 'Courier New';">transaction:entity-transaction</span>&nbsp;<span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #7f007f; font-family: 'Courier New';">entity-manager</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #000000; font-family: 'Courier New';">=</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #2a00ff; font-style: italic; font-family: 'Courier New';">"#{entityManager}"</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #008080; font-family: 'Courier New';">/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #000000; font-family: '宋体';">默认生成的此文件是不含有&nbsp;<font face="Courier New"><span style="color: #000000;">transaction&nbsp;</span></font><font face="宋体"><span style="color: #000000;">的命名空间，需要手动在</span></font></span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #000000; font-family: '宋体';">此文件加入它的命名空间：</span></span></font></span></font></span></p>
<p><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; font-family: '宋体';"><font face="宋体"><font face="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #7f007f; font-family: 'Courier New';">xmlns:transaction</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #000000; font-family: 'Courier New';">=</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #2a00ff; font-style: italic; font-family: 'Courier New';"><a href="http://jboss.com/products/seam/transaction">http://jboss.com/products/seam/transaction</a><br />
</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #2a00ff; font-style: italic; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://jboss.com/products/seam/transaction">http://jboss.com/products/seam/transaction</a>&nbsp;<br />
</span><span style="background: #ffffff none repeat scroll 0% 0%; font-size: 10.5pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #2a00ff; font-style: italic; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://jboss.com/products/seam/transaction-2.1.xsd">http://jboss.com/products/seam/transaction-2.1.xsd</a></span></font></font></span></p>
<p><span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;四、<span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">为此项目加入必要的依赖包&nbsp;。。。。。。</span></span></p>
<img src ="http://www.blogjava.net/sealyu/aggbug/292632.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2009-08-26 12:36 <a href="http://www.blogjava.net/sealyu/archive/2009/08/26/292632.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JBoss中的TransactionTimeOut的设置</title><link>http://www.blogjava.net/sealyu/archive/2009/05/18/271239.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Mon, 18 May 2009 02:01:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2009/05/18/271239.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/271239.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2009/05/18/271239.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/271239.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/271239.html</trackback:ping><description><![CDATA[这两天在作seam的时候不时遇到&#8220;org.jboss.util.NestedSQLException: Transaction is not active&#8221;的错误信息，后来到jboss的wiki上发现了问题的原因和解决方法：<br />
<h2> How do I set the Transaction Timeout?</h2>
<p>Transaction timeout (unit is always seconds) can be configured in various ways:</p>
<p>This argument is the same no matter if you are using JBossTM(&lt;=4.0.5) or JBossJTA-Arjuna(&gt;=4.2).</p>
<ul>
    <li type="ul">
    <p>Globally:
    You can change this behavior globally by modifying the
    TransactionManagerService in /conf/jboss-service.xml (or
    /deploy/jta-service.xml for 4.0.3)</p>
    </li>
</ul>
<p><strong>Version &lt;= 4.0.5</strong></p>
<p>This part is the same for either JBossTM or JBossJTA and is the same for ejb2 and ejb3</p>
<ul>
    <li type="ul">
    <p>Per-method basis: Modifying the <span style="font-family: courier new,courier;">&lt;transaction-timeout&gt;</span>
    element inside the &lt;method&gt; element of a session or entity bean.
    This is located in the META-INF/jboss.xml deployment descriptor of a
    session bean. When the transaction timeout is specified at the method
    level, it overrides the default timeout. Further information about this
    element can be found in jboss-x.x.x/docs/dtd/jboss_4_0.dtd. Example
    taken from the testsuite:</p>
    </li>
</ul>
<ul>
    <li type="ul">
    <p>Using
    BMT: Calling
    javax.transaction.UserTransaction.setTransactionTimeout(int seconds).
    Please, be aware that this only applies to transactions started after
    this invocation on the same thread. Example:</p>
    </li>
</ul>
<pre><code jive-java="">@TransactionTimeout(1500)<br />
</code></pre>
<br />
<br />
<img src ="http://www.blogjava.net/sealyu/aggbug/271239.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2009-05-18 10:01 <a href="http://www.blogjava.net/sealyu/archive/2009/05/18/271239.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path</title><link>http://www.blogjava.net/sealyu/archive/2009/04/11/265054.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Sat, 11 Apr 2009 14:22:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2009/04/11/265054.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/265054.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2009/04/11/265054.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/265054.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/265054.html</trackback:ping><description><![CDATA[<table style="table-layout: fixed">
    <tbody>
        <tr>
            <td>
            <div class="cnt" id="blog_text">
            <div class="cnt" twffan="done">
            <p>P1:Tomcat6启动的时候出现下面这样的提示：</p>
            <p>2007-12-31 9:51:51 org.apache.catalina.core.AprLifecycleListener init<br />
            信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Sun\jre1.6.0_03\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;.;D:\Sun\jdk1.6.0_03\bin;D:\Sun\jdk1.6.0_03\jre\bin;D:\ApacheTomcat\lib;</p>
            <p>S1:实际这是建议使用apache的apr;apr 是apache portable runtime 用上这个后可以有效的提高tomcat处理静态页面的能力.如果想使用apr的话， 实际操作很简单，</p>
            <p>下载 <a href="http://tomcat.heanet.ie/native/1.1.1/binaries/win32/tcnative-1.dll">http://tomcat.heanet.ie/native/1.1.1/binaries/win32/tcnative-1.dll</a></p>
            <p>将这个文件复制到C:\WINDOWS\system32\下面,然后重新启动tomcat，就会发现tomcat 的控制台信息为：<br />
            2007-12-31 9:55:40 org.apache.catalina.core.AprLifecycleListener init<br />
            信息: An older version 1.1.8 of the Apache Tomcat Native library is installed, while Tomcat recommends version greater then 1.1.10<br />
            2007-12-31 9:55:40 org.apache.catalina.core.AprLifecycleListener init<br />
            信息: Loaded Apache Tomcat Native library 1.1.8.</p>
            </div>
            </div>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.blogjava.net/sealyu/aggbug/265054.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2009-04-11 22:22 <a href="http://www.blogjava.net/sealyu/archive/2009/04/11/265054.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JBoss类加载配置属性 UseJBossWebLoader</title><link>http://www.blogjava.net/sealyu/archive/2009/02/24/256392.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Tue, 24 Feb 2009 02:25:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2009/02/24/256392.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/256392.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2009/02/24/256392.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/256392.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/256392.html</trackback:ping><description><![CDATA[<p>See ClassLoadingConfiguration.</p>
<p>Available option in deploy/jbossweb-tomcat.sar/META-INF/jboss-service.xml</p>
<p>or deploy/jboss-web.deployer/META-INF/jboss-service.xml</p>
<p>This
configuration options toggles usage of separate classloaders for web
modules. The JBoss unified classloader holds all the classes from
multiple web applications in one big classloader and may cause unwanted
interference.</p>
<p>Example</p>
<p>Imagine
web modules "sales.war" and "stock.war", both containing some version
of "utility.jar". In case "sales.war" uses version 1.0 and "stock.war"
requires version 2.0, turning off the unified web loader is the safest
solution. If you don't, the first loaded library will have priority,
and remains in the classloader till the reference count drops to zero.</p>
<p>The
disadvantage of using isolated classloaders: either you need to
duplicate the same library across multiple web modules, or add it to
the classpath of your server instance (default: lib/). The instance
libraries are defaults, they can be overridden when the web module
contains it's own custom versions.</p>
<p>The
configuration file contains a small comment about isolation of JSP
files as well, to separate two JSP files with the same name from two
different web modules. In JBoss 4.0.5, using non-precompiled JSP pages,
this seems to work fine, even with the JBoss unified web loader.</p>
<img src ="http://www.blogjava.net/sealyu/aggbug/256392.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2009-02-24 10:25 <a href="http://www.blogjava.net/sealyu/archive/2009/02/24/256392.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>How to use Django with Apache and mod_python</title><link>http://www.blogjava.net/sealyu/archive/2008/11/07/239347.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Fri, 07 Nov 2008 15:44:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/11/07/239347.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/239347.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/11/07/239347.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/239347.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/239347.html</trackback:ping><description><![CDATA[<p><a external="" href="http://httpd.apache.org/">Apache</a> with <a external="" href="http://www.modpython.org/">mod_python</a> currently is the preferred setup for using Django
on a production server.</p>
<p>mod_python is similar to (and inspired by) <a external="" href="http://perl.apache.org/">mod_perl</a> : It embeds Python within
Apache and loads Python code into memory when the server starts. Code stays in
memory throughout the life of an Apache process, which leads to significant
performance gains over other server arrangements.</p>
<p>Django requires Apache 2.x and mod_python 3.x, and you should use Apache&#8217;s
<a external="" href="http://httpd.apache.org/docs/2.2/mod/prefork.html">prefork MPM</a>, as opposed to the <a external="" href="http://httpd.apache.org/docs/2.2/mod/worker.html">worker MPM</a>.</p>
<p>You may also be interested in <a external="" href="http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#howto-deployment-fastcgi"><em>How to use Django with FastCGI, SCGI or AJP</em></a> (which also covers SCGI and AJP).</p>
<div id="s-basic-configuration">
<h2 id="basic-configuration">Basic configuration<a href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#basic-configuration" title="Permalink to this headline">&#182;</a></h2>
<p>To configure Django with mod_python, first make sure you have Apache installed,
with the mod_python module activated.</p>
<p>Then edit your <tt literal="">httpd.conf</tt> file and add the following:</p>
<div>
<pre>&lt;Location "/mysite/"&gt;<br />
SetHandler python-program<br />
PythonHandler django.core.handlers.modpython<br />
SetEnv DJANGO_SETTINGS_MODULE mysite.settings<br />
PythonOption django.root /mysite<br />
PythonDebug On<br />
&lt;/Location&gt;<br />
</pre>
</div>
<p>...and replace <tt literal="">mysite.settings</tt> with the Python import path to your Django
project's settings file.</p>
<p>This tells Apache: "Use mod_python for any URL at or under '/mysite/', using the
Django mod_python handler." It passes the value of <a external="" href="http://docs.djangoproject.com/en/dev/topics/settings/#django-settings-module"><em>DJANGO_SETTINGS_MODULE</em></a> so mod_python knows which settings to use.</p>
<div>
New in Django 1.0: The <tt literal="">PythonOption django.root ...</tt> is new in this version.</div>
<p>Because mod_python does not know we are
serving this site from underneath the <tt literal="">/mysite/</tt> prefix, this value needs to
be passed through to the mod_python handler in Django, via the <tt literal="">PythonOption
django.root ...</tt> line. The value set on that line (the last item) should
match the string given in the <tt literal="">&lt;Location ...&gt;</tt> directive. The effect of this
is that Django will automatically strip the <tt literal="">/mysite</tt> string from the front
of any URLs before matching them against your <tt literal="">URLConf</tt> patterns. If you
later move your site to live under <tt literal="">/mysite2</tt>, you will not have to change
anything except the <tt literal="">django.root</tt> option in the config file.</p>
<p>When using <tt literal="">django.root</tt> you should make sure that what's left, after the
prefix has been removed, begins with a slash. Your URLConf patterns that are
expecting an initial slash will then work correctly. In the above example,
since we want to send things like <tt literal="">/mysite/admin/</tt> to <tt literal="">/admin/</tt>, we need
to remove the string <tt literal="">/mysite</tt> from the beginning, so that is the
<tt literal="">django.root</tt> value. It would be an error to use <tt literal="">/mysite/</tt> (with a
trailing slash) in this case.</p>
<p>Note that we're using the <tt literal="">&lt;Location&gt;</tt> directive, not the <tt literal="">&lt;Directory&gt;</tt>
directive. The latter is used for pointing at places on your filesystem,
whereas <tt literal="">&lt;Location&gt;</tt> points at places in the URL structure of a Web site.
<tt literal="">&lt;Directory&gt;</tt> would be meaningless here.</p>
<p>Also, if your Django project is not on the default <tt literal="">PYTHONPATH</tt> for your
computer, you'll have to tell mod_python where your project can be found:</p>
<pre>&lt;Location "/mysite/"&gt;<br />
SetHandler python-program<br />
PythonHandler django.core.handlers.modpython<br />
SetEnv DJANGO_SETTINGS_MODULE mysite.settings<br />
PythonOption django.root /mysite<br />
PythonDebug On<br />
<strong>PythonPath "['/path/to/project'] + sys.path"</strong><br />
&lt;/Location&gt;<br />
</pre>
<p>The value you use for <tt literal="">PythonPath</tt> should include the parent directories of
all the modules you are going to import in your application. It should also
include the parent directory of the <a external="" href="http://docs.djangoproject.com/en/dev/topics/settings/#django-settings-module"><em>DJANGO_SETTINGS_MODULE</em></a> location. This is exactly the same situation as
setting the Python path for interactive usage. Whenever you try to import
something, Python will run through all the directories in <tt literal="">sys.path</tt> in turn,
from first to last, and try to import from each directory until one succeeds.</p>
<p>An example might make this clearer. Suppose you have some applications under
<tt literal="">/usr/local/django-apps/</tt> (for example, <tt literal="">/usr/local/django-apps/weblog/</tt> and
so forth), your settings file is at <tt literal="">/var/www/mysite/settings.py</tt> and you have
specified <a external="" href="http://docs.djangoproject.com/en/dev/topics/settings/#django-settings-module"><em>DJANGO_SETTINGS_MODULE</em></a> as in the above
example. In this case, you would need to write your <tt literal="">PythonPath</tt> directive
as:</p>
<div>
<pre>PythonPath "['/usr/local/django-apps/', '/var/www'] + sys.path"<br />
</pre>
</div>
<p>With this path, <tt literal="">import weblog</tt> and <tt literal="">import mysite.settings</tt> will both
work. If you had <tt literal="">import blogroll</tt> in your code somewhere and <tt literal="">blogroll</tt>
lived under the <tt literal="">weblog/</tt> directory, you would <em>also</em> need to add
<tt literal="">/usr/local/django-apps/weblog/</tt> to your <tt literal="">PythonPath</tt>. Remember: the
<strong>parent directories</strong> of anything you import directly must be on the Python
path.</p>
<div note="">
<p admonition-title="">Note</p>
<p>If you're using Windows, we still recommended that you use forward
slashes in the pathnames, even though Windows normally uses the backslash
character as its native separator. Apache knows how to convert from the
forward slash format to the native format, so this approach is portable and
easier to read. (It avoids tricky problems with having to double-escape
backslashes.)</p>
<p>This is valid even on a Windows system:</p>
<div>
<pre>PythonPath "['c:/path/to/project'] + sys.path"<br />
</pre>
</div>
</div>
<p>You can also add directives such as <tt literal="">PythonAutoReload Off</tt> for performance.
See the <a external="" href="http://modpython.org/live/current/doc-html/directives.html">mod_python documentation</a> for a full list of options.</p>
<p>Note that you should set <tt literal="">PythonDebug Off</tt> on a production server. If you
leave <tt literal="">PythonDebug On</tt>, your users would see ugly (and revealing) Python
tracebacks if something goes wrong within mod_python.</p>
<p>Restart Apache, and any request to <tt literal="">/mysite/</tt> or below will be served by
Django. Note that Django's URLconfs won't trim the "/mysite/" -- they get passed
the full URL.</p>
<p>When deploying Django sites on mod_python, you'll need to restart Apache each
time you make changes to your Python code.</p>
</div>
<div id="s-multiple-django-installations-on-the-same-apache">
<h2 id="multiple-django-installations-on-the-same-apache">Multiple Django installations on the same Apache<a href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#multiple-django-installations-on-the-same-apache" title="Permalink to this headline">&#182;</a></h2>
<p>It's entirely possible to run multiple Django installations on the same Apache
instance. Just use <tt literal="">VirtualHost</tt> for that, like so:</p>
<div>
<pre>NameVirtualHost *<br />
<br />
&lt;VirtualHost *&gt;<br />
ServerName www.example.com<br />
# ...<br />
SetEnv DJANGO_SETTINGS_MODULE mysite.settings<br />
&lt;/VirtualHost&gt;<br />
<br />
&lt;VirtualHost *&gt;<br />
ServerName www2.example.com<br />
# ...<br />
SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings<br />
&lt;/VirtualHost&gt;<br />
</pre>
</div>
<p>If you need to put two Django installations within the same <tt literal="">VirtualHost</tt>
(or in different <tt literal="">VirtualHost</tt> blocks that share the same server name),
you'll need to take a special precaution to ensure mod_python's cache doesn't
mess things up. Use the <tt literal="">PythonInterpreter</tt> directive to give different
<tt literal="">&lt;Location&gt;</tt> directives separate interpreters:</p>
<div>
<pre>&lt;VirtualHost *&gt;<br />
ServerName www.example.com<br />
# ...<br />
&lt;Location "/something"&gt;<br />
SetEnv DJANGO_SETTINGS_MODULE mysite.settings<br />
PythonInterpreter mysite<br />
&lt;/Location&gt;<br />
<br />
&lt;Location "/otherthing"&gt;<br />
SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings<br />
PythonInterpreter othersite<br />
&lt;/Location&gt;<br />
&lt;/VirtualHost&gt;<br />
</pre>
</div>
<p>The values of <tt literal="">PythonInterpreter</tt> don't really matter, as long as they're
different between the two <tt literal="">Location</tt> blocks.</p>
</div>
<div id="s-running-a-development-server-with-mod-python">
<h2 id="running-a-development-server-with-mod-python">Running a development server with mod_python<a href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#running-a-development-server-with-mod-python" title="Permalink to this headline">&#182;</a></h2>
<p>If you use mod_python for your development server, you can avoid the hassle of
having to restart the server each time you make code changes. Just set
<tt literal="">MaxRequestsPerChild 1</tt> in your <tt literal="">httpd.conf</tt> file to force Apache to reload
everything for each request. But don't do that on a production server, or we'll
revoke your Django privileges.</p>
<p>If you're the type of programmer who debugs using scattered <tt literal="">print</tt>
statements, note that <tt literal="">print</tt> statements have no effect in mod_python; they
don't appear in the Apache log, as one might expect. If you have the need to
print debugging information in a mod_python setup, either do this:</p>
<div>
<pre>assert False, the_value_i_want_to_see<br />
</pre>
</div>
<p>Or add the debugging information to the template of your page.</p>
</div>
<div id="s-id1">
<h2 id="id1">Serving media files<a href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#id1" title="Permalink to this headline">&#182;</a></h2>
<p>Django doesn't serve media files itself; it leaves that job to whichever Web
server you choose.</p>
<p>We recommend using a separate Web server -- i.e., one that's not also running
Django -- for serving media. Here are some good choices:</p>
<ul>
    <li><a external="" href="http://www.lighttpd.net/">lighttpd</a></li>
    <li><a external="" href="http://en.wikipedia.org/wiki/TUX_web_server">TUX</a></li>
    <li>A stripped-down version of <a external="" href="http://httpd.apache.org/">Apache</a></li>
</ul>
<p>If, however, you have no option but to serve media files on the same Apache
<tt literal="">VirtualHost</tt> as Django, here's how you can turn off mod_python for a
particular part of the site:</p>
<div>
<pre>&lt;Location "/media"&gt;<br />
SetHandler None<br />
&lt;/Location&gt;<br />
</pre>
</div>
<p>Just change <tt literal="">Location</tt> to the root URL of your media files. You can also use
<tt literal="">&lt;LocationMatch&gt;</tt> to match a regular expression.</p>
<p>This example sets up Django at the site root but explicitly disables Django for
the <tt literal="">media</tt> subdirectory and any URL that ends with <tt literal="">.jpg</tt>, <tt literal="">.gif</tt> or
<tt literal="">.png</tt>:</p>
<div>
<pre>&lt;Location "/"&gt;<br />
SetHandler python-program<br />
PythonHandler django.core.handlers.modpython<br />
SetEnv DJANGO_SETTINGS_MODULE mysite.settings<br />
&lt;/Location&gt;<br />
<br />
&lt;Location "/media"&gt;<br />
SetHandler None<br />
&lt;/Location&gt;<br />
<br />
&lt;LocationMatch "".(jpg|gif|png)$"&gt;<br />
SetHandler None<br />
&lt;/LocationMatch&gt;<br />
</pre>
</div>
</div>
<div id="s-id3">
<h2 id="id3">Serving the admin files<a href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#id3" title="Permalink to this headline">&#182;</a></h2>
<p>Note that the Django development server automagically serves admin media files,
but this is not the case when you use any other server arrangement. You're
responsible for setting up Apache, or whichever media server you're using, to
serve the admin files.</p>
<p>The admin files live in (<tt literal="">django/contrib/admin/media</tt>) of the Django
distribution.</p>
<p>Here are two recommended approaches:</p>
<ol simple="">
    <li>Create a symbolic link to the admin media files from within your
    document root. This way, all of your Django-related files -- code <strong>and</strong>
    templates -- stay in one place, and you'll still be able to <tt literal="">svn
    update</tt> your code to get the latest admin templates, if they change.</li>
    <li>Or, copy the admin media files so that they live within your Apache
    document root.</li>
</ol>
</div>
<div id="s-using-eggs-with-mod-python">
<h2 id="using-eggs-with-mod-python">Using "eggs" with mod_python<a href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#using-eggs-with-mod-python" title="Permalink to this headline">&#182;</a></h2>
<p>If you installed Django from a Python <a external="" href="http://peak.telecommunity.com/DevCenter/PythonEggs">egg</a> or are using eggs in your Django
project, some extra configuration is required. Create an extra file in your
project (or somewhere else) that contains something like the following:</p>
<div>
<pre>import os<br />
os.environ['PYTHON_EGG_CACHE'] = '/some/directory'<br />
</pre>
</div>
<p>Here, <tt literal="">/some/directory</tt> is a directory that the Apache webserver process can
write to. It will be used as the location for any unpacking of code the eggs
need to do.</p>
<p>Then you have to tell mod_python to import this file before doing anything
else. This is done using the <a external="" href="http://www.modpython.org/live/current/doc-html/dir-other-pimp.html">PythonImport</a> directive to mod_python. You need
to ensure that you have specified the <tt literal="">PythonInterpreter</tt> directive to
mod_python as described <a internal="" href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#multiple-django-installations-on-the-same-apache">above</a> (you need to do this even if you aren't
serving multiple installations in this case). Then add the <tt literal="">PythonImport</tt>
line in the main server configuration (i.e., outside the <tt literal="">Location</tt> or
<tt literal="">VirtualHost</tt> sections). For example:</p>
<div>
<pre>PythonInterpreter my_django<br />
PythonImport /path/to/my/project/file.py my_django<br />
</pre>
</div>
<p>Note that you can use an absolute path here (or a normal dotted import path),
as described in the <a external="" href="http://www.modpython.org/live/current/doc-html/dir-other-pimp.html">mod_python manual</a>. We use an absolute path in the
above example because if any Python path modifications are required to access
your project, they will not have been done at the time the <tt literal="">PythonImport</tt>
line is processed.</p>
</div>
<div id="s-error-handling">
<h2 id="error-handling">Error handling<a href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#error-handling" title="Permalink to this headline">&#182;</a></h2>
<p>When you use Apache/mod_python, errors will be caught by Django -- in other
words, they won't propagate to the Apache level and won't appear in the Apache
<tt literal="">error_log</tt>.</p>
<p>The exception for this is if something is really wonky in your Django setup. In
that case, you'll see an "Internal Server Error" page in your browser and the
full Python traceback in your Apache <tt literal="">error_log</tt> file. The <tt literal="">error_log</tt>
traceback is spread over multiple lines. (Yes, this is ugly and rather hard to
read, but it's how mod_python does things.)</p>
</div>
<div id="s-if-you-get-a-segmentation-fault">
<h2 id="if-you-get-a-segmentation-fault">If you get a segmentation fault<a href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#if-you-get-a-segmentation-fault" title="Permalink to this headline">&#182;</a></h2>
<p>If Apache causes a segmentation fault, there are two probable causes, neither
of which has to do with Django itself.</p>
<ol simple="">
    <li>It may be because your Python code is importing the "pyexpat" module,
    which may conflict with the version embedded in Apache. For full
    information, see <a external="" href="http://www.dscpl.com.au/articles/modpython-006.html">Expat Causing Apache Crash</a>.</li>
    <li>It may be because you're running mod_python and mod_php in the same
    Apache instance, with MySQL as your database backend. In some cases,
    this causes a known mod_python issue due to version conflicts in PHP and
    the Python MySQL backend. There's full information in the
    <a external="" href="http://modpython.org/FAQ/faqw.py?req=show&amp;file=faq02.013.htp">mod_python FAQ entry</a>.</li>
</ol>
<p>If you continue to have problems setting up mod_python, a good thing to do is
get a barebones mod_python site working, without the Django framework. This is
an easy way to isolate mod_python-specific problems. <a external="" href="http://www.dscpl.com.au/articles/modpython-001.html">Getting mod_python Working</a>
details this procedure.</p>
<p>The next step should be to edit your test code and add an import of any
Django-specific code you're using -- your views, your models, your URLconf,
your RSS configuration, etc. Put these imports in your test handler function
and access your test URL in a browser. If this causes a crash, you've confirmed
it's the importing of Django code that causes the problem. Gradually reduce the
set of imports until it stops crashing, so as to find the specific module that
causes the problem. Drop down further into modules and look into their imports,
as necessary.</p>
</div>
<img src ="http://www.blogjava.net/sealyu/aggbug/239347.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-11-07 23:44 <a href="http://www.blogjava.net/sealyu/archive/2008/11/07/239347.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Apache + Tomcat 配置多个应用</title><link>http://www.blogjava.net/sealyu/archive/2008/08/25/224326.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Mon, 25 Aug 2008 15:14:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/08/25/224326.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/224326.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/08/25/224326.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/224326.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/224326.html</trackback:ping><description><![CDATA[最近在服务器上需要配置多个应用，使用apache+tomcat搭配，采用mod_jk进行分配。<br />
刚开始在同一个tomcat中配置了多个应用，后来感觉效果不好，改为每个tomcat对应一个应用。搜索资料如下：<br />
<a href="http://ttitfly.javaeye.com/blog/147643"><span class="hilite1">apache</span>2.2与tomcat集成(可以<span class="hilite2">多个tomcat</span>)</a><br />
1. 安装<span class="hilite1">apache</span>2.2 参见：<a href="http://ttitfly.javaeye.com/admin/show/127337" target="_blank">http://ttitfly.javaeye.com/admin/show/127337</a> <br />
<br />
2.需求概况： <br />
有2个服务：www.test.com, bbs.test.com。分别对应2个tomcat下的2个web应用。由<span class="hilite1">apache</span> httpd作为互联网接入服务器，在80端口接收对这2个服务的请求。<span class="hilite1">apache</span> httpd再将这2个请求分别对应到不同的后端web服务器(Tomcat)处理。 <br />
<br />
3.配置域名映射到本机即127.0.0.1，同时配置service域名 <br />
<br />
<div class="dp-highlighter">
<ol class="dp-j">
    <li><span><span class="number">127.0</span><span>.</span><span class="number">0.1</span><span>&nbsp;&nbsp;&nbsp;&nbsp;localhost&nbsp;www.test.com&nbsp;www.service.test.com&nbsp;bbs.test.com&nbsp;bbs.service.test.com&nbsp;&nbsp;</span></span> </li>
</ol>
</div>
<pre class="java" style="display: none" name="code">127.0.0.1    localhost www.test.com www.service.test.com bbs.test.com bbs.service.test.com</pre>
<br />
<br />
4. 分别在2个tomcat里分别部署一个非常简单的应用。 <br />
<br />
第一个tomcat ：端口:8080 <br />
<br />
编辑$TOMCAT_HOME/conf/server.xml <br />
<br />
添加一个Host
<div class="dp-highlighter">
<div class="bar"><span><span>&lt;Host&nbsp;name=</span><span class="string">"www.service.test.com"</span><span>&nbsp;unpackWARs=</span><span class="string">"true"</span><span>&nbsp;autoDeploy=</span><span class="string">"true"</span><span>&nbsp;&nbsp;</span></span> </div>
<ol class="dp-j">
    <li><span>xmlValidation=</span><span class="string">"false"</span><span>&nbsp;xmlNamespaceAware=</span><span class="string">"false"</span><span>/&gt;&nbsp;&nbsp;</span></span> </li>
</ol>
</div>
<pre class="java" style="display: none" name="code">&lt;Host name="www.service.test.com" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"/&gt;</pre>
<br />
<br />
再在$TOMCAT_HOME/conf/Catalina下建立一个目录:www.service.test.com <br />
然后在www.service.test.com目录下建立一个ROOT.xml,内容为： <br />
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-j">
    <li><span><span>&lt;Context&nbsp;docBase=</span><span class="string">"/home/mahaibo/app/test"</span><span>&nbsp;&nbsp;</span></span>
    <li><span>privileged=</span><span class="string">"true"</span><span>&nbsp;antiResourceLocking=</span><span class="string">"false"</span><span>&nbsp;antiJARLocking=</span><span class="string">"false"</span><span>&gt; &nbsp;&nbsp;</span></span>
    <li><span>&lt;/Context&gt;&nbsp;&nbsp;</span> </li>
</ol>
</div>
<pre class="java" style="display: none" name="code">&lt;Context docBase="/home/mahaibo/app/test"
privileged="true" antiResourceLocking="false" antiJARLocking="false"&gt;
&lt;/Context&gt;</pre>
<br />
<span style="color: red">docBase指向具体的项目路径</span> <br />
<br />
同理第二个tomcat（端口8088）也是一样的做法： <br />
<br />
编辑$TOMCAT_HOME/conf/server.xml <br />
<br />
添加一个Host: <br />
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-j">
    <li><span><span>&lt;Host&nbsp;name=</span><span class="string">"bbs.service.test.com"</span><span>&nbsp;unpackWARs=</span><span class="string">"true"</span><span>&nbsp;autoDeploy=</span><span class="string">"true"</span><span>&nbsp;&nbsp;</span></span>
    <li><span>xmlValidation=</span><span class="string">"false"</span><span>&nbsp;xmlNamespaceAware=</span><span class="string">"false"</span><span>/&gt;&nbsp;&nbsp;</span></span> </li>
</ol>
</div>
<pre class="java" style="display: none" name="code">&lt;Host name="bbs.service.test.com" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"/&gt;</pre>
<br />
<br />
<br />
然后在$TOMCAT_HOME/conf/Catalina下建立一个目录:bbs.service.test.com <br />
<br />
再在bbs.service.test.com目录下建立一个ROOT.xml,内容为： <br />
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-j">
    <li><span><span>&lt;Context&nbsp;docBase=</span><span class="string">"/home/mahaibo/app/bbs"</span><span>&nbsp;&nbsp;</span></span>
    <li><span>privileged=</span><span class="string">"true"</span><span>&nbsp;antiResourceLocking=</span><span class="string">"false"</span><span>&nbsp;antiJARLocking=</span><span class="string">"false"</span><span>&gt; &nbsp;&nbsp;</span></span>
    <li><span>&lt;/Context&gt;&nbsp;&nbsp;</span> </li>
</ol>
</div>
<pre class="java" style="display: none" name="code">&lt;Context docBase="/home/mahaibo/app/bbs"
privileged="true" antiResourceLocking="false" antiJARLocking="false"&gt;
&lt;/Context&gt;</pre>
<br />
<br />
5. 分别启动tomcat，可以通过http://www.service.test.com:8080和http://bbs.service.test.com:8088访问 <br />
<br />
6. 配置<span class="hilite1">apache</span> httpd.conf文件。 <br />
<br />
找到apach/conf/httpd.conf文件，确认下面这些文字行前面没有"#"注释号： <br />
<br />
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-j">
    <li><span><span>LoadModule&nbsp;proxy_module&nbsp;modules/mod_proxy.so &nbsp;&nbsp;</span></span>
    <li><span>LoadModule&nbsp;proxy_ajp_module&nbsp;modules/mod_proxy_ajp.so &nbsp;&nbsp;</span>
    <li><span>LoadModule&nbsp;proxy_balancer_module&nbsp;modules/mod_proxy_balancer.so &nbsp;&nbsp;</span>
    <li><span>LoadModule&nbsp;proxy_connect_module&nbsp;modules/mod_proxy_connect.so &nbsp;&nbsp;</span>
    <li><span>LoadModule&nbsp;proxy_http_module&nbsp;modules/mod_proxy_http.so &nbsp;&nbsp;</span>
    <li><span>LoadModule&nbsp;proxy_ftp_module&nbsp;modules/mod_proxy_ftp.so&nbsp;&nbsp;</span> </li>
</ol>
</div>
<pre class="java" style="display: none" name="code">LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so</pre>
<br />
<br />
并增加虚拟主机配置： <br />
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-j">
    <li><span><span>NameVirtualHost&nbsp;*:</span><span class="number">80</span><span>&nbsp;&nbsp;</span></span>
    <li><span>&lt;VirtualHost&nbsp;*:</span><span class="number">80</span><span>&gt; &nbsp;&nbsp;</span></span>
    <li><span>ServerName&nbsp;www.test.com &nbsp;&nbsp;</span>
    <li><span>ProxyIOBufferSize&nbsp;</span><span class="number">8192</span><span>&nbsp;&nbsp;</span></span>
    <li><span>ProxyRequests&nbsp;Off &nbsp;&nbsp;</span>
    <li><span>ProxyVia&nbsp;Full &nbsp;&nbsp;</span>
    <li><span>ProxyPass&nbsp;/&nbsp;http:</span><span class="comment">//www.service.test.com:8080/&nbsp;smax=5&nbsp;max=20&nbsp;ttl=120&nbsp;retry=300 </span><span>&nbsp;&nbsp;</span></span>
    <li><span>&lt;/VirtualHost&gt; &nbsp;&nbsp;</span>
    <li><span>&nbsp;&nbsp;</span>
    <li><span>&lt;VirtualHost&nbsp;*:</span><span class="number">80</span><span>&gt; &nbsp;&nbsp;</span></span>
    <li><span>ServerName&nbsp;bbs.test.com &nbsp;&nbsp;</span>
    <li><span>ProxyIOBufferSize&nbsp;</span><span class="number">8192</span><span>&nbsp;&nbsp;</span></span>
    <li><span>ProxyRequests&nbsp;Off &nbsp;&nbsp;</span>
    <li><span>ProxyVia&nbsp;Full &nbsp;&nbsp;</span>
    <li><span>ProxyPass&nbsp;/&nbsp;http:</span><span class="comment">//bbs.service.test.com:8088/&nbsp;smax=5&nbsp;max=20&nbsp;ttl=120&nbsp;retry=300 </span><span>&nbsp;&nbsp;</span></span>
    <li><span>&lt;/VirtualHost&gt;&nbsp;&nbsp;</span> </li>
</ol>
</div>
<pre class="java" style="display: none" name="code">NameVirtualHost *:80
&lt;VirtualHost *:80&gt;
ServerName www.test.com
ProxyIOBufferSize 8192
ProxyRequests Off
ProxyVia Full
ProxyPass / http://www.service.test.com:8080/ smax=5 max=20 ttl=120 retry=300
&lt;/VirtualHost&gt;
&lt;VirtualHost *:80&gt;
ServerName bbs.test.com
ProxyIOBufferSize 8192
ProxyRequests Off
ProxyVia Full
ProxyPass / http://bbs.service.test.com:8088/ smax=5 max=20 ttl=120 retry=300
&lt;/VirtualHost&gt;
</pre>
<br />
<br />
7.启动<span class="hilite1">apache</span> <br />
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-j">
    <li><span><span>./&lt;SPAN&nbsp;</span><span class="keyword">class</span><span>=hilite1&gt;apache&lt;/SPAN&gt;ctl&nbsp;start&nbsp;&nbsp;</span></span> </li>
</ol>
<br />
</div>
<pre class="java" style="display: none" name="code">./<span class="hilite1">apache</span>ctl start</pre>
<br />
<br />
8 可以通过访问http://www.test.com和http://bbs.test.com来分别访问2个不同tomcat下的不同应用了。<br />
&nbsp;<br />
<br />
<br />
<br />
apache+tomcat配置负载均衡的网站 <br />
<br />
<h1 style="margin: 17pt 0cm 16.5pt 21.25pt; text-indent: -21.25pt; tab-stops: list 21.25pt">1.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp; </span><span style="font-family: 宋体">目标</span> </h1>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">使用</span> apache <span style="font-family: 宋体">和</span> tomcat <span style="font-family: 宋体">配置一个可以应用的</span> web <span style="font-family: 宋体">网站，要达到以下要求：</span> </p>
<p style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; tab-stops: list 18.0pt">1、&nbsp;Apache <span style="font-family: 宋体">做为</span> HttpServer <span style="font-family: 宋体">，后面连接多个</span> tomcat <span style="font-family: 宋体">应用实例，并进行负载均衡。</span> </p>
<p style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; tab-stops: list 18.0pt">2、&nbsp;<span style="font-family: 宋体">为系统设定</span> Session <span style="font-family: 宋体">超时时间，包括</span> Apache <span style="font-family: 宋体">和</span> tomcat </p>
<p style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; tab-stops: list 18.0pt">3、&nbsp;<span style="font-family: 宋体">为系统屏蔽文件列表，包括</span> Apache <span style="font-family: 宋体">和</span> tomcat </p>
<h1 style="margin: 17pt 0cm 16.5pt 21.25pt; text-indent: -21.25pt; tab-stops: list 21.25pt">2.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp; </span><span style="font-family: 宋体">安装</span> tomcat </h1>
<h2 style="margin: 13pt 0cm 13pt 1cm; text-indent: -1cm; tab-stops: list 1.0cm">2.1. <span style="font-family: 黑体">下载，解压</span> tomcat </h2>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">不要下载安装版</span> , <span style="font-family: 宋体">下载地址</span> </p>
<p style="margin: 0cm 0cm 0pt"><a href="http://tomcat.apache.org/">http://tomcat.apache.org</a> </p>
<h2 style="margin: 13pt 0cm 13pt 1cm; text-indent: -1cm; tab-stops: list 1.0cm">2.2. <span style="font-family: 黑体">配置</span> tomcat </h2>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">2.2.1. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置</span> server <span style="font-family: 宋体">的关闭口</span> </h3>
<p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-family: 宋体">我们需要在一台机器上跑</span> 2 <span style="font-family: 宋体">个不同的</span> tomcat <span style="font-family: 宋体">，需要修改不同的</span> tomcat <span style="font-family: 宋体">的关闭口，避免出现端口被占用的情况。在</span> server.xml <span style="font-family: 宋体">中找到</span> server, <span style="font-family: 宋体">将：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;Server port="8005" shutdown="SHUTDOWN"&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">改为</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;Server port="<span style="color: #ff6600">XXXX</span>" shutdown="SHUTDOWN"&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="color: #ff6600">XXXX</span> <span style="font-family: 宋体">在这里表示不同的端口：我的两个</span> tomcat <span style="font-family: 宋体">分别使用</span> 8035 <span style="font-family: 宋体">，</span> 8045 </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">注意：这里之所以要配置不同的</span> tomcat <span style="font-family: 宋体">关闭口，只是因为我们使用了多个</span> tomcat <span style="font-family: 宋体">，其实用一个</span> server <span style="font-family: 宋体">多个实例也可以。</span> </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">2.2.2. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置</span> service </h3>
<p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-family: 宋体">我们需要对不同的</span> tomcat <span style="font-family: 宋体">的</span> service <span style="font-family: 宋体">取不同的名字，在</span> server.xml <span style="font-family: 宋体">中找到：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;Service name="Catalina"&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">改为：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;Service name="<span style="color: #ff6600">XXXX</span>"&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">两个</span> service <span style="font-family: 宋体">分别为</span> tomcat6 <span style="font-family: 宋体">和</span> tomcat5 </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">2.2.3. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置</span> Connector </h3>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">这个部分主要是要改两个</span> Connector <span style="font-family: 宋体">，当然前提是你的</span> tomcat <span style="font-family: 宋体">只有两个</span> Connector <span style="font-family: 宋体">。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">修改</span> ajp1.3 <span style="font-family: 宋体">的端口：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">找到：</span> <span style="background: silver">&lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">改为：</span> <span style="background: silver">&lt;Connector port="<span style="color: #ff6600">XXXX</span>" protocol="AJP/1.3" redirectPort="8443" /&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">两个</span> Service <span style="font-family: 宋体">的</span> ajp/1.3 <span style="font-family: 宋体">的端口分别为：</span> 8019 <span style="font-family: 宋体">，</span> 8029 </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">修改</span> http <span style="font-family: 宋体">的端口：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">找到：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;Connector port="8080" protocol="HTTP/1.1" </span></p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxThreads="150" connectionTimeout="20000" </span></p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; redirectPort="8443" /&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">改为：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;Connector port="<span style="color: #ff6600">XXXX</span>" protocol="HTTP/1.1" </span></p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxThreads="150" connectionTimeout="20000" </span></p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; redirectPort="8443" /&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">两个</span> Service <span style="font-family: 宋体">的</span> ajp/1.3 <span style="font-family: 宋体">的端口分别为：</span> 8060 <span style="font-family: 宋体">，</span> 8070 </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">2.2.4. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置</span> Engine </h3>
<p style="margin: 0cm 0cm 0pt">Engine <span style="font-family: 宋体">主要是配置</span> jvmRoute <span style="font-family: 宋体">属性，找到：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;Engine name="Catalina" defaultHost="localhost"&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">改为：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;Engine jvmRoute="XXXX" name="Catalina" defaultHost="localhost"&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">两个实例分别为：</span> tomcat6 <span style="font-family: 宋体">和</span> tomcat5. </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">2.2.5. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置公用性</span> Context </h3>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">如果有</span> Context <span style="font-family: 宋体">是多个系统公用的，比如图片等的存放地，可以做个配置：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">在</span> Host <span style="font-family: 宋体">中增加：</span> </p>
<p style="background: white; margin: 0cm 0cm 0pt; line-height: 150%"><span style="font-size: 10pt; color: #4b4b4b; line-height: 150%; font-family: Verdana">&lt;Context path="/image" docBase="D:"webRoot"image" debug="0" reloadable="false" crossContext="true"&gt; </span></p>
<p style="background: white; margin: 0cm 0cm 0pt; line-height: 150%"><span style="font-size: 10pt; color: #4b4b4b; line-height: 150%; font-family: Verdana">&lt;/Context&gt; </span></p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">2.2.6. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">屏蔽文件列表 </span></h3>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">打开</span> tomcat <span style="font-family: 宋体">目录下的</span> conf/web.xml <span style="font-family: 宋体">，</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">找到：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;servlet&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;servlet-name&gt;default&lt;/servlet-name&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;servlet-class&gt;org.apache.catalina.servlets.DefaultServlet&lt;/servlet-class&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;init-param&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param-name&gt;debug&lt;/param-name&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param-value&gt;0&lt;/param-value&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/init-param&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;init-param&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param-name&gt;listings&lt;/param-name&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param-value&gt;<span style="color: #ff6600">true</span>&lt;/param-value&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/init-param&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp; &lt;/servlet&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">将</span> listings <span style="font-family: 宋体">参数改为</span> false; </p>
<h2 style="margin: 13pt 0cm 13pt 1cm; text-indent: -1cm; tab-stops: list 1.0cm">2.3. <span style="font-family: 黑体">配置应用</span> (web.xml) </h2>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">对系统应用做些控制。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">配置</span> session <span style="font-family: 宋体">过期时间，大多数网站用户都只是做些浏览性的操作，为了减轻服务器负载压力，我们将</span> session <span style="font-family: 宋体">超时时间从默认的</span> 30 <span style="font-family: 宋体">分钟变为</span> 5 <span style="font-family: 宋体">分钟。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">在</span> web <span style="font-family: 宋体">应用程序的</span> web.xml <span style="font-family: 宋体">中</span> servlet-mapping <span style="font-family: 宋体">之后增加如下一段：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;session-config&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp; &lt;session-timeout&gt;5&lt;/session-timeout&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;/session-config&gt;</span> </p>
<h1 style="margin: 17pt 0cm 16.5pt 21.25pt; text-indent: -21.25pt; tab-stops: list 21.25pt">3.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp; </span><span style="font-family: 宋体">安装</span> Apache </h1>
<h2 style="margin: 13pt 0cm 13pt 1cm; text-indent: -1cm; tab-stops: list 1.0cm">3.1. <span style="font-family: 黑体">下载、安装</span> Apache </h2>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">下载地址</span> <a href="http://httpd.apache.org/download.cgi">http://httpd.apache.org/download.cgi</a> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">下载后点击安装</span> msi <span style="font-family: 宋体">文件。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">安装的时候没有什么特别需要注意的地方，按照默认就行了。是否安装为</span> service <span style="font-family: 宋体">看具体情况而定。</span> </p>
<h2 style="margin: 13pt 0cm 13pt 1cm; text-indent: -1cm; tab-stops: list 1.0cm">3.2. <span style="font-family: 黑体">下载、安装</span> Apache <span style="font-family: 黑体">、</span> tomcat <span style="font-family: 黑体">的</span> Connector </h2>
<p style="margin: 0cm 0cm 0pt"><a href="http://tomcat.apache.org/download-connectors.cgi">http://tomcat.apache.org/download-connectors.cgi</a> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">注意，很多网站上都介绍是</span> JK2 <span style="font-family: 宋体">，可能是觉得</span> JK2 <span style="font-family: 宋体">比</span> JK <span style="font-family: 宋体">要新吧，其实</span> JK2 <span style="font-family: 宋体">已经停止研发了，建议使用</span> jk1.2 <span style="font-family: 宋体">。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">下载压缩包，之后将</span> module <span style="font-family: 宋体">目录中的</span> <span style="color: #4b4b4b">mod_jk-apache****.so</span> <span style="color: #4b4b4b; font-family: 宋体">文件放入</span> <span style="color: #4b4b4b">/module/</span> <span style="color: #4b4b4b; font-family: 宋体">目录下。</span> </p>
<h2 style="margin: 13pt 0cm 13pt 1cm; text-indent: -1cm; tab-stops: list 1.0cm">3.3. <span style="font-family: 黑体">配置</span> Apache <span style="font-family: 黑体">（</span> httpd.conf <span style="font-family: 黑体">）</span> </h2>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">3.3.1. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置端口： </span></h3>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">找到</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">Listen 80</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">改为</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">Listen **</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">当然如果不需要改的话，就不用改了。正常情况无须更改。</span> </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">3.3.2. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置</span> DocumentRoot </h3>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">找到</span> DocumentRoot <span style="font-family: 宋体">段，将其改为：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">DocumentRoot "E:/MyWebsite"</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">这里的</span> <span style="background: silver">"E:/MyWebsite"</span> <span style="font-family: 宋体">指的是你的</span> web <span style="font-family: 宋体">程序的根路径，视具体应用而定。</span> </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">3.3.3. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置</span> serverName </h3>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">找到</span> serverName <span style="font-family: 宋体">这个段，将其配置为你的</span> ServerName </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">如果没有配置为域名，配为</span> IP <span style="font-family: 宋体">也可以，此处还不是很清楚，多虚拟主机的情况的配置。</span> </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">3.3.4. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置虚拟主机 </span></h3>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;VirtualHost *:80&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp; ServerAdmin flyffa@gmail.com</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp; DocumentRoot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; E:/MyWebsite</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp; ServerName localhost</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp; DirectoryIndex index.html index.htm index.jsp</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp; ErrorLog logs/error_log</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp; CustomLog logs/access_log common</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&nbsp;&nbsp;&nbsp; ErrorDocument 404 /sys/logon.jsp</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">&lt;/VirtualHost&gt;</span> </p>
<h2 style="margin: 13pt 0cm 13pt 1cm; text-indent: -1cm; tab-stops: list 1.0cm">3.4. <span style="font-family: 黑体">配置</span> JK <span style="font-family: 黑体">方式的负载均衡</span> </h2>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">3.4.1. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置</span> module </h3>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">我们需要与</span> tomcat <span style="font-family: 宋体">做连接，所以要把</span> tomcat <span style="font-family: 宋体">的</span> connector <span style="font-family: 宋体">的模块配置进去。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">在</span> LoadModule <span style="font-family: 宋体">部分加入：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">LoadModule jk_module modules/mod_jk-apache-2.0.55.so</span> <span style="font-family: 宋体">－加载模块</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">这个</span> so <span style="font-family: 宋体">是我下载的版本，个人可以根据自己下载的文件名加以配置</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">JkWorkersFile conf/workers.properties</span> <span style="font-family: 宋体">－指定</span> connector <span style="font-family: 宋体">的配置文件名称</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">JkLogFile logs/mod_jk.log</span> <span style="font-family: 宋体">－指定</span> connector <span style="font-family: 宋体">的日志文件名称</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">JkLogLevel info</span> <span style="font-family: 宋体">－指定</span> connector <span style="font-family: 宋体">的日志等级</span> </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">3.4.2. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置</span> worker <span style="font-family: 宋体">列表</span> (conf/workers.properties) </h3>
<p style="margin: 0cm 0cm 0pt"><strong><span style="font-family: 宋体">定义列表</span> </strong></p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.list=tomcat6,tomcat5,loadbalancer</span> </p>
<p style="margin: 0cm 0cm 0pt"><strong><span style="font-family: 宋体">定义一个名为</span> &#8220;loadbalancer&#8221; </strong><strong><span style="font-family: 宋体">的</span> worker </strong></p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">其作为对多个</span> Tomcat <span style="font-family: 宋体">进程的负载平衡使用：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.loadbalancer.type=lb </span></p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.loadbalancer.balanced_workers=tomcat5, tomcat6</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">（</span> <span style="font-family: 宋体">负载平衡类型的</span> worker <span style="font-family: 宋体">并不与</span> Tomcat worker <span style="font-family: 宋体">通讯，它负责管理这些</span> Tomcat worker <span style="font-family: 宋体">。</span> <span style="font-family: 宋体">）</span> </p>
<p style="margin: 0cm 0cm 0pt"><strong><span style="font-family: 宋体">定义多个</span> worker </strong><strong><span style="font-family: 宋体">列表</span> </strong></p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver"># Set properties for tomcat6 (ajp13)</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat6.type=ajp13</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat6.host=localhost</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat6.port=8019</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat6.lbfactor=50</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat6.cachesize=10</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat6.cache_timeout=600</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat6.socket_keepalive=1</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat6.reclycle_timeout=300</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver"># Set properties for tomcat5 (ajp13)</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat5.type=ajp13</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat5.host=localhost</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat5.port=8029</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat5.lbfactor=50</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat5.cachesize=10</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat5.cache_timeout=600</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat5.socket_keepalive=1</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">worker.tomcat5.reclycle_timeout=300</span> </p>
<p style="background: white; margin: 0cm 0cm 0pt 5.45pt; line-height: 150%"><span style="color: #ff6600; font-family: 宋体">注意：</span> <strong><span style="color: red; line-height: 150%">lbfactor=</span> </strong><strong><span style="color: blue; line-height: 150%">50</span> </strong><span style="font-family: 宋体">（</span> <span style="font-family: 宋体">当此</span> Tomcat worker <span style="font-family: 宋体">被用于一个负载平衡</span> worker <span style="font-family: 宋体">使用时，此属性将被使用。它定义了此</span> worker <span style="font-family: 宋体">的负载平衡权值。</span> <span style="font-family: 宋体">）</span> </p>
<p style="background: white; margin: 0cm 0cm 0pt 5.45pt; line-height: 150%"><strong><span style="color: red; line-height: 150%">cachesize=</span> </strong><strong><span style="color: blue; line-height: 150%">10</span> </strong><span style="font-family: 宋体">（</span> <span style="font-family: 宋体">当在多线程的</span> web server <span style="font-family: 宋体">（例如</span> apache2.0 <span style="font-family: 宋体">、</span> IIS <span style="font-family: 宋体">、</span> Netscape <span style="font-family: 宋体">）中使用</span> JK <span style="font-family: 宋体">时，此属性是有效的。如果将</span> cachesize <span style="font-family: 宋体">的值设置为较高的值，这些支持多线程的</span> web server <span style="font-family: 宋体">将获得很好的处理能力。如果此属性不被设置，则连接</span> cache <span style="font-family: 宋体">特性将失效。</span> <span style="font-family: 宋体">）</span> </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">3.4.3. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">配置</span> Apache <span style="font-family: 宋体">到</span> tomcat <span style="font-family: 宋体">的桥接</span> </h3>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">在</span> DocumnetRoot <span style="font-family: 宋体">片段下加入</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">JkMount /*.jsp tomcat6</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">JkMount /*.do tomcat6</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">JkMount /*Servlet tomcat6</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">这里只是简单的将</span> apache <span style="font-family: 宋体">的请求转到其中的一个</span> tomcat <span style="font-family: 宋体">中，形成桥接，至于负载均衡的时候，就无须进行这步操作，直接启动负载均衡。启动负载均衡见下一节。</span> </p>
<h3 style="margin: 13pt 0cm 13pt 35.45pt; text-indent: -35.45pt; tab-stops: list 35.45pt">3.4.4. <span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">启动负载均衡 </span></h3>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">在</span> DocumnetRoot <span style="font-family: 宋体">片段下加入</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">JkMount /*.jsp loadbalancer</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">JkMount /*.do loadbalancer</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">JkMount /*Servlet loadbalancer</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">－指定对所有的请求启动负载均衡，这里的</span> loadbalancer <span style="font-family: 宋体">是<span style="color: #ff6600">定义的</span></span> <span style="color: #ff6600">worker</span> <span style="color: #ff6600; font-family: 宋体">的名字</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="color: red; font-family: 宋体">这里我在配置的时候犯了两个错误：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="color: #ff6600; font-family: 宋体">第一是没有配置</span> <span style="background: silver">JkWorkersFile conf/workers.properties</span> <span style="font-family: 宋体">，以为</span> Apache <span style="font-family: 宋体">会自动认识（其实</span> apache <span style="font-family: 宋体">是自动产生了一个叫做</span> ajp13 <span style="font-family: 宋体">的</span> worker <span style="font-family: 宋体">，指向本机的</span> 8009 <span style="font-family: 宋体">端口）。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">第二是以为</span> <span style="background: silver">JkMount</span> <span style="font-family: 宋体">语句中出现</span> loadbalancer,ajp13 <span style="font-family: 宋体">之类的是系统设定的东西，其实都是在</span> workers.properties <span style="font-family: 宋体">文件中定义的，结果出现名字不匹配的情况。后来配置了</span> <span style="background: silver">JkLogFile logs/mod_jk.log</span> <span style="font-family: 宋体">之后看到错误日志才明白。</span> </p>
<h2 style="margin: 13pt 0cm 13pt 1cm; text-indent: -1cm; tab-stops: list 1.0cm">3.5. <span style="font-family: 黑体">配置</span> Proxy <span style="font-family: 黑体">方式的负载均衡</span> </h2>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">使用</span> Apache2.1 <span style="font-family: 宋体">以上的版本，就可以用</span> mod_proxy_ajp <span style="font-family: 宋体">来完成负载均衡的配置，不过到目前为止，没有看到如何让</span> Apache <span style="font-family: 宋体">负责静态部分，</span> tomcat <span style="font-family: 宋体">负责动态部分的配置方式，只能用</span> path <span style="font-family: 宋体">进行区分分发请求。如：在虚拟主机的配置中增加：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">ProxyPass / ajp://localhost:8019/</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">ProxyPassReverse / ajp://localhost:8019/</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">而形如：</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">ProxyPass /*.jsp ajp://localhost:8019/</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="background: silver">ProxyPassReverse /*.jsp ajp://localhost:8019/</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">这样的配置是不能通过的。</span> </p>
<img src ="http://www.blogjava.net/sealyu/aggbug/224326.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-08-25 23:14 <a href="http://www.blogjava.net/sealyu/archive/2008/08/25/224326.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java.lang.OutOfMemoryError: PermGen space及其解决方法</title><link>http://www.blogjava.net/sealyu/archive/2008/08/25/224195.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Mon, 25 Aug 2008 08:22:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/08/25/224195.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/224195.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/08/25/224195.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/224195.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/224195.html</trackback:ping><description><![CDATA[<div>
<p>1、<br />
</p>
<p>PermGen space的全称是Permanent Generation
space,是指内存的永久保存区域OutOfMemoryError: PermGen
space从表面上看就是内存益出，解决方法也一定是加大内存。说说为什么会内存益出：这一部分用于存放Class和Meta的信息,Class在被
Load的时候被放入PermGen space区域，它和和存放Instance的Heap区域不同,GC(Garbage
Collection)不会在主程序运行期对PermGen
space进行清理，所以如果你的APP会LOAD很多CLASS的话,就很可能出现PermGen
space错误。这种错误常见在web服务器对JSP进行pre compile的时候。</p>
改正方法：-Xms256m -Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256m </div>
<p>2、</p>
<p>在tomcat中redeploy时出现outofmemory的错误.</p>
<p>可以有以下几个方面的原因:</p>
<p>１,使用了<u><font color="#800080">proxool,因为proxool内部包含了一个老版本的cglib.</font></u></p>
<p><u><font color="#800080">2, log4j,最好不用,只用common-logging</font></u></p>
<p><u><font color="#800080">3, 老版本的cglib,快点更新到最新版。</font></u></p>
<p><u><font color="#800080">４，更新到最新的hibernate3.2</font></u><br />
</p>
3、<br />
<br />
这里以tomcat环境为例，其它WEB服务器如jboss,weblogic等是同一个道理。<br />
一、java.lang.OutOfMemoryError: PermGen space
<p>PermGen space的全称是Permanent Generation space,是指内存的永久保存区域,<br />
这块内存主要是被JVM存放Class和Meta信息的,Class在被Loader时就会被放到PermGen space中,<br />
它和存放类实例(Instance)的Heap区域不同,GC(Garbage Collection)不会在主程序运行期对<br />
PermGen space进行清理，所以如果你的应用中有很多CLASS的话,就很可能出现PermGen space错误,<br />
这种错误常见在web服务器对JSP进行pre compile的时候。如果你的WEB APP下都用了大量的第三方jar, 其大小<br />
超过了jvm默认的大小(4M)那么就会产生此错误信息了。<br />
解决方法： 手动设置MaxPermSize大小</p>
<p>修改TOMCAT_HOME/bin/catalina.sh<br />
在&#8220;echo "Using CATALINA_BASE:&nbsp;&nbsp; $CATALINA_BASE"&#8221;上面加入以下行：<br />
JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m<br />
建议：将相同的第三方jar文件移置到tomcat/shared/lib目录下，这样可以达到减少jar 文档重复占用内存的目的。</p>
<p>二、java.lang.OutOfMemoryError: Java heap space<br />
Heap size 设置<br />
JVM堆的设置是指java程序运行过程中JVM可以调配使用的内存空间的设置.JVM在启动的时候会自动设置Heap size的值，<br />
其初始空间(即-Xms)是物理内存的1/64，最大空间(-Xmx)是物理内存的1/4。可以利用JVM提供的-Xmn -Xms -Xmx等选项可<br />
进行设置。Heap size 的大小是Young Generation 和Tenured Generaion 之和。<br />
提示：在JVM中如果98％的时间是用于GC且可用的Heap size 不足2％的时候将抛出此异常信息。<br />
提示：Heap Size 最大不要超过可用物理内存的80％，一般的要将-Xms和-Xmx选项设置为相同，而-Xmn为1/4的-Xmx值。 <br />
解决方法：手动设置Heap size<br />
修改TOMCAT_HOME/bin/catalina.sh<br />
在&#8220;echo "Using CATALINA_BASE:&nbsp;&nbsp; $CATALINA_BASE"&#8221;上面加入以下行：<br />
JAVA_OPTS="-server -Xms800m -Xmx800m&nbsp;&nbsp; -XX:MaxNewSize=256m"</p>
<p>三、实例，以下给出1G内存环境下java jvm 的参数设置参考：</p>
<p>JAVA_OPTS="-server -Xms800m -Xmx800m&nbsp; -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true "</p>
<p><br />
三、相关资料</p>
<p><a href="http://www.tot.name/show/3/7/20061112220131.htm"><font color="#004299">/show/3/7/20061112220131.htm</font><img id="snap_com_shot_link_icon" class="snap_preview_icon" style="border: 0pt none ; margin: 0pt ! important; padding: 1px 0pt 0pt; max-height: 2000px; max-width: 2000px; min-width: 0px; min-height: 0px; font-style: normal; font-weight: normal; font-family: &quot;trebuchet ms&quot;,arial,helvetica,sans-serif; float: none; position: static; left: auto; top: auto; line-height: normal; background-image: url(http://i.ixnp.com/images/v3.44/theme/silver/palette.gif); background-color: transparent; visibility: visible; width: 14px; height: 12px; background-position: -1128px 0pt; background-repeat: no-repeat; text-decoration: none; vertical-align: top; display: inline;" src="http://i.ixnp.com/images/v3.44/t.gif"  alt="" /></a></p>
<p><a href="http://www.tot.name/show/3/7/20061112220054.htm"><font color="#004299">/show/3/7/20061112220054.htm</font><img id="snap_com_shot_link_icon" class="snap_preview_icon" style="border: 0pt none ; margin: 0pt ! important; padding: 1px 0pt 0pt; max-height: 2000px; max-width: 2000px; min-width: 0px; min-height: 0px; font-style: normal; font-weight: normal; font-family: &quot;trebuchet ms&quot;,arial,helvetica,sans-serif; float: none; position: static; left: auto; top: auto; line-height: normal; background-image: url(http://i.ixnp.com/images/v3.44/theme/silver/palette.gif); background-color: transparent; visibility: visible; width: 14px; height: 12px; background-position: -1128px 0pt; background-repeat: no-repeat; text-decoration: none; vertical-align: top; display: inline;" src="http://i.ixnp.com/images/v3.44/t.gif"  alt="" /></a></p>
<p><a href="http://www.tot.name/show/3/7/20061112220201.htm"><font color="#004299">/show/3/7/20061112220201.htm</font><img id="snap_com_shot_link_icon" class="snap_preview_icon" style="border: 0pt none ; margin: 0pt ! important; padding: 1px 0pt 0pt; max-height: 2000px; max-width: 2000px; min-width: 0px; min-height: 0px; font-style: normal; font-weight: normal; font-family: &quot;trebuchet ms&quot;,arial,helvetica,sans-serif; float: none; position: static; left: auto; top: auto; line-height: normal; background-image: url(http://i.ixnp.com/images/v3.44/theme/silver/palette.gif); background-color: transparent; visibility: visible; width: 14px; height: 12px; background-position: -1128px 0pt; background-repeat: no-repeat; text-decoration: none; vertical-align: top; display: inline;" src="http://i.ixnp.com/images/v3.44/t.gif"  alt="" /></a></p>
题外话：经常看到网友抱怨tomcat的性能不如...，不稳定等，其实根据笔者几年的经验，从"互联星空&#8220;到现在的房产门户网，我们<br />
均使用tomcat作为WEB服务器，每天访问量百万多，tomcat仍然运行良好。建议大家有问题多从自己程序入手，多看看java的DOC文档<br />
并详细了解JVM的知识。这样开发的程序才会健壮。<br />
<br />
<font style="font-weight: bold;" size="4"><span style="color: #99cc00;">延伸阅读：</span></font>
<h3><a href="http://www.wujianrong.com/archives/2007/02/jvm_1.html#more"><font color="#004299">JVM 性能调整的一些基本概念</font><img id="snap_com_shot_link_icon" class="snap_preview_icon" style="border: 0pt none ; margin: 0pt ! important; padding: 1px 0pt 0pt; max-height: 2000px; max-width: 2000px; min-width: 0px; min-height: 0px; font-style: normal; font-weight: normal; font-family: &quot;trebuchet ms&quot;,arial,helvetica,sans-serif; float: none; position: static; left: auto; top: auto; line-height: normal; background-image: url(http://i.ixnp.com/images/v3.44/theme/silver/palette.gif); background-color: transparent; visibility: visible; width: 14px; height: 12px; background-position: -1128px 0pt; background-repeat: no-repeat; text-decoration: none; vertical-align: top; display: inline;" src="http://i.ixnp.com/images/v3.44/t.gif"  alt="" /></a></h3>
<h2><a href="http://www.wujianrong.com/archives/2006/11/apachetomcat.html"><font color="#004299">apache+Tomcat负载平衡设置详解[转]</font><img id="snap_com_shot_link_icon" class="snap_preview_icon" style="border: 0pt none ; margin: 0pt ! important; padding: 1px 0pt 0pt; max-height: 2000px; max-width: 2000px; min-width: 0px; min-height: 0px; font-style: normal; font-weight: normal; font-family: &quot;trebuchet ms&quot;,arial,helvetica,sans-serif; float: none; position: static; left: auto; top: auto; line-height: normal; background-image: url(http://i.ixnp.com/images/v3.44/theme/silver/palette.gif); background-color: transparent; visibility: visible; width: 14px; height: 12px; background-position: -1128px 0pt; background-repeat: no-repeat; text-decoration: none; vertical-align: top; display: inline;" src="http://i.ixnp.com/images/v3.44/t.gif"  alt="" /></a></h2>
<h1><font color="#004299" size="3"><a href="http://java.sun.com/j2se/1.3/docs/tooldocs/linux/java.html">java - the Java application launcher<img id="snap_com_shot_link_icon" class="snap_preview_icon" style="border: 0pt none ; margin: 0pt ! important; padding: 1px 0pt 0pt; max-height: 2000px; max-width: 2000px; min-width: 0px; min-height: 0px; font-style: normal; font-weight: normal; font-family: &quot;trebuchet ms&quot;,arial,helvetica,sans-serif; float: none; position: static; left: auto; top: auto; line-height: normal; background-image: url(http://i.ixnp.com/images/v3.44/theme/silver/palette.gif); background-color: transparent; visibility: visible; width: 14px; height: 12px; background-position: -1128px 0pt; background-repeat: no-repeat; text-decoration: none; vertical-align: top; display: inline;" src="http://i.ixnp.com/images/v3.44/t.gif"  alt="" /></a></font><br />
</h1>
<h3><a href="http://www.wujianrong.com/archives/2006/11/jvm.html"><font color="#004299">JVM调优[转]</font></a></h3>
<img src ="http://www.blogjava.net/sealyu/aggbug/224195.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-08-25 16:22 <a href="http://www.blogjava.net/sealyu/archive/2008/08/25/224195.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Redhat AS4使用jsvc编写tomcat自启动安全脚本(转)</title><link>http://www.blogjava.net/sealyu/archive/2008/08/18/222685.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Mon, 18 Aug 2008 02:10:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/08/18/222685.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/222685.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/08/18/222685.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/222685.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/222685.html</trackback:ping><description><![CDATA[1．安装jsvc
<br />
#cd /usr/local/xiaobai/apache-tomcat-5.5.20/bin
<br />
#tar xvfz jsvc.tar.gz
<br />
#cd jsvc-src
<br />
#sh support/buildconf.sh
<br />
#chmod 755 configure
<br />
#./configure --with-java=/usr/local/xiaobai/jdk1.5.0_09      (改成你的JDK的位置)
<br />
#make
<br />
<br />
2、添加脚本让tomcat自动启动
<br />
#useradd tomcat5     添加用户
<br />
#groupadd tomcat　　添加组
<br />
#usermod -G tomcat tomcat5　　把tomcat5加入tomcat组
<br />
<br />
#chown -R tomcat5 /usr/local/xiaobai/apache-tomcat-5.5.20
<br />
设置用户tomcat5对tomcat的权限
<br />
<br />
#cp /usr/local/xiaobai/apache-tomcat-5.5.20/bin/jsvc-src/native/Tomcat5.sh /etc/init.d/tomcat
<br />
移动文件tomcat5.sh到/etc/init.d/里面并改名为tomcat
<br />
<br />
#chmod 755 /etc/init.d/tomcat
<br />
#vi /etc/init.d/tomcat
<br />
<br />
删除原有内容添加如下内容
<br />
<br />
#!/bin/sh
<br />
#
<br />
# Startup Script for Tomcat5
<br />
#
<br />
# chkconfig: 345 88 14
<br />
# description: Tomcat Daemon
<br />
# processname: jsvc
<br />
# pidfile: /var/run/jsvc.pid
<br />
# config:
<br />
#
<br />
# Source function library.
<br />
. /etc/rc.d/init.d/functions
<br />
#
<br />
prog=tomcat
<br />
#
<br />
JAVA_HOME=/usr/local/xiaobai/jdk1.5.0_09
<br />
CATALINA_HOME=/usr/local/xiaobai/apache-tomcat-5.5.20
<br />
DAEMON_HOME=/usr/local/xiaobai/apache-tomcat-5.5.20/bin
<br />
#TOMCAT_USER=tomcat5
<br />
TOMCAT_USER=tomcat5
<br />
<br />
# for multi instances adapt those lines.
<br />
TMP_DIR=/var/tmp
<br />
PID_FILE=/var/run/jsvc.pid
<br />
CATALINA_BASE=/usr/local/xiaobai/apache-tomcat-5.5.20
<br />
<br />
CATALINA_OPTS=
<br />
CLASSPATH="
<br />
$JAVA_HOME/lib/tools.jar:"
<br />
$CATALINA_HOME/bin/commons-daemon.jar:"
<br />
$CATALINA_HOME/bin/bootstrap.jar
<br />
<br />
case "$1" in
<br />
start)
<br />
#
<br />
# Start Tomcat
<br />
#
<br />
$DAEMON_HOME/jsvc-src/jsvc "
<br />
-user $TOMCAT_USER "
<br />
-home $JAVA_HOME "
<br />
-Dcatalina.home=$CATALINA_HOME "
<br />
-Dcatalina.base=$CATALINA_BASE "
<br />
-Djava.io.tmpdir=$TMP_DIR "
<br />
-wait 10 "
<br />
-pidfile $PID_FILE "
<br />
-outfile $CATALINA_HOME/logs/catalina.out "
<br />
-errfile '&amp;1' "
<br />
$CATALINA_OPTS "
<br />
-cp $CLASSPATH "
<br />
org.apache.catalina.startup.Bootstrap
<br />
#
<br />
# To get a verbose JVM
<br />
#-verbose "
<br />
# To get a debug of jsvc.
<br />
#-debug "
<br />
exit $?
<br />
;;
<br />
<br />
stop)
<br />
#
<br />
# Stop Tomcat
<br />
#
<br />
$DAEMON_HOME/jsvc-src/jsvc "
<br />
-stop "
<br />
-pidfile $PID_FILE "
<br />
org.apache.catalina.startup.Bootstrap
<br />
exit $?
<br />
;;
<br />
<br />
*)
<br />
echo "Usage tomcat.sh start/stop"
<br />
exit 1;;
<br />
esac
<br />
<br />
#service tomcat start   测试tomcat能不能启动
<br />
#chkconfig tomcat on
<br />
#chkconfig --list tomcat
<br />
完成自启动脚本
<br />
<br />
<span style="color: red;">注意：
<br />
在tomcat文件的头两行的注释语句中，需要包含chkconfig和description两部分内容(确认不要拼写错误，)，否则在执行&#8220;chkconfig --add tomcat&#8221;时，会出现&#8220;tomcat服务不支持chkconfig&#8221;的错误提示。
<br />
chkconfig这行表示缺省启动的运行级别以及启动和停止的优先级，如该服务缺省不再任何运行级启动，则以 - 代替运行级别。在tomcat中表示脚本在运行级2、3、4、5启动，启动优先权为10，停止优先权为90。
<br />
description行对服务进行描述，可以用 &#8220;"&#8221; 跨行注释。</span>
<img src ="http://www.blogjava.net/sealyu/aggbug/222685.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-08-18 10:10 <a href="http://www.blogjava.net/sealyu/archive/2008/08/18/222685.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Apache设置虚拟站点总结</title><link>http://www.blogjava.net/sealyu/archive/2008/08/14/221988.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 14 Aug 2008 06:10:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/08/14/221988.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/221988.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/08/14/221988.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/221988.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/221988.html</trackback:ping><description><![CDATA[<div id="blog_text" class="cnt">
<p>在整合Apache和Tomcat之后，发现该服务器的两个网站一个是静态的，一个是动态jsp的，设置总结如下</p>
<p>主要设置httpd.conf</p>
<p>1、DirectoryIndex的设置</p>
<p>如果多个虚拟站点中包含多种文件格式和文件名的首页文件，必须在这里全部出现</p>
<p>2、多个站点的定义如下</p>
<p>#NameVirtualHost *:80</p>
<p>#<br />
# VirtualHost example:<br />
# Almost any Apache directive may go into a VirtualHost container.<br />
# The first VirtualHost section is used for requests without a known<br />
# server name.<br />
#<br />
NameVirtualHost 220.231.32.*:80</p>
<p>&lt;VirtualHost 220.231.32.*:80&gt;<br />
&nbsp;&nbsp;&nbsp; ServerAdmin <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#108;&#105;&#117;&#98;&#105;&#110;&#64;&#115;&#105;&#110;&#97;&#46;&#99;&#111;&#109;">liubin@sina.com</a><br />
&nbsp;&nbsp;&nbsp; DocumentRoot /usr/local/tomcat/webapps/ronglian<br />
&nbsp;&nbsp;&nbsp; ServerName <a href="http://www.ronglian.com/">www.ronglian.com</a><br />
&nbsp;&nbsp;&nbsp; ErrorLog logs/ronglian.com-error_log<br />
&nbsp;&nbsp;&nbsp; CustomLog logs/ronglian.com-access_log common<br />
&lt;/VirtualHost&gt;</p>
<p>&lt;VirtualHost 220.231.32.*:80&gt;<br />
&nbsp;&nbsp;&nbsp; ServerAdmin <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#119;&#101;&#108;&#108;&#98;&#111;&#98;&#121;&#64;&#116;&#111;&#109;&#46;&#99;&#111;&#109;">wellboby@tom.com</a><br />
&nbsp;&nbsp;&nbsp; DocumentRoot /usr/local/wwwroot/chinaface<br />
&nbsp;&nbsp;&nbsp; ServerName <a href="http://www.chinaface.net/">www.chinaface.net</a><br />
&nbsp;&nbsp;&nbsp; ErrorLog logs/chinaface.net-error_log<br />
&nbsp;&nbsp;&nbsp; CustomLog logs/chinaface.net-access_log common<br />
&lt;/VirtualHost&gt;</p>
<p>！！
在这里，NameVirtualHost的字段不能省略，否则起apache时报错：VirtualHost 220.231.32.*.80
overlaps with VirtualHost 220.231.32.*:80, the first has precedence,
perhaps you need a NameVirtualHost
directive——虽然apache能起，同错误描述一样，第二个站点的定义被第一个站点的定义所覆盖，即访问第二个站点指向的其实是第一个</p>
<p>！！
NameVirtualHost字段的端口号不能忽略，否则起apache时报错：VirtualHost 220.231.32.*:80 --
mixing * ports and non-* ports with a NameVirtualHost address is not
supported, proceeding with undefined results<br />
[Sun Jul 09 16:59:37
2006] [error] VirtualHost 220.231.32.*:80 -- mixing * ports and non-*
ports with a NameVirtualHost address is not supported, proceeding with
undefined results——apache不能起</p>
<p>！！如果VirtualHost
字段的端口号确实，起apache时报错：VirtualHost 220.231.32.28:0 -- mixing * ports and
non-* ports with a NameVirtualHost address is not supported, proceeding
with undefined results——但apache可以启动，访问也正常</p>
</div>
<img src ="http://www.blogjava.net/sealyu/aggbug/221988.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-08-14 14:10 <a href="http://www.blogjava.net/sealyu/archive/2008/08/14/221988.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>TomCat多虚拟站点配置（转）</title><link>http://www.blogjava.net/sealyu/archive/2008/08/14/221921.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 14 Aug 2008 03:25:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/08/14/221921.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/221921.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/08/14/221921.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/221921.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/221921.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 在网络上找了许久，没有一个真正可以解决TomCat多虚拟站点的配置问题的，经过试验和参考官方网站资料，终于解决了这个问题．参考资料：Apache&nbsp;Tomcat文档http://tomcat.apache.org/tomcat-5.0-doc/config/host.html在文中有这么一段话：One&nbsp;or&nbsp;more&nbsp;Host&nbsp;ele...&nbsp;&nbsp;<a href='http://www.blogjava.net/sealyu/archive/2008/08/14/221921.html'>阅读全文</a><img src ="http://www.blogjava.net/sealyu/aggbug/221921.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-08-14 11:25 <a href="http://www.blogjava.net/sealyu/archive/2008/08/14/221921.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>apache2.2与tomcat集成(可以多个tomcat)</title><link>http://www.blogjava.net/sealyu/archive/2008/08/11/221381.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Mon, 11 Aug 2008 14:05:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/08/11/221381.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/221381.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/08/11/221381.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/221381.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/221381.html</trackback:ping><description><![CDATA[1. 安装apache2.2 参见：<a href="http://ttitfly.javaeye.com/admin/show/127337" target="_blank">http://ttitfly.javaeye.com/admin/show/127337</a>
<br />
<br />
2.需求概况：
<br />
有2个服务：www.test.com, bbs.test.com。分别对应2个tomcat下的2个web应用。由apache httpd作为互联网接入服务器，在80端口接收对这2个服务的请求。apache httpd再将这2个请求分别对应到不同的后端web服务器(Tomcat)处理。
<br />
<br />
3.配置域名映射到本机即127.0.0.1，同时配置service域名
<br />
<br />
<div>
<div>
<div>Java代码 <a href="http://ttitfly.javaeye.com/blog/147643#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="复制代码"><img src="http://ttitfly.javaeye.com/images/icon_copy.gif" alt="复制代码" /></a></div>
</div>
<ol start="1">
    <li>127.0.0.1&nbsp;&nbsp;&nbsp;&nbsp;localhost&nbsp;www.test.com&nbsp;www.service.test.com&nbsp;bbs.test.com&nbsp;bbs.service.test.com&nbsp;&nbsp;</li>
</ol>
</div>
<br />
<br />
4. 分别在2个tomcat里分别部署一个非常简单的应用。
<br />
<br />
第一个tomcat ：端口:8080
<br />
<br />
编辑$TOMCAT_HOME/conf/server.xml
<br />
<br />
添加一个Host
<br />
<div>
<div>
<div>Java代码 <a href="http://ttitfly.javaeye.com/blog/147643#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="复制代码"><img src="http://ttitfly.javaeye.com/images/icon_copy.gif" alt="复制代码" /></a></div>
</div>
<ol start="1">
    <li>&lt;Host&nbsp;name="www.service.test.com"&nbsp;unpackWARs="true"&nbsp;autoDeploy="true"&nbsp;&nbsp;</li>
    <li>xmlValidation="false"&nbsp;xmlNamespaceAware="false"/&gt;&nbsp;&nbsp;</li>
</ol>
</div>
<pre style="display: none;" name="code" class="java">&lt;Host name="www.service.test.com" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"/&gt;</pre>
<br />
<br />
再在$TOMCAT_HOME/conf/Catalina下建立一个目录:www.service.test.com
<br />
然后在www.service.test.com目录下建立一个ROOT.xml,内容为：
<br />
<div>
<div>
<div>Java代码 <a href="http://ttitfly.javaeye.com/blog/147643#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="复制代码"><img src="http://ttitfly.javaeye.com/images/icon_copy.gif" alt="复制代码" /></a></div>
</div>
<ol start="1">
    <li>&lt;Context&nbsp;docBase="/home/mahaibo/app/test"&nbsp;&nbsp;</li>
    <li>privileged="true"&nbsp;antiResourceLocking="false"&nbsp;antiJARLocking="false"&gt;&nbsp;&nbsp;</li>
    <li>&lt;/Context&gt;&nbsp;&nbsp;</li>
</ol>
</div>
<pre style="display: none;" name="code" class="java">&lt;Context docBase="/home/mahaibo/app/test"
privileged="true" antiResourceLocking="false" antiJARLocking="false"&gt;
&lt;/Context&gt;</pre>
<br />
<span style="color: red;">docBase指向具体的项目路径</span>
<br />
<br />
同理第二个tomcat（端口8088）也是一样的做法：
<br />
<br />
编辑$TOMCAT_HOME/conf/server.xml
<br />
<br />
添加一个Host:
<br />
<div>
<div>
<div>Java代码 <a href="http://ttitfly.javaeye.com/blog/147643#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="复制代码"><img src="http://ttitfly.javaeye.com/images/icon_copy.gif" alt="复制代码" /></a></div>
</div>
<ol start="1">
    <li>&lt;Host&nbsp;name="bbs.service.test.com"&nbsp;unpackWARs="true"&nbsp;autoDeploy="true"&nbsp;&nbsp;</li>
    <li>xmlValidation="false"&nbsp;xmlNamespaceAware="false"/&gt;&nbsp;&nbsp;</li>
</ol>
</div>
<pre style="display: none;" name="code" class="java">&lt;Host name="bbs.service.test.com" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"/&gt;</pre>
<br />
<br />
<br />
然后在$TOMCAT_HOME/conf/Catalina下建立一个目录:bbs.service.test.com
<br />
<br />
再在bbs.service.test.com目录下建立一个ROOT.xml,内容为：
<br />
<div>
<div>
<div>Java代码 <a href="http://ttitfly.javaeye.com/blog/147643#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="复制代码"><img src="http://ttitfly.javaeye.com/images/icon_copy.gif" alt="复制代码" /></a></div>
</div>
<ol start="1">
    <li>&lt;Context&nbsp;docBase="/home/mahaibo/app/bbs"&nbsp;&nbsp;</li>
    <li>privileged="true"&nbsp;antiResourceLocking="false"&nbsp;antiJARLocking="false"&gt;&nbsp;&nbsp;</li>
    <li>&lt;/Context&gt;&nbsp;&nbsp;</li>
</ol>
</div>
<pre style="display: none;" name="code" class="java">&lt;Context docBase="/home/mahaibo/app/bbs"
privileged="true" antiResourceLocking="false" antiJARLocking="false"&gt;
&lt;/Context&gt;</pre>
<br />
<br />
5. 分别启动tomcat，可以通过http://www.service.test.com:8080和http://bbs.service.test.com:8088访问
<br />
<br />
6. 配置apache httpd.conf文件。
<br />
<br />
找到apach/conf/httpd.conf文件，确认下面这些文字行前面没有"#"注释号：
<br />
<br />
<div>
<div>
<div>Java代码 <a href="http://ttitfly.javaeye.com/blog/147643#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="复制代码"><img src="http://ttitfly.javaeye.com/images/icon_copy.gif" alt="复制代码" /></a></div>
</div>
<ol start="1">
    <li>LoadModule&nbsp;proxy_module&nbsp;modules/mod_proxy.so&nbsp;&nbsp;</li>
    <li>LoadModule&nbsp;proxy_ajp_module&nbsp;modules/mod_proxy_ajp.so&nbsp;&nbsp;</li>
    <li>LoadModule&nbsp;proxy_balancer_module&nbsp;modules/mod_proxy_balancer.so&nbsp;&nbsp;</li>
    <li>LoadModule&nbsp;proxy_connect_module&nbsp;modules/mod_proxy_connect.so&nbsp;&nbsp;</li>
    <li>LoadModule&nbsp;proxy_http_module&nbsp;modules/mod_proxy_http.so&nbsp;&nbsp;</li>
    <li>LoadModule&nbsp;proxy_ftp_module&nbsp;modules/mod_proxy_ftp.so&nbsp;&nbsp;</li>
</ol>
</div>
<pre style="display: none;" name="code" class="java">LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so</pre>
<br />
<br />
并增加虚拟主机配置：
<br />
<div>
<div>
<div>Java代码 <a href="http://ttitfly.javaeye.com/blog/147643#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="复制代码"><img src="http://ttitfly.javaeye.com/images/icon_copy.gif" alt="复制代码" /></a></div>
</div>
<ol start="1">
    <li>NameVirtualHost&nbsp;*:80&nbsp;&nbsp;</li>
    <li>&lt;VirtualHost&nbsp;*:80&gt;&nbsp;&nbsp;</li>
    <li>ServerName&nbsp;www.test.com&nbsp;&nbsp;</li>
    <li>ProxyIOBufferSize&nbsp;8192&nbsp;&nbsp;</li>
    <li>ProxyRequests&nbsp;Off&nbsp;&nbsp;</li>
    <li>ProxyVia&nbsp;Full&nbsp;&nbsp;</li>
    <li>ProxyPass&nbsp;/&nbsp;http://www.service.test.com:8080/&nbsp;smax=5&nbsp;max=20&nbsp;ttl=120&nbsp;retry=300&nbsp;&nbsp;</li>
    <li>&lt;/VirtualHost&gt;&nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp;</li>
    <li>&lt;VirtualHost&nbsp;*:80&gt;&nbsp;&nbsp;</li>
    <li>ServerName&nbsp;bbs.test.com&nbsp;&nbsp;</li>
    <li>ProxyIOBufferSize&nbsp;8192&nbsp;&nbsp;</li>
    <li>ProxyRequests&nbsp;Off&nbsp;&nbsp;</li>
    <li>ProxyVia&nbsp;Full&nbsp;&nbsp;</li>
    <li>ProxyPass&nbsp;/&nbsp;http://bbs.service.test.com:8088/&nbsp;smax=5&nbsp;max=20&nbsp;ttl=120&nbsp;retry=300&nbsp;&nbsp;</li>
    <li>&lt;/VirtualHost&gt;&nbsp;&nbsp;</li>
</ol>
</div>
<pre style="display: none;" name="code" class="java">NameVirtualHost *:80
&lt;VirtualHost *:80&gt;
ServerName www.test.com
ProxyIOBufferSize 8192
ProxyRequests Off
ProxyVia Full
ProxyPass / http://www.service.test.com:8080/ smax=5 max=20 ttl=120 retry=300
&lt;/VirtualHost&gt;
&lt;VirtualHost *:80&gt;
ServerName bbs.test.com
ProxyIOBufferSize 8192
ProxyRequests Off
ProxyVia Full
ProxyPass / http://bbs.service.test.com:8088/ smax=5 max=20 ttl=120 retry=300
&lt;/VirtualHost&gt;
</pre>
<br />
<br />
7.启动apache
<br />
<div>
<div>
<div>Java代码 <a href="http://ttitfly.javaeye.com/blog/147643#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" title="复制代码"><img src="http://ttitfly.javaeye.com/images/icon_copy.gif" alt="复制代码" /></a></div>
</div>
<ol start="1">
    <li>./apachectl&nbsp;start&nbsp;&nbsp;</li>
</ol>
</div>
<br />
<br />
8 可以通过访问http://www.test.com和http://bbs.test.com来分别访问2个不同tomcat下的不同应用了。
<img src ="http://www.blogjava.net/sealyu/aggbug/221381.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-08-11 22:05 <a href="http://www.blogjava.net/sealyu/archive/2008/08/11/221381.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Apache配置 虚拟转向实例（转）</title><link>http://www.blogjava.net/sealyu/archive/2008/08/11/221312.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Mon, 11 Aug 2008 07:32:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/08/11/221312.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/221312.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/08/11/221312.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/221312.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/221312.html</trackback:ping><description><![CDATA[NameVirtualHost&nbsp;*:80&nbsp;这个一定要 <br />
然后把主的ServerAdmin丢最下面 <br />
///////////////////// <br />
NameVirtualHost&nbsp;*:80 <br />
&lt;VirtualHost&nbsp;*:80&gt; <br />
ServerName&nbsp;abccccc.com <br />
ProxyPass&nbsp;/&nbsp;http://localhost:8088/ <br />
ProxyPassReverse&nbsp;/&nbsp;http://localhost:8088/ <br />
&lt;/VirtualHost&gt; <br />
<br />
#设置虚拟主机 <br />
&lt;VirtualHost&nbsp;*:80&gt; <br />
ServerAdmin&nbsp;www.adddd.com <br />
DocumentRoot&nbsp;E:/Tomcat/webapps/ROOT&nbsp; <br />
#您的站点项目所在路径，应与tomcat中的目录设置相同 <br />
ServerName&nbsp;www.adddd.com <br />
Alias&nbsp;/p&nbsp;"F:""uploadFiles" <br />
&lt;Directory&nbsp;"F:""uploadFiles"&gt; <br />
&nbsp;&nbsp;&nbsp;&nbsp;Options&nbsp;-Indexes&nbsp;MultiViews <br />
&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride&nbsp;None <br />
&nbsp;&nbsp;&nbsp;&nbsp;Order&nbsp;allow,deny <br />
&nbsp;&nbsp;&nbsp;&nbsp;Allow&nbsp;from&nbsp;all <br />
&lt;/Directory&gt; <br />
<br />
Alias&nbsp;/aaaaaa&nbsp;"F:""aaaaaa" <br />
&lt;Directory&nbsp;"F:""aaaaaa"abcc"&gt; <br />
&nbsp;&nbsp;&nbsp;&nbsp;Options&nbsp;-Indexes&nbsp;MultiViews <br />
&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride&nbsp;None <br />
&nbsp;&nbsp;&nbsp;&nbsp;Order&nbsp;allow,deny <br />
&nbsp;&nbsp;&nbsp;&nbsp;Allow&nbsp;from&nbsp;all <br />
&lt;/Directory&gt; <br />
DirectoryIndex&nbsp;index.html&nbsp;index.htm&nbsp;index.jsp <br />
ErrorLog&nbsp;logs/shsc-error_log.txt <br />
CustomLog&nbsp;logs/shsc-<a href="http://www.jb51.net/list/list_105_1.htm" target="_blank"><font color="red">access</font></a>_log.txt&nbsp;common <br />
JkMount&nbsp;/servlet/*&nbsp;ajp13&nbsp; <br />
#让Apache支持对servlet传送，用以Tomcat解析 <br />
JkMount&nbsp;/*.jsp&nbsp;ajp13&nbsp; <br />
#让Apache支持对jsp传送，用以Tomcat解析 <br />
JkMount&nbsp;/*.do&nbsp;ajp13&nbsp; <br />
#让Apache支持对.do传送，用以Tomcat解析 <br />
&lt;/VirtualHost&gt; <br />
/////////////////////
<img src ="http://www.blogjava.net/sealyu/aggbug/221312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-08-11 15:32 <a href="http://www.blogjava.net/sealyu/archive/2008/08/11/221312.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Apache 2.2.9 和 Tomcat 5.5.26 的自动集成</title><link>http://www.blogjava.net/sealyu/archive/2008/07/17/215597.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 17 Jul 2008 14:27:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/07/17/215597.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/215597.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/07/17/215597.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/215597.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/215597.html</trackback:ping><description><![CDATA[<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">集成 Apache 和 Tomcat 后，Tomcat 的应用可以通过 Apache 来访问。这个功能使用了一个 mod_jk.so 的模块，有关这个方面的配置曾经困扰了我很久，我相信也给不少人带来了麻烦。这次我要说的是一种更加简便的配置方式：自动化配置。</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">自动化配置的前提是只有一个 Tomcat 实例和 Apache 在同一台机器上运行。自动化配置是通过在 Tomcat 的配置文件 server.xml 中的 Engine 元素中添加相应的 ApacheConfig 监听器(Listener)来实现的。</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">下面是具体的配置：</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">第一步：下载并安装 Apache httpd和 Tomcat</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">下载并安装 Apache 2.2.9 和 Tomcat 5.5.26，假设他们的安装目录如下：</span></p>
<p style="margin-left: 10.5pt; text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">D:/apps/Apache/Apache2.2 </span></p>
<p style="margin-left: 10.5pt; text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">D:/apps/Apache/apache-tomcat-5.5.26</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">这两个服务器可以在以下地址下载：</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">Tomcat: </span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">http://apache.osuosl.org/tomcat/tomcat-5/v5.5.26/bin/apache-tomcat-5.5.26.zip</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">Apache:</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;"><a href="http://apache.osuosl.org/httpd/binaries/win32/apache_2.2.9-win32-x86-openssl-0.9.8h-r2.msi">http://apache.osuosl.org/httpd/binaries/win32/apache_2.2.9-win32-x86-openssl-0.9.8h-r2.msi</a></span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">第二步：下载并安装 mod_jk.so </span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">mod_jk </span><span style="font-size: 12pt; font-family: 宋体;">的下载地址如下：</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">http://apache.osuosl.org/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.26/mod_jk-1.2.26-httpd-2.2.4.so</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">下载后将其重命名并复制到到 D:/apps/Apache/Apache2.2/modules 下</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">第三步：创建 workers.properties 文件</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">workers.properties </span><span style="font-size: 12pt; font-family: 宋体;">定义了每个 worker 的类型、协议、端口等信息。如果手上没有现成的配置文件，可以使用以下最简单的配置：</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;"># Define 1 real worker using ajp13</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">worker.list=worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;"># Set properties for worker1 (ajp13)</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">worker.worker1.type=ajp13</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">worker.worker1.host=localhost</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">worker.worker1.port=8009</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">将这个文件放在 Tomcat 下的 conf/jk 目录中，如果放在其他地方，则需要在 server.xml 的配置中明确指定。</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">第四步：修改 Tomcat server.xml 文件</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">找到下面这行内容并在后面添加配置信息：</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">&nbsp;&nbsp;&nbsp;<span style="font-family: Courier New; color: #800000;">&lt;Engine name="Catalina" defaultHost="localhost"&gt;</span></span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">配置信息如下：</span></p>
<p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; &lt;Listener className="org.apache.jk.config.ApacheConfig" </span></p>
<p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; workersConfig="conf/workers.properties"</span></p>
<p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modJk="D:/apps/Apache/Apache2.2/modules/mod_jk.so"</span></p>
<p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jkLog="logs/mod_jk.log"</span></p>
<p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jkDebug="info"</span></p>
<p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jkWorker="worker1" </span></p>
<p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; noRoot="true"</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;"><span style="font-family: Courier New; color: #800000;">&nbsp;&nbsp;&nbsp; /&gt;</span></span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">其中：</span></p>
<ul>
    <li><span style="font-size: 12pt; font-family: 宋体;">workersConfig </span><span style="font-size: 12pt; font-family: 宋体;">是 workers.properties 的位置，这里我没有使用默认的位置，所以在此明确说明了。</span></li>
</ul>
<ul>
    <li><span style="font-size: 12pt; font-family: 宋体;">modJk</span><span style="font-size: 12pt; font-family: 宋体;">：定义了 mod_jk.so 的具体位置</span></li>
</ul>
<ul>
    <li><span style="font-size: 12pt; font-family: Wingdings;"><span style="font-size: 12pt; font-family: 宋体;">jkLog </span><span style="font-size: 12pt; font-family: 宋体;">定义了 mod_jk.log 的位置，这里是 tomcat 下的 logs 目录</span></span></li>
</ul>
<ul>
    <li><span style="font-size: 12pt; font-family: Wingdings;"><span style="font-size: 12pt; font-family: 宋体;">jkDebug</span><span style="font-size: 12pt; font-family: 宋体;">：定义日志级别，可以使用的级别有：debug, info, error, 或者 emerg，默认为 emerg</span></span></li>
</ul>
<ul>
    <li><span style="font-size: 12pt; font-family: Wingdings;"><span style="font-size: 12pt; font-family: 宋体;">jkWorker</span><span style="font-size: 12pt; font-family: 宋体;">：定义 worker 的名称，必须是在 workers.properties 中定义过的名称，否则可能会出现 internal server error 的错误</span></span></li>
</ul>
<ul>
    <li><span style="font-size: 12pt; font-family: Wingdings;"><span style="font-size: 12pt; font-family: 宋体;">noRoot</span><span style="font-size: 12pt; font-family: 宋体;">：如果为 true，则根目录不会映射到 Tomcat 的根目录，false 则映射到 Tomcat 根目录，如果是 false 的话，<a href="http://localhost/">http://localhost/</a> 会打开 Tomcat 的欢迎页面（ROOT）</span></span></li>
</ul>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">第五步：修改 Apache httpd.conf 文件</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">找到 httpd.conf 文件并在最后加上如下配置：</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">#To be added at the end of your httpd.conf</span></p>
<p style="text-align: left; margin-left: 40px;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;"><span style="font-family: Courier New; color: #800000;">Include $TOMCAT_HOME/conf/auto/mod_jk.conf</span></span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">要注意的是，这里 Include 后面的路径必须正确，这里 $TOMCAT_HOME 是 Tomcat 安装目录，D:/apps/Apache/apache-tomcat-5.5.26。</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">第六步：重启 Tomcat 并自动生成 mod_jk.conf</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">重启 Tomcat，重启成功后会在其 conf 下面生成 mod_jk.conf 文件，这个配置文件就是在 httpd.conf 中要用到的那个，这个文件的路径必须和在 httpd.conf 中的一致。下面是生成的一个mod_jk.conf：</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">########## Auto generated on Sun Jun 29 11:21:57 CST 2008##########</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&lt;IfModule !mod_jk.c&gt;</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;LoadModule jk_module "D:/apps/Apache/Apache2.2/modules/mod_jk.so"</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&lt;/IfModule&gt;</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">JkWorkersFile "D:/apps/Apache/apache-tomcat-5.5.26/conf/workers.properties"</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">JkLogFile "D:/apps/Apache/apache-tomcat-5.5.26/logs/mod_jk.log"</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">JkLogLevel info</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&lt;VirtualHost localhost&gt;</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; ServerName localhost</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /webdav worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /webdav/* worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /servlets-examples worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /servlets-examples/* worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /tomcat-docs worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /tomcat-docs/* worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /jsp-examples worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /jsp-examples/* worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /balancer worker1</span></p>
<p style="text-align: left; margin-left: 40px; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; JkMount /balancer/* worker1</span></p>
<p style="text-align: left; margin-left: 40px;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;"><span style="font-family: Courier New; color: #800000;">&lt;/VirtualHost&gt;</span></span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">第七步：启动 Apache 并测试配置</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">Apache </span><span style="font-size: 12pt; font-family: 宋体;">启动完成后，测试如下地址：</span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;"><a href="http://localhost/jsp-examples">http://localhost/jsp-examples</a></span></p>
<p style="text-align: left;" class="MsoNormal" align="left"><span style="font-family: 宋体;">如果页面能正常显示，说明配置成功！如果出现</span> internal server error <span style="font-family: 宋体;">之类的错误，说明上面的配置有误，需要检查并测试。</span></p>
<img src ="http://www.blogjava.net/sealyu/aggbug/215597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-07-17 22:27 <a href="http://www.blogjava.net/sealyu/archive/2008/07/17/215597.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Working with mod_jk</title><link>http://www.blogjava.net/sealyu/archive/2008/07/17/215595.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 17 Jul 2008 14:01:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/07/17/215595.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/215595.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/07/17/215595.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/215595.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/215595.html</trackback:ping><description><![CDATA[<p>By Gal Shachor <tt>&lt;<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#115;&#104;&#97;&#99;&#104;&#111;&#114;&#64;&#105;&#108;&#46;&#105;&#98;&#109;&#46;&#99;&#111;&#109;">shachor@il.ibm.com</a>&gt;</tt></p>
<h2>Table of Contents</h2>
<ul>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s2">What is mod_jk?</a></li>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s3">Why mod_jk?</a></li>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s4">What does it mean to me?</a></li>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s5">Definitions and Terminology</a></li>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s6">Obtaining mod_jk</a>
    <ul>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s61">mod_jk Binaries</a></li>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s62">Building mod_jk</a></li>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s63">Building mod_jk for NT</a></li>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s64">Building mod_jk for Unix</a></li>
    </ul>
    </li>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s7">Configuring Apache</a>
    <ul>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s71">Removing mod_jserv directives</a></li>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s72">Configuring Apache to use mod_jk</a></li>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s73">Assigning URLs to be redirected to Tomcat</a></li>
    </ul>
    </li>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s8">Configuring Tomcat</a>
    <ul>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s81">Enabling Tomcat's Apache Auto-Config</a></li>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s82">Configuring Tomcat to use the AJPv13 Protocol</a></li>
        <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s83">Defining Workers</a></li>
    </ul>
    </li>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s9">Example Configuration</a></li>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s10">Troubleshooting and F.A.Q's</a></li>
    <li><a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s11">Credits</a></li>
</ul>
<hr />
<h2><a name="s2">What is mod_jk?</a></h2>
<p>mod_jk is a replacement to the elderly mod_jserv. It is a completely new
Tomcat-Apache plug-in that handles the communication between Tomcat and Apache.</p>
<hr />
<h2><a name="s3">Why mod_jk?</a></h2>
<p>Several reasons: </p>
<ul>
    <li><strong>mod_jserv was too complex</strong>. Because it was ported from Apache/JServ, it
    brought with it lots of JServ specific bits that aren't needed by Apache.
    </li>
    <li><strong>mod_jserv supported only Apache</strong>. Tomcat supports many web servers
    through a compatibility layer named the jk library. Supporting two different
    modes of work became problematic in terms of support, documentation and bug
    fixes. mod_jk should fix that.</li>
    <li>The layered approach provided
    by the jk library makes it easier to support both <strong>Apache1.3.x <em>and</em>
    Apache2.xx.</strong></li>
    <li><strong>Better support for SSL</strong>. mod_jserv couldn't reliably identify whether a
    request was made via HTTP or HTTPS. mod_jk can, using the newer Ajpv13 protocol.</li>
</ul>
<hr />
<h2><a name="s4">What does it mean to me?</a></h2>
<p>You will need to get to know a new simplified configuration mechanism. The
advantage is that learning this mechanism will give you a head start if you
want to deploy Tomcat on Apache and other web servers, such as Microsoft's
Internet Information Server (IIS) and the iPlanet Enterprise Web Server.</p>
<hr />
<h2><a name="s5">Definitions and Terminology</a></h2>
<p>In this document I am going to use a few terms, so let's define them:</p>
<table>
    <tbody>
        <tr>
            <th>
            <p>Term</p>
            </th>
            <th>
            <p>Meaning</p>
            </th>
        </tr>
        <tr>
            <td>
            <p>Worker Process</p>
            </td>
            <td>
            <p>A worker is a tomcat instance that is running to serve
            servlet requests coming from the web server. In most cases there is only a
            single worker (the one and only tomcat process) but sometimes you will run
            multiple workers to achieve load balancing or site partitioning. Each worker
            is identified to the web server by the host were it is located, the port
            where it listens and the communication protocol used to exchange messages.</p>
            </td>
        </tr>
        <tr>
            <td>
            <p>In-Process Worker</p>
            </td>
            <td>
            <p>This is a special worker. Instead of working with a Tomcat
            process residing on another process, the web server opens a JVM and executes
            Tomcat inside the web server process address space. Our discussion in this
            document is not going to get into this special worker.</p>
            </td>
        </tr>
        <tr>
            <td>
            <p>Web Server Plug-in/Tomcat Redirector</p>
            </td>
            <td>
            <p>For Tomcat to cooperate with any web server it needs an
            "agent" to reside in the web server and send him servlet requests.
            This is the web server plug-in, and in our case the web server plug-in is
            mod_jk. The redirector usually comes in the shape of a DLL or shared object
            module that you plug into the web server.</p>
            </td>
        </tr>
        <tr>
            <td>
            <p>Plug-in Configuration</p>
            </td>
            <td>
            <p>We need to configure the web server plug-in so that it
            knows where the different Tomcat workers are and to which of them it should
            forward requests. This information, accompanied with some internal parameter,
            such as the log level, comprises the plug-in configuration. </p>
            </td>
        </tr>
        <tr>
            <td>
            <p>Web Server Configuration</p>
            </td>
            <td>
            <p>Each
            web server has some configuration that defines its behavior, e.g. on
            which port to listen, what files to serve, what web server plug-ins to
            load, etc. You will need to modify your web server configuration to
            instruct it to load the Tomcat redirector mod_jk.</p>
            </td>
        </tr>
    </tbody>
</table>
<hr />
<h2><a name="s6">Obtaining mod_jk</a></h2>
<p>mod_jk can be obtained in two formats - binary and source.&nbsp; Depending on
the platform you are running your web server on, a binary version of mod_jk may
be available.&nbsp; It is recommended to use the binary version if one is
available.&nbsp; If the binary is not available, follow the instructions for
building mod_jk from source.&nbsp; Notes at the end of this section offer
recommendations for specific platforms. </p>
<h3><a name="s61">mod_jk Binaries</a></h3>
<p>Binaries for mod_jk are available for several platforms in the same area as
the Tomcat Binary Release.&nbsp; The binaries are located in subdirectories by platform.&nbsp; For some
platforms, such as Windows, this is the typical way of obtaining mod_jk since
most Windows systems do not have C compilers.&nbsp; For others, the binary
distribution of mod_jk offers simpler installation. </p>
<p>For example, the Tomcat 3.3 M1 Release at <a href="http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.3-m1/bin/">http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.3-m1/bin/</a>
contains the following: </p>
<table border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" width="600">
    <tbody>
        <tr>
            <td width="15%">linux/i386/</td>
            <td width="85%">Contains mod_jk.so for Apache 1.3 for the standard API as
            well as EAPI and mod_jk.so for Apache 2.0</td>
        </tr>
        <tr>
            <td width="15%">netware/</td>
            <td width="85%">Contains the mod_jk.nlm and nsapi.nlm</td>
        </tr>
        <tr>
            <td width="15%">win32/</td>
            <td width="85%">Contains the mod_jk.dll for Windows as well as other useful
            binaries.</td>
        </tr>
    </tbody>
</table>
<p>Check the site for the latest binaries.</p>
<p>Note: The version of mod_jk is not dependent on the version of Tomcat.&nbsp;
The Tomcat 3.3 distribution of mod_jk will function correctly with other 3.x
versions of Tomcat, such as Tomcat 3.2.1.</p>
<h3><a name="s62">Building mod_jk</a></h3>
<p>mod_jk is available in source distribution for all Windows and most Unix
platforms.&nbsp; The source for mod_jk is included in the Binary Distribution of
Tomcat in the TOMCAT_HOME/native/mod_jk/ directory.&nbsp; This directory is
organized by Web Server name and version.&nbsp; Each directory contains the
source as well as the appropriate build scripts, make files, or project files. </p>
<h3><a name="s63">Building mod_jk for NT</a></h3>
<p>The redirector was developed using Visual C++ version 6.0, so having this
environment is a prerequisite if you want to perform a custom build.</p>
<p>The steps that you need to take are: </p>
<ol>
    <li>Change directory to the apache1.3 or apache2.0 source directory depending
    on your version of Apache. </li>
    <li>Set an APACHE1_HOME environment variable which points to where your Apache is
    installed.</li>
    <li>Execute the following
    command:<br />
    <br />
    <tt>MSDEV mod_jk.dsp /MAKE ALL</tt><br />
    <br />
    If msdev is not in your path, enter the full path to msdev.exe. Also, ApacheCore.lib
    is expected to exist in the APACHE1_HOME"src"CoreD and APACHE1_HOME"src"CoreR
    directories before linking will succeed. You will need to build enough of the
    Apache source to create these libraries.</li>
    <li>Copy mod_jk.dll to Apache's modules directory.</li>
</ol>
<p>This will build both release and debug versions of the redirector plug-in (mod_jk). </p>
<p>An alternative will be to open <tt>mod_jk.dsp</tt> in msdev and build it using the build
menu.</p>
<h3><a name="s64">Building mod_jk for Unix</a></h3>
<h4> Apache</h4>
<ol>
    <li>Make sure your Apache has DSO support. You can check this
    with <tt>$APACHE_HOME/bin/httpd -l</tt>. If you see
    "mod_so.c" in the output, DSO support is available. If it's
    missing, you may have to recompile or reinstall Apache.</li>
    <li>Find out whether your Apache has EAPI support. If you
    compiled it yourself from source, EAPI is probably not compiled
    in, unless you added it yourself (perhaps with mod_ssl). You
    need to build mod_jk.so with or without EAPI to match your
    Apache configuration. If you install a mismatched mod_jk.so,
    <tt>$APACHE_HOME/bin/apachectl configtest</tt> will warn
    you.</li>
    <li>Make sure you have Perl 5 installed. The <tt>apxs</tt>
    script used to build the module is written in Perl.
    </li>
    <li>Change directory to <tt>TOMCAT_HOME/native/mod_jk/apache1.3</tt> (or
    <tt>apache2.0</tt>).
    </li>
    <li>
    <p>Build mod_jk.so. Following are three techniques you can try,
    in order of simplicity:</p>
    <ol>
        <li>Run the build script for your platform.&nbsp; If a build script is
        not available for your platform, you may be able to build mod_jk using <tt>./build-unix.sh</tt>. This script will set some variables, call
        <tt>apxs</tt> as below, and try to copy mod_jk.so to
        $APACHE_HOME/libexec. If it fails, you need to do
        the following manually:
        <ul>
            <li>set JAVA_HOME in your shell, e.g. "<tt>set
            JAVA_HOME=/usr/local/jdk1.2.2; export
            JAVA_HOME</tt>"</li>
            <li>set APACHE_HOME in your shell, e.g.
            "<tt>set APACHE_HOME=/usr/local/apache;
            export APACHE_HOME</tt>"</li>
            <li>uncomment the following line in the
            <tt>build-unix.sh</tt> file,
            replacing "linux" with the name of your
            platform as specified in the
            Java include directory for your installation
            <blockquote><tt># JAVA_INCLUDE="-I
            ${JAVA_HOME}/include -I
            ${JAVA_HOME}/include/linux"</tt></blockquote>
            </li>
        </ul>
        </li>
        <li>If build-unix.sh fails, you may have better luck
        with the Makefiles in the same directory, e.g.
        "<tt>make -f Makefile.linux mod_jk.so</tt>"
        </li>
        <li>
        <p>Finally, you can try to build it manually. Run the
        <tt>apxs</tt> command that came with your apache
        distribution (hint: look in /usr/local/apache/bin,
        /usr/sbin, or wherever you installed apache). Type the
        command all on one line.</p>
        <hr />
        <p>For Linux:</p>
        <blockquote><tt>apxs -o mod_jk.so -I../jk
        -I/usr/local/jdk/include -I/usr/local/jdk/include/linux
        -c *.c ../jk/*.c</tt></blockquote>
        <p>Your build may fail because the object files from
        the <tt>../jk</tt> directory have been compiled to the
        current directory, rather than their source directory.
        Running <tt>gcc -shared -o mod_jk.so *.o</tt>
        should finish the build.</p>
        <hr />
        <p>For Solaris:</p>
        <p>Use the <tt>build-solaris.sh</tt> script as follows:</p>
        <blockquote><tt># sh build-solaris.sh</tt></blockquote>
        <p>This will build and install mod_jk.so in your apache/libexec
        directory.&nbsp; This script contains settings for your Java and Apache
        home locations.&nbsp; Make sure that these are set according to your
        installation.&nbsp; The default settings are <tt>JAVA_HOME=/usr/java</tt> and
        <tt>APACHE_HOME=/usr/local/apache</tt>.&nbsp; If your installation is different,
        you will need to edit the <tt>build-solaris.sh</tt> script and change these
        values appropriately.</p>
        <p>See <tt>README.solaris</tt> located in <tt>TOMCAT_HOME/native/mod_jk/apache1.3</tt>
        for more information.</p>
        <p>If the build script does not work, you can also build mod_jk as
        follows:</p>
        <blockquote><tt>$APACHE_HOME/bin/apxs -o mod_jk.so -DSOLARIS -I../jk -I/usr/java/include
        -I/usr/java/include/solaris -c *.c ../jk/*.c</tt></blockquote>
        <p>On some systems, this will build the module
        correctly, but will fail at runtime with a
        "<tt>symbol "fdatasync" not found</tt>". To
        fix, add <tt>-lposix4</tt> just before the
        <tt>-c</tt> in the above command.</p>
        <hr />
        <p>For HP-UX 11.00:</p>
        <p>Use the <tt>build-hpux.sh</tt> script as follows:</p>
        <blockquote><tt># sh build-hpux.sh</tt></blockquote>
        <p>This will build and install mod_jk.so in your apache/libexec
        directory.&nbsp; This script contains settings for your Java and Apache
        home locations.&nbsp; Make sure that these are set according to your
        installation.&nbsp; The default settings are <tt>JAVA_HOME=/opt/java1.3</tt> and
        <tt>APACHE_HOME=/usr/local/apache</tt>.&nbsp; If your installation is different,
        you will need to edit the <tt>build-hpux.sh</tt> script and change these
        values appropriately.</p>
        <p>Also note that there are two HP-UX build scripts.&nbsp; One script
        was written to build mod_jk without JNI support using GNU GCC.&nbsp; The
        other script builds mod_jk with JNI support, however, this script
        requires the HP ANSI C Compiler (not the stripped down C compiler
        included with HP-UX to rebuild the kernel).&nbsp; The HP Compiler is
        required because the dlopen() and related shared libraries are only
        available for 64-bit applications and reliable 64-bit compilation is not
        available with the current version of GCC.</p>
        <p>The <tt>build-hpux.sh</tt> script should also work for HP-UX 10.00.</p>
        <p>See <tt>README.hpux</tt> located in <tt>TOMCAT_HOME/native/mod_jk/apache1.3</tt>
        for more information.</p>
        <hr />
        <p>For other Unixes (including FreeBSD):</p>
        <p>You may need to replace fdatasync() with fsync() in jk_util.c.</p>
        <p>The <tt>build-hpux-cc.sh</tt> script should be modifiable for IRIX and AIX.&nbsp;
        Edit the script and change the APACHE_HOME and JAVA_HOME locations as
        required.</p>
        <hr />
        <p>If you are using EAPI, try adding
        <tt>-DEAPI</tt> to the apxs command after
        <tt>mod_jk.so</tt>.</p>
        <p>If apxs fails with <code>apxs:Break: Command failed
        with rc=255</code>, it may have been damaged by
        mod_ssl. Search for:</p>
        <pre>my $CFG_LD_SHLIB      = q();          # substituted via Makefile.tmpl<br />
        my $CFG_LDFLAGS_SHLIB = q(); # substituted via Makefile.tmpl<br />
        </pre>
        <p>and change to:</p>
        <pre>my $CFG_LD_SHLIB      = q(ld);          # substituted via Makefile.tmpl<br />
        my $CFG_LDFLAGS_SHLIB = q(-G); # substituted via Makefile.tmpl<br />
        </pre>
        <p>If you've installed Java in another directory,
        adjust accordingly.</p>
        <p>For other Unixes you should be able to work it out,
        but remember that <strong>the order of the arguments to
        <tt>apxs</tt> is important!</strong>.</p>
        </li>
    </ol>
    </li>
    <li>Now, copy the mod_jk library.&nbsp; <tt># cp mod_jk.so $APACHE_HOME/libexec</tt>.  (Note that
    the build scripts attempt to do this, but you may have to
    <tt>su</tt> first.)</li>
</ol>
<h4>Other Webservers</h4>
<p>There are several Makefiles in the other directories under the <tt>TOMCAT_HOME/native/mod_jk/</tt>
directory.&nbsp; You should also check the Tomcat documentation for specific
information related to other web servers.</p>
<hr />
<h2><a name="s7">Configuring Apache</a></h2>
<p>This section details the configuration that is required for the Apache Web
Server to support mod_jk.</p>
<h3><a name="s71">Removing mod_jserv directives</a></h3>
<p>
If you've previously configured Apache to use mod_jserv, remove any <tt>ApJServMount</tt> directives from your httpd.conf. If you're including <tt>tomcat-apache.conf</tt> or <tt>tomcat.conf</tt>, you'll want to remove them as well - they are specific to
mod_jserv.&nbsp; The mod_jserv configuration directives are not compatible with
mod_jk!
</p>
<h3><a name="s72">Configure Apache to use mod_jk</a></h3>
<div>
<p>The simplest way to configure Apache to use mod_jk is to turn on the Apache
auto-configure setting in Tomcat and put the following include directive at the
end of your Apache httpd.conf file (make sure you replace TOMCAT_HOME with the
correct path for your Tomcat installation:</p>
<p><tt>Include TOMCAT_HOME/conf/jk/mod_jk.conf-auto</tt></p>
<p>Example:</p>
<p><tt>Include /usr/local/jakarta-tomcat/conf/jk/mod_jk.conf-auto</tt></p>
<p>This will tell Apache to use directives in the mod_jk.conf-auto file
in the Apache configuration.&nbsp; This file is created by enabling the Apache
auto-configuration as described in the configuring Tomcat section below [<a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s8">Configuring
Tomcat</a>].</p>
<p><strong>NOTE:&nbsp; If you plan to use the Tomcat-Apache auto-configuration, skip
the rest of this section and continue with the <a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s8">Configuring Tomcat</a>
section.</strong></p>
<p>Custom configurations can be created by enabling the auto-configuration and
copying the <tt>TOMCAT_HOME/conf/jk/mod_jk.conf-auto</tt> file to your own
configuration file, such as <tt>TOMCAT_HOME/conf/jk/mod_jk.conf-local</tt>.</p>
<p>The basic configuration is as follows:</p>
<ul>
    <li>You will need to instruct Apache to load Tomcat. This can be done with
    Apache's <tt>LoadModule</tt> and <tt>AddModule</tt> configuration directives.</li>
    <li>You must inform mod_jk the location of your <tt>workers.properties</tt> file.
    Use mod_jk's <tt>JkWorkersFile</tt> configuration directive.</li>
    <li>You should specify a location where mod_jk is going to place its log file
    and a log level to be used. Use the <tt>JkLogFile</tt> and <tt>JkLogLevel</tt>
    configuration directives. Possible log levels are <em>debug</em>, <em>info</em>,
    <em>error</em> and <em>emerg</em>, but <em>info</em> should be your default
    selection.</li>
    <li>The directive <tt>JkLogStampFormat</tt> will configure the date/time format
    found on mod_jk logfile. Using <tt>strftime()</tt> format string it's set by
    default to "[%a %b %d %H:%M:%S %Y] "</li>
</ul>
A simple example would be to include the following lines in your <tt>httpd.conf</tt> file:
<blockquote>
<pre>LoadModule    jk_module  libexec/mod_jk.so<br />
AddModule     mod_jk.c<br />
JkWorkersFile /usr/local/jakarta-tomcat/conf/workers.properties<br />
JkLogFile     /usr/local/apache/logs/mod_jk.log<br />
JkLogLevel    info<br />
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "<br />
</pre>
</blockquote>
</div>
<h3><a name="s73">Assigning URLs to Tomcat</a></h3>
<div>
<p>If you have created a custom or local version of <tt>mod_jk.conf-local</tt>
as noted above, you can change settings such as the workers or URL prefix.</p>
<p>Use mod_jk's JkMount directive to assign specific URLs to Tomcat. In general
the structure of a JkMount directive is:</p>
<pre>JkMount <em>&lt;URL prefix&gt;</em> <em>&lt;Worker name&gt;</em>
</pre>
<p>For example the following directives will send all requests ending in
<tt>.jsp</tt> or beginning with <tt>/servlet</tt> to the "<tt>ajp13</tt>" worker,
but jsp requests to files located in /otherworker will go to "<tt>remoteworker</tt>".
</p>
<blockquote>
<pre>JkMount /*.jsp ajp13<br />
JkMount /servlet/* ajp13<br />
JkMount /otherworker/*.jsp remoteworker<br />
</pre>
</blockquote>
You  can use the <tt>JkMount</tt> directive at the top level or inside <tt>&lt;VirtualHost&gt;</tt>
sections of your httpd.conf file.
</div>
<hr />
<h2><a name="s8">Configuring Tomcat</a></h2>
<h3><a name="s81">Enabling Tomcat's Apache Auto-Config</a></h3>
<div>
<p>
In most simple cases Tomcat can generate the needed Apache configuration. You
can configure Tomcat so that when it starts up it will automatically generate
a configuration file for Apache to use mod_jk.
Most of the time you don't need to do anything but
include this file (appending <tt>"Include TOMCAT_HOME/conf/jk/mod_jk.conf-auto"</tt>)
in your httpd.conf, as shown in the previous section (<a href="http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html#s7">Configuring
Apache</a>).
</p>
<p>To configure Tomcat to generate the Apache auto-configuration add the following block to your <tt>TOMCAT_HOME/conf/server.xml</tt>  file after <tt>&lt;AutoWebApp ... /&gt;</tt>.
</p>
<blockquote>
<pre>&lt;ApacheConfig /&gt;<br />
</pre>
</blockquote>
<p>
That's it, you can
now start Tomcat and Apache and access Tomcat from the Apache server.
</p>
<p>Note: Settings for mod_jk auto-configuration is new in Tomcat 3.3.&nbsp;
Older versions of Tomcat create the auto-config file without a directive in
server.xml.&nbsp; The new directive in Tomcat 3.3 allows for additional
configuration options as detailed later in this section.&nbsp; For older
versions of Tomcat, refere to the documentation that came with that version.
</p>
<p>
If you have special needs, for example mounting
URL prefixes that are not the default, you can use this file as a base for your
customized configuration and save the results in another file. If you manage
the Apache configuration yourself you'll need to update it whenever you add a
new context.
</p>
<p>Note that you must restart tomcat and apache after adding a new
context; Apache doesn't support configuration changes without a restart. Also
the file <tt>TOMCAT_HOME/conf/jk/mod_jk.conf-auto</tt> is generated when
tomcat starts, so you'll need to start Tomcat before Apache. Tomcat will
overwrite <tt>TOMCAT_HOME/conf/jk/mod_jk.conf-auto</tt> each startup so
customized configuration should be kept elsewhere.&nbsp; For example, copy&nbsp;
<tt>TOMCAT_HOME/conf/jk/mod_jk.conf-auto</tt> to <tt>TOMCAT_HOME/conf/jk/mod_jk.conf-local
</tt>before making changes.&nbsp; You'll need to startup Tomcat once to generate
this file with your configuration for the first time.
</p>
<p>It is also possible to specify the location of the auto generated files by
setting options in the &lt;ApacheConfig /&gt; block.&nbsp; The following details
the syntax:
</p>
<blockquote>
<pre>&lt; ContextManager ... &gt;<br />
...<br />
&lt;ApacheConfig <em>options</em> /&gt;<br />
...<br />
&lt; /ContextManager &gt;<br />
</pre>
</blockquote>
<p>
&nbsp;where <em>options</em> can include any of the following attributes:
</p>
<ul>
    <li><strong>confighome</strong> - default parent directory for the following paths. If
    not set, this defaults to TOMCAT_HOME. Ignored whenever any of the following
    paths is absolute.
    </li>
    <li><strong>jservconfig</strong> - path to write apache jserv conf file to. If not set,
    defaults to "conf/jserv/tomcat-apache.conf".
    </li>
    <li><strong>jkconfig</strong> - path to write apacke mod_jk conf file to. If not set,
    defaults to "conf/jk/mod_jk.conf".
    </li>
    <li><strong>workersconfig</strong> - path to workers.properties file used by mod_jk. If
    not set, defaults to "conf/jk/workers.properties".
    </li>
    <li><strong>modjserv</strong> - path to Apache JServ plugin module file. If not set,
    defaults to "modules/ApacheModuleJServ.dll" on windows,
    "modules/Jserv.nlm" on netware, and "libexec/mod_jserv.so"
    everywhere else.
    </li>
    <li><strong>modjk</strong> - path to Apache mod_jk plugin file. If not set, defaults to
    "modules/mod_jk.dll" on windows, "modules/mod_jk.nlm" on
    netware, and "libexec/mod_jk.so" everywhere else.
    </li>
    <li><strong>jklog</strong> - path to log file to be used by mod_jk.</li>
</ul>
<p>
&nbsp;Example:
</p>
<blockquote>
<pre>...<br />
<br />
&lt;AutoWebApp dir="webapps" host="DEFAULT" /&gt;<br />
<br />
&lt;ApacheConfig confighome="/home/mydir" /&gt;<br />
<br />
...</pre>
</blockquote>
</div>
<h3><a name="s82">(Optional) Configuring Tomcat to use the Ajpv13 protocol</a></h3>
<div>
mod_jk can use either the original Ajpv12 protocol or the newer Ajpv13 protocol.
Both protocols are enabled by default. The "Ajp13" Connection Handler in Tomcat will
give you the benefit of a faster protocol and the ability to identify requests made via HTTPS.<br />
<br />
The following block enables Ajpv13 in your <tt>TOMCAT_HOME/conf/server.xml</tt> file.
<blockquote>
<pre>&lt;RequestInterceptor<br />
className="org.apache.tomcat.modules.server.Ajp13Interceptor"<br />
port="8009"/&gt;<br />
</pre>
</blockquote>
<p>The <tt>server.xml</tt> file already has a block similar to this for
Ajp12 connections on port 8007 (as delivered by mod_jserv). Even if you
think you're only using Ajp13, you probably don't want to delete this
connector -- it's required to shut down Tomcat.</p>
</div>
<h3><a name="s83">(Optional) Defining "workers"</a></h3>
<h4>Configuring workers manually.</h4>
<div>
<p>
Workers are configured using the file <tt>TOMCAT_HOME/conf/jk/workers.properties</tt>.
There is a great deal of information in the
<a href="http://tomcat.apache.org/tomcat-3.2-doc/Tomcat-Workers-HowTo.html">workers.properties howto</a> document, and you
should really look at that first. If you're in a hurry however, you can probably get away
with editing the file <tt>workers.properties</tt> and setting the <tt>workers.tomcat_home</tt>, <tt>workers.java_home</tt> and <tt>ps</tt> variables to the correct values for your system.
</p>
</div>
<hr />
<h2><a name="s9">Example Configuration</a></h2>
Here's an example configuration which probably reflects many real-world setups. A site
is using Tomcat and Apache with two virtual hosts (one of them using HTTPS as well, which
we're assuming is being handled by mod_ssl).
<br />
<br />
URLs ending in .jsp and beginning with /servlet are handled by Tomcat, the rest are
handled by Apache. The files for each Host are server out of /web/host1 and /web/host2
respectively.<br />
<br />
The example are over-simplified and incomplete but should get you started. Also note the
virtual host setup is new in Tomcat 3.2 - <em>this example won't work with Tomcat 3.1</em>.<br />
<br />
<table>
    <tbody>
        <tr>
            <td>
            <blockquote>
            <pre>.<br />
            .<br />
            &lt;Connector className="org.apache.tomcat.service.PoolTcpConnector"&gt;<br />
            &lt;Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/&gt;<br />
            &lt;Parameter name="port" value="8007"/&gt;<br />
            &lt;/Connector&gt;<br />
            <br />
            &lt;Connector className="org.apache.tomcat.service.PoolTcpConnector"&gt;<br />
            &lt;Parameter name="handler"  value="org.apache.tomcat.service.connector.Ajp13ConnectionHandler"/&gt;<br />
            &lt;Parameter name="port" value="8009"/&gt;<br />
            &lt;/Connector&gt;<br />
            <br />
            &lt;Host name="host1.apache.org"&gt;<br />
            &lt;Context path="" docBase="/web/host1" debug="0"/&gt;<br />
            &lt;/Host&gt;<br />
            &lt;Host name="host2.apache.org"&gt;<br />
            &lt;Context path="" docBase="/web/host2" debug="0"/&gt;<br />
            &lt;/Host&gt;<br />
            .<br />
            .<br />
            </pre>
            </blockquote>
            </td>
        </tr>
    </tbody>
</table>
<em>Table 1 - Excerpt from server.xml showing the Ajp13 Connector and two virtual
hosts.</em>
<br />
<br />
<table>
    <tbody>
        <tr>
            <td>
            <blockquote>
            <pre># Setup for Solaris system<br />
            #<br />
            workers.tomcat_home=/usr/local/jakarta-tomcat<br />
            workers.java_home=/usr/java<br />
            ps=/<br />
            worker.list=ajp12, ajp13<br />
            <br />
            # Definition for Ajp13 worker (Ajp12 left to readers imagination)<br />
            #<br />
            worker.ajp13.port=8009<br />
            worker.ajp13.host=localhost<br />
            worker.ajp13.type=ajp13<br />
            </pre>
            </blockquote>
            </td>
        </tr>
    </tbody>
</table>
<em>Table 2 - Excerpt from workers.properties showing the Ajp13 worker</em>
<br />
<br />
<table>
    <tbody>
        <tr>
            <td>
            <blockquote>
            <pre># Load mod_jk<br />
            #<br />
            LoadModule    jk_module  libexec/mod_jk.so<br />
            AddModule     mod_jk.c<br />
            <br />
            # Configure mod_jk<br />
            #<br />
            JkWorkersFile /usr/local/jakarta-tomcat/conf/jk/workers.properties<br />
            JkLogFile     /usr/local/apache/logs/mod_jk.log<br />
            JkLogLevel    info<br />
            <br />
            # First Virtual Host.<br />
            #<br />
            &lt;VirtualHost 10.0.0.1:80&gt;<br />
            DocumentRoot /web/host1<br />
            ServerName host1.apache.org<br />
            JkMount /*.jsp ajp13<br />
            JkMount /servlet/* ajp13<br />
            &lt;/VirtualHost&gt;<br />
            <br />
            # Second Virtual Host. Also accessible via HTTPS<br />
            #<br />
            &lt;VirtualHost 10.0.0.2:80&gt;<br />
            DocumentRoot /web/host2<br />
            ServerName host2.apache.org<br />
            JkMount /*.jsp ajp13<br />
            JkMount /servlet/* ajp13<br />
            &lt;/VirtualHost&gt;<br />
            <br />
            &lt;VirtualHost 10.0.0.2:443&gt;<br />
            DocumentRoot /web/host2<br />
            ServerName host2.apache.org<br />
            SSLEngine On<br />
            JkMount /*.jsp ajp13<br />
            JkMount /servlet/* ajp13<br />
            &lt;/VirtualHost&gt;<br />
            <br />
            </pre>
            </blockquote>
            </td>
        </tr>
    </tbody>
</table>
<em>Table 3 - Excerpt from Apaches httpd.conf showing JK directives.</em>
<hr />
<h2><a name="s10">Troubleshooting and F.A.Q.s</a></h2>
<h3>Q. Where can I get help/support for mod_jk?</h3>
A. The primary mechanism for support is through the Tomcat Documentation
included in the TOMCAT_HOME/doc directory.&nbsp; These documents are viewable
via browser through Tomcat <a href="http://localhost:8080/doc/index.html">http://localhost:8080/doc/index.html</a>.&nbsp;
Documentation is also available on the Apache Jakarta web site for Tomcat at <a href="http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/index.html">http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/index.html</a>.
<p>For additional help, the best resource is the Tomcat Users Discussion
list.&nbsp; You should start by searching the mail list archives located at <a href="http:///">http://mikal.org/interests/java/tomcat/index.html</a>
before you post questions to the list.&nbsp; If you are unable to locate the
answer to your question in the archive, you can post questions about Tomcat or
mod_jk to the user list for assistance.&nbsp; Make sure that you include the
version of Apache and Tomcat that you are using as well as the platform you are
running on. <a href="http:///">http://jakarta.apache.org/site/mail.html</a></p>
<h3>Q. I can't find mod_jk anywhere. Where is it?</h3>
A. Starting with Tomcat 3.3, the source for mod_jk is included in the native/mod_jk
directory.&nbsp; You can also download the Source Distribution of Tomcat to
obtain the source for mod_jk, which is how it was obtained in versions prior to
Tomcat 3.3. The Binary Distributions of mod_jk are available at the same
location as the Binary Distribution of Tomcat.&nbsp; The mod_jk binaries are
located in subdirectories by platform.
But in May 2001, the jakarta-tomcat-connectors was started and you'll find here
up to date featured mod_jk (ie: new protocols AJP14/WARP)
<h3>Q. Which protocol should I use? Ajp12 or Ajp13?</h3>
A. Ajp13 is a newer protocol, it's faster, and it works better with SSL. You almost
certainly want to use it. There is more information in the
<a href="http://tomcat.apache.org/tomcat-3.2-doc/Tomcat-Workers-HowTo.html">workers.properties howto</a> document.
<h3>Q. Whenever I restart Tomcat, Apache locks up!</h3>
A. The Ajp13 protocol keeps an open socket between Tomcat and Apache. The latest
release of mod_jk (the one found since Tomcat 3.3-m2 and J-T-C) handle the network failure.
But with previous release of mod_jk, you may have to restart Apache as well.
<h3>Q. Why did exist two files mod_jk.so (-eapi ad -noeapi) in download dir for Linux ?</h3>
A. Many versions of Apache use of modified API, known at Extended API. For example,
Apache using mod_ssl or Apache present in certains recent Linux distributions.
So if you got such 'Extended Apache', you need to use mod_jk.so-eapi, or use
mod_jk.so-noeapi for standard Apache. It's wise to avoid using EAPI modules on STD API Apache or to use standard
API modules on EAPI Apache. Allways be sure to have the mod_jk.so for your version of Apache
<h3>Q. What's that message about 'garbled DSO ?'</h3>
A. It's related to Apache EAPI, the message 'mod_jk.so is garbled - perhaps this is not an Apache module DSO ?'
just told you are trying to install a mod_jk.so DSO module that was compiled on an Apache using EAPI,
like apache-mod_ssl or apache from Redhat distro 6.2/7.0 but your system use the standard apache
with normal API.
<h3>Q. And the message about 'module might crash under EAPI! '</h3>
A. Also related to EAPI, the message '[warn] Loaded DSO /usr/lib/apache/mod_jk.so uses plain Apache 1.3 API,
this module might crash under EAPI! (please recompile it with -DEAPI)', the mod_jk.so was compiled under normal
Apache with standard API and you try to install the module on an Apache using EAPI.
<h3>Q. Where can I get more information?</h3>
A. The <a href="http://tomcat.apache.org/tomcat-3.2-doc/Tomcat-Workers-HowTo.html">workers.properties howto</a> document has
considerably more in-depth information than this one, and is worth a look. You could
also try searching the mailing list archives for "mod_jk" or look at the source.
<h3>Q.
APXS is getting an error during the build of mod_jk, like rc=0 or rc=255.&nbsp;
I tried all of the steps in the build section, what do I do now?</h3>
A. APXS is a Perl script that is created when you build the Apache web server
from source.&nbsp; Chances are that if you are getting these errors and you
obtained Apache as a binary distribution, that APXS is not configured correctly
for your system.&nbsp; Your best bet is to get the Apache source from <a href="http://httpd.apache.org/">http://httpd.apache.org</a>
and build it yourself.&nbsp; Use the following for a basic build (read the
Apache docs for other options):
<blockquote>
<pre># cd /usr/local/src<br />
# gzip -dc apache_1.3.19.tar.gz|tar xvf -<br />
# cd apache_1.3.19<br />
# ./configure --prefix=/usr/local/apache "<br />
--enable-module=most "<br />
--enable-shared=max<br />
# make<br />
# make install</pre>
</blockquote>
<p>Note: The above steps assume that you downloaded the Apache source and placed
it in your /usr/local/src directory.</p>
<hr />
<h2><a name="s11">Credits</a></h2>
<p>This document was originally created by
<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#115;&#104;&#97;&#99;&#104;&#111;&#114;&#64;&#105;&#108;&#46;&#105;&#98;&#109;&#46;&#99;&#111;&#109;">Gal Shachor</a></p>
<p>Revisions by (Alphabetical)</p>
<p>Mike Braden <tt>&lt;<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#109;&#105;&#107;&#101;&#98;&#64;&#109;&#119;&#98;&#105;&#110;&#99;&#46;&#99;&#111;&#109;">mikeb@mwbinc.com</a>&gt;</tt><br />
Mike Bremford<br />
Chris Pepper</p>
<p>With help from countless others on the tomcat-dev and tomcat-user lists!</p>
<p>
Copyright &#169;1999-2001 The Apache Software Foundation<br />
<a href="http://jakarta.apache.org/legal.html">Legal Stuff They Make Us Say</a><br />
<a href="http://jakarta.apache.org/contact.html">Contact Information</a> </p>
<img src ="http://www.blogjava.net/sealyu/aggbug/215595.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-07-17 22:01 <a href="http://www.blogjava.net/sealyu/archive/2008/07/17/215595.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat-Apache HOWTO</title><link>http://www.blogjava.net/sealyu/archive/2008/07/17/215545.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 17 Jul 2008 08:56:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/07/17/215545.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/215545.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/07/17/215545.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/215545.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/215545.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: This document explains how to connect Tomcat to the popularopen source web server, Apache.  It was originally part ofTomcat: A Minimalistic User's Guide by Gal Shachor, buthas been split off for...&nbsp;&nbsp;<a href='http://www.blogjava.net/sealyu/archive/2008/07/17/215545.html'>阅读全文</a><img src ="http://www.blogjava.net/sealyu/aggbug/215545.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-07-17 16:56 <a href="http://www.blogjava.net/sealyu/archive/2008/07/17/215545.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>The Apache Tomcat Connector - Webserver HowTo</title><link>http://www.blogjava.net/sealyu/archive/2008/07/17/215541.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 17 Jul 2008 08:51:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/07/17/215541.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/215541.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/07/17/215541.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/215541.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/215541.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Apache HowTo                                    print-friendly            version                                                Introduction                            ...&nbsp;&nbsp;<a href='http://www.blogjava.net/sealyu/archive/2008/07/17/215541.html'>阅读全文</a><img src ="http://www.blogjava.net/sealyu/aggbug/215541.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-07-17 16:51 <a href="http://www.blogjava.net/sealyu/archive/2008/07/17/215541.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tomcat5.5下配置manager用户名密码</title><link>http://www.blogjava.net/sealyu/archive/2008/07/17/215540.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 17 Jul 2008 08:48:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/07/17/215540.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/215540.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/07/17/215540.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/215540.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/215540.html</trackback:ping><description><![CDATA[在tomcat-users.xml中添加：<br />
&lt;role rolename="manager"/&gt;<br />
&lt;role rolename="admin"/&gt;<br />
<br />
&lt;user username="admin" password="admin" roles="admin,manager"/&gt;
<img src ="http://www.blogjava.net/sealyu/aggbug/215540.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-07-17 16:48 <a href="http://www.blogjava.net/sealyu/archive/2008/07/17/215540.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Redhat linux as 4上Apache与tomcat整合</title><link>http://www.blogjava.net/sealyu/archive/2008/07/17/215507.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 17 Jul 2008 07:24:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/07/17/215507.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/215507.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/07/17/215507.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/215507.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/215507.html</trackback:ping><description><![CDATA[1.首先需要安装JDK，Apache，Tomcat。安装完成后进行第二步。<br />
2.在apache网站下载jk文件 mod_jk_1.2.25_http_2.0.59.so，将该文件拷入apache的安装目录下的modules目录下。
<br />
修改apache安装目录下的httpd_conf文件：
<br />
LoadModule jk_module  modules/ mod_jk_1.2.25_http_2.0.59.so
<br />
JkWorkersFile  &#8220;Conf/workers.properties&#8221;
<br />
JkLogFile  &#8220;logs/mod_jk.log
<br />
JkLogLevel debug
<br />
JkMount  /*.jsp worker1
<br />
JkMount  /test/*  worker1
<br />
<br />
Listen 192.168.0.1:80
<br />
<br />
DocumentRoot  &#8220;/web/tomcat5028/webapps/test&#8221;
<br />
&lt;Directory &#8220;/web/tomcat5028/webapps/test&#8221;&gt;
<br />
在conf下建立workers.properties文件，键入以下内容：
<br />
ps=/
<br />
worker. .list = worker1
<br />
worker.worker1.typye = ajp13
<br />
worker.worker1.host = 192.168.0.1
<br />
worker.worker1.port = 8009
<br />
worker.worker1.lbfactor = 1
<br />
最后测试，重启Tomcat服务器和Apache服务器，通过IE访问http://192.168.0.1/如果出现
<br />
Tomcat的默认主页，表明配置以成功。
<img src ="http://www.blogjava.net/sealyu/aggbug/215507.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-07-17 15:24 <a href="http://www.blogjava.net/sealyu/archive/2008/07/17/215507.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Apache HTTP Server 与 Tomcat 的三种连接方式介绍</title><link>http://www.blogjava.net/sealyu/archive/2008/07/16/215337.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Wed, 16 Jul 2008 14:41:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/07/16/215337.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/215337.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/07/16/215337.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/215337.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/215337.html</trackback:ping><description><![CDATA[<blockquote>整合 Apache Http Server 和 Tomcat 可以提升对静态文件的处理性能、利用 Web 服务器来做负载均衡以及容错、无缝的升级应用程序。本文介绍了三种整合 Apache 和 Tomcat 的方式。</blockquote>
<p>首先我们先介绍一下为什么要让
Apache 与 Tomcat 之间进行连接。事实上 Tomcat 本身已经提供了 HTTP 服务，该服务默认的端口是 8080，装好
tomcat 后通过 8080 端口可以直接使用 Tomcat 所运行的应用程序，你也可以将该端口改为 80。</p>
<p>既然 Tomcat 本身已经可以提供这样的服务，我们为什么还要引入 Apache 或者其他的一些专门的 HTTP 服务器呢？原因有下面几个：</p>
<p>1.	提升对静态文件的处理性能</p>
<p>2.	利用 Web 服务器来做负载均衡以及容错</p>
<p>3.	无缝的升级应用程序</p>
<p>这
三点对一个 web 网站来说是非常之重要的，我们希望我们的网站不仅是速度快，而且要稳定，不能因为某个 Tomcat
宕机或者是升级程序导致用户访问不了，而能完成这几个功能的、最好的 HTTP 服务器也就只有 apache 的 http server 了，它跟
tomcat 的结合是最紧密和可靠的。</p>
<p>接下来我们介绍三种方法将 apache 和 tomcat 整合在一起。</p>
<p><a name="N1005F">JK</a></p>
<p>这是最常见的方式，你可以在网上找到很多关于配置JK的网页，当然最全的还是其官方所提供的文档。JK 本身有两个版本分别是 1 和 2，目前 1 最新的版本是 1.2.19，而版本 2 早已经废弃了，以后不再有新版本的推出了，所以建议你采用版本 1。</p>
<p>JK
是通过 AJP 协议与 Tomcat 服务器进行通讯的，Tomcat 默认的 AJP Connector 的端口是 8009。JK
本身提供了一个监控以及管理的页面 jkstatus，通过 jkstatus 可以监控 JK 目前的工作状态以及对到 tomcat
的连接进行设置，如下图所示：</p>
<br />
<a name="N1006D"><strong>图 1：监控以及管理的页面 jkstatus</strong></a><br />
<img alt="图 1：监控以及管理的页面 jkstatus" src="http://www.ibm.com/developerworks/cn/opensource/os-lo-apache-tomcat/images/image002.jpg" border="0" height="228" width="554" />
<br />
<p>在
这个图中我们可以看到当前JK配了两个连接分别到 8109 和 8209 端口上，目前 s2 这个连接是停止状态，而 s1
这个连接自上次重启后已经处理了 47 万多个请求，流量达到 6.2 个 G，最大的并发数有 13 等等。我们也可以利用 jkstatus
的管理功能来切换 JK 到不同的 Tomcat 上，例如将 s2 启用，并停用
s1，这个在更新应用程序的时候非常有用，而且整个切换过程对用户来说是透明的，也就达到了无缝升级的目的。关于 JK
的配置文章网上已经非常多了，这里我们不再详细的介绍整个配置过程，但我要讲一下配置的思路，只要明白了配置的思路，JK 就是一个非常灵活的组件。</p>
<p>JK 的配置最关键的有三个文件，分别是 </p>
<p>
<strong>httpd.conf </strong>
<br />
Apache 服务器的配置文件，用来加载 JK 模块以及指定 JK 配置文件信息</p>
<p>
<strong>workers.properties</strong>
<br />
到 Tomcat 服务器的连接定义文件</p>
<p>
<strong>uriworkermap.properties</strong>
<br />
URI 映射文件，用来指定哪些 URL 由 Tomcat 处理，你也可以直接在 httpd.conf 中配置这些 URI，但是独立这些配置的好处是 JK 模块会定期更新该文件的内容，使得我们修改配置的时候无需重新启动 Apache 服务器。</p>
<p>其中第二、三个配置文件名都可以自定义。下面是一个典型的 httpd.conf 对 JK 的配置</p>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td>
            <pre># (httpd.conf)<br />
            # 加载 mod_jk 模块<br />
            LoadModule jk_module modules/mod_jk.so<br />
            <br />
            #<br />
            # Configure mod_jk<br />
            #<br />
            <br />
            JkWorkersFile conf/workers.properties<br />
            JkMountFile conf/uriworkermap.properties<br />
            JkLogFile logs/mod_jk.log<br />
            JkLogLevel warn<br />
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<br />
<p>接下来我们在 Apache 的 conf 目录下新建两个文件分别是 workers.properties、uriworkermap.properties。这两个文件的内容大概如下</p>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td>
            <pre>#<br />
            # workers.properties<br />
            #<br />
            <br />
            <br />
            # list the workers by name<br />
            <br />
            worker.list=DLOG4J, status<br />
            <br />
            # localhost server 1<br />
            # ------------------------<br />
            worker.s1.port=8109<br />
            worker.s1.host=localhost<br />
            worker.s1.type=ajp13<br />
            <br />
            # localhost server 2<br />
            # ------------------------<br />
            worker.s2.port=8209<br />
            worker.s2.host=localhost<br />
            worker.s2.type=ajp13<br />
            worker.s2.stopped=1<br />
            <br />
            worker.DLOG4J.type=lb<br />
            worker.retries=3<br />
            worker.DLOG4J.balanced_workers=s1, s2<br />
            worker.DLOG4J.sticky_session=1<br />
            <br />
            worker.status.type=status<br />
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<br />
<p>以上的 workers.properties
配置就是我们前面那个屏幕抓图的页面所用的配置。首先我们配置了两个类型为 ajp13 的 worker 分别是 s1 和
s2，它们指向同一台服务器上运行在两个不同端口 8109 和 8209 的 Tomcat 上。接下来我们配置了一个类型为
lb（也就是负载均衡的意思）的 worker，它的名字是 DLOG4J，这是一个逻辑的 worker，它用来管理前面配置的两个物理连接 s1
和 s2。最后还配置了一个类型为 status 的 worker，这是用来监控 JK 本身的模块。有了这三个 worker
还不够，我们还需要告诉 JK，哪些 worker 是可用的，所以就有 <strong>worker.list = DLOG4J, status</strong> 这行配置。</p>
<p>接下来便是 URI 的映射配置了，我们需要指定哪些链接是由 Tomcat 处理的，哪些是由 Apache 直接处理的，看看下面这个文件你就能明白其中配置的意义</p>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td>
            <pre>/*=DLOG4J<br />
            /jkstatus=status<br />
            <br />
            !/*.gif=DLOG4J<br />
            !/*.jpg=DLOG4J<br />
            !/*.png=DLOG4J<br />
            !/*.css=DLOG4J<br />
            !/*.js=DLOG4J<br />
            !/*.htm=DLOG4J<br />
            !/*.html=DLOG4J<br />
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<br />
<p>相信你已经明白了一大半了：所有的请求都由 DLOG4J
这个 worker 进行处理，但是有几个例外，/jkstatus 请求由 status 这个 worker
处理。另外这个配置中每一行数据前面的感叹号是什么意思呢？感叹号表示接下来的 URI 不要由 JK 进行处理，也就是 Apache
直接处理所有的图片、css 文件、js 文件以及静态 html 文本文件。</p>
<p>
通过对 workers.properties 和 uriworkermap.properties 的配置，可以有各种各样的组合来满足我们前面提出对一个 web 网站的要求。您不妨动手试试！</p>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td><img src="http://www.ibm.com/i/v14/rules/blue_rule.gif" alt="" height="1" width="100%" /><br />
            <img alt="" src="http://www.ibm.com/i/c.gif" border="0" height="6" width="8" /></td>
        </tr>
    </tbody>
</table>
<table align="right" cellpadding="0" cellspacing="0">
    <tbody>
        <tr align="right">
            <td><img src="http://www.ibm.com/i/c.gif" alt="" height="4" width="100%" /><br />
            <table border="0" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <td valign="middle"><img src="http://www.ibm.com/i/v14/icons/u_bold.gif" alt="" border="0" height="16" width="16" /><br />
                        </td>
                        <td align="right" valign="top"><a href="http://www.ibm.com/developerworks/cn/opensource/os-lo-apache-tomcat/index.html#main" class="fbox"><strong>回页首</strong></a></td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<br />
<br />
<p><a name="N100CB">http_proxy</a></p>
<p>这是利用 Apache 自带的 mod_proxy 模块使用代理技术来连接 Tomcat。在配置之前请确保是否使用的是 2.2.x 版本的 Apache 服务器。因为 2.2.x 版本对这个模块进行了重写，大大的增强了其功能和稳定性。</p>
<p>http_proxy 模式是基于 HTTP 协议的代理，因此它要求 Tomcat 必须提供 HTTP 服务，也就是说必须启用 Tomcat 的 HTTP Connector。一个最简单的配置如下</p>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td>
            <pre>ProxyPass /images !<br />
            ProxyPass /css !<br />
            ProxyPass /js !<br />
            ProxyPass / http://localhost:8080/<br />
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<br />
<p>在这个配置中，我们把所有
http://localhost 的请求代理到 http://localhost:8080/ ，这也就是 Tomcat 的访问地址，除了
images、css、js 几个目录除外。我们同样可以利用 mod_proxy 来做负载均衡，再看看下面这个配置</p>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td>
            <pre>ProxyPass /images !<br />
            ProxyPass /css ! <br />
            ProxyPass /js !<br />
            <br />
            ProxyPass / balancer://example/<br />
            &lt;Proxy balancer://example/&gt;<br />
            BalancerMember http://server1:8080/<br />
            BalancerMember http://server2:8080/<br />
            BalancerMember http://server3:8080/<br />
            &lt;/Proxy&gt;<br />
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<br />
<p>配置比 JK 简单多了，而且它也可以通过一个页面来监控集群运行的状态，并做一些简单的维护设置。</p>
<br />
<a name="N100F1"><strong>图 2：监控集群运行状态</strong></a><br />
<img alt="图 2：监控集群运行状态" src="http://www.ibm.com/developerworks/cn/opensource/os-lo-apache-tomcat/images/image004.gif" border="0" height="427" width="553" />
<br />
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td><img src="http://www.ibm.com/i/v14/rules/blue_rule.gif" alt="" height="1" width="100%" /><br />
            <img alt="" src="http://www.ibm.com/i/c.gif" border="0" height="6" width="8" /></td>
        </tr>
    </tbody>
</table>
<table align="right" cellpadding="0" cellspacing="0">
    <tbody>
        <tr align="right">
            <td><img src="http://www.ibm.com/i/c.gif" alt="" height="4" width="100%" /><br />
            <table border="0" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <td valign="middle"><img src="http://www.ibm.com/i/v14/icons/u_bold.gif" alt="" border="0" height="16" width="16" /><br />
                        </td>
                        <td align="right" valign="top"><a href="http://www.ibm.com/developerworks/cn/opensource/os-lo-apache-tomcat/index.html#main" class="fbox"><strong>回页首</strong></a></td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<br />
<br />
<p><a name="N10101">ajp_proxy</a></p>
<p>ajp_proxy
连接方式其实跟 http_proxy 方式一样，都是由 mod_proxy 所提供的功能。配置也是一样，只需要把 http:// 换成
ajp:// ，同时连接的是 Tomcat 的 AJP Connector 所在的端口。上面例子的配置可以改为：</p>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td>
            <pre>ProxyPass /images !<br />
            ProxyPass /css ! <br />
            ProxyPass /js !<br />
            <br />
            ProxyPass / balancer://example/<br />
            &lt;Proxy balancer://example/&gt;<br />
            BalancerMember ajp://server1:8080/<br />
            BalancerMember ajp://server2:8080/<br />
            BalancerMember ajp://server3:8080/<br />
            &lt;/Proxy&gt;<br />
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<br />
<p>采用 proxy 的连接方式，需要在 Apache
上加载所需的模块，mod_proxy 相关的模块有
mod_proxy.so、mod_proxy_connect.so、mod_proxy_http.so、mod_proxy_ftp.so、
mod_proxy_ajp.so， 其中 mod_proxy_ajp.so 只在 Apache 2.2.x 中才有。如果是采用
http_proxy 方式则需要加载 mod_proxy.so 和 mod_proxy_http.so；如果是 ajp_proxy 则需要加载
mod_proxy.so 和 mod_proxy_ajp.so这两个模块。</p>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td><img src="http://www.ibm.com/i/v14/rules/blue_rule.gif" alt="" height="1" width="100%" /><br />
            <img alt="" src="http://www.ibm.com/i/c.gif" border="0" height="6" width="8" /></td>
        </tr>
    </tbody>
</table>
<table align="right" cellpadding="0" cellspacing="0">
    <tbody>
        <tr align="right">
            <td><img src="http://www.ibm.com/i/c.gif" alt="" height="4" width="100%" /><br />
            <table border="0" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <td valign="middle"><img src="http://www.ibm.com/i/v14/icons/u_bold.gif" alt="" border="0" height="16" width="16" /><br />
                        </td>
                        <td align="right" valign="top"><a href="http://www.ibm.com/developerworks/cn/opensource/os-lo-apache-tomcat/index.html#main" class="fbox"><strong>回页首</strong></a></td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<br />
<br />
<p><a name="N10116">三者比较</a></p>
<p>相
对于 JK 的连接方式，后两种在配置上是比较简单的，灵活性方面也一点都不逊色。但就稳定性而言就不像 JK 这样久经考验，毕竟 Apache
2.2.3 推出的时间并不长，采用这种连接方式的网站还不多，因此，如果是应用于关键的互联网网站，还是建议采用 JK 的连接方式。</p>
<br />
<br />
<p><a name="resources">参考资料 </a></p>
<ul>
    <li>
    获得 <a href="http://httpd.apache.org/">Apache Http Server</a>。
    <br />
    <br />
    </li>
    <li>
    获得 <a href="http://tomcat.apache.org/">Apache Tomcat</a>。
    <br />
    <br />
    </li>
    <li>
    <a href="http://tomcat.apache.org/connectors-doc/">JK 文档</a>。
    </li>
</ul>
<br />
<br />
<p><a name="author">关于作者</a></p>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td colspan="3"><img alt="" src="http://www.ibm.com/i/c.gif" height="5" width="100%" /></td>
        </tr>
        <tr align="left" valign="top">
            <td><br />
            </td>
            <td><img alt="" src="http://www.ibm.com/i/c.gif" height="5" width="4" /></td>
            <td width="100%">
            <p>刘冬，一直使用 J2EE/J2ME 从事移动互联网方面的开发。您可以通过 Java 自由人网站来跟他联系，网址是：<a href="http://www.dlog.cn/javayou">http://www.dlog.cn/javayou</a> ，另外他的邮件地址是<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#106;&#97;&#118;&#97;&#121;&#111;&#117;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;&#63;&#99;&#99;&#61;">javayou@gmail.com</a>。</p>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.blogjava.net/sealyu/aggbug/215337.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-07-16 22:41 <a href="http://www.blogjava.net/sealyu/archive/2008/07/16/215337.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> JBoss 4.0.4GA 启动参数解释(转载)</title><link>http://www.blogjava.net/sealyu/archive/2008/04/10/191991.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 10 Apr 2008 14:29:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/04/10/191991.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/191991.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/04/10/191991.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/191991.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/191991.html</trackback:ping><description><![CDATA[-h, --help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;显示帮助信息<br />
&nbsp;&nbsp;&nbsp; -V, --version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 显示版本信息<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -D&lt;name&gt;[=&lt;value&gt;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 设置系统属性<br />
&nbsp;&nbsp;&nbsp; -d, --bootdir=&lt;dir&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;设置启动补丁目录的位置；必须是绝对路径或者url<br />
&nbsp;&nbsp;&nbsp; -p, --patchdir=&lt;dir&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 设置补丁目录的位置；必须是绝对路径或者url<br />
&nbsp;&nbsp;&nbsp; -n, --netboot=&lt;url&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 从指定的url网络位置启动<br />
&nbsp;&nbsp;&nbsp; -c, --configuration=&lt;name&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 指定服务器启动的配置（default、all、minimal）<br />
&nbsp;&nbsp;&nbsp; -B, --bootlib=&lt;filename&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将其它的jar包添加到bootclasspath的前面<br />
&nbsp;&nbsp;&nbsp; -L, --library=&lt;filename&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将其它的jar包添加到 loaders classpath<br />
&nbsp;&nbsp;&nbsp; -C, --classpath=&lt;url&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将其它的url添加到loaders classpath<br />
&nbsp;&nbsp;&nbsp; -P, --properties=&lt;url&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 从指定的url加载系统属性<br />
&nbsp;&nbsp;&nbsp; -b, --host=&lt;host or ip&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;所有JBoss Service绑定的地址<br />
&nbsp;&nbsp;&nbsp; -g, --partition=&lt;name&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;HA分区的名称（缺省为DefaultDomain）<br />
&nbsp;&nbsp;&nbsp; -u, --udp=&lt;ip&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UDP的多播地址<br />
&nbsp;&nbsp;&nbsp; -l, --log=&lt;log4j|jdk&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 设置日志记录插件类型
<p>JBoss 4.0.4GA环境变量</p>
<p>&nbsp;&nbsp;&nbsp; JBOSS_HOME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JBoss的位置<br />
&nbsp;&nbsp;&nbsp;&nbsp;JAVA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Java运行程序的位置<br />
&nbsp;&nbsp;&nbsp; JAVA_OPTS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JVM启动参数<br />
&nbsp;&nbsp;&nbsp;&nbsp;MAX_FD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JBoss能够使用文件描述符的最大数量（仅用于Un*x）</p>
<img src ="http://www.blogjava.net/sealyu/aggbug/191991.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-04-10 22:29 <a href="http://www.blogjava.net/sealyu/archive/2008/04/10/191991.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>