??xml version="1.0" encoding="utf-8" standalone="yes"?>96av麻豆蜜桃一区二区,国产精品色在线,国产精品国产精品国产专区蜜臀ahhttp://www.aygfsteel.com/sealyu/archive/2010/05/18/321225.htmlsealsealMon, 17 May 2010 20:19:00 GMThttp://www.aygfsteel.com/sealyu/archive/2010/05/18/321225.htmlhttp://www.aygfsteel.com/sealyu/comments/321225.htmlhttp://www.aygfsteel.com/sealyu/archive/2010/05/18/321225.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/321225.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/321225.html TreeCache是一U结构化的、基于复制的事务~存。TreeCache是JBoss应用服务器中集群服务—包括JNDI集群、HTTP和EJB? Sesssion集群、JMS集群—的基础框架。其可以单独使用Q可以集成到JBossAS应用Q也可以集成到其他的应用服务器上。TreeCache? 一U树(wi)状结构,每个节点拥有一个名字和多个或者没有子节点Q除跟节Ҏ(gu)有子节点其他节点有且只有一个父母节点,可以通过路径名来讉K子节? QF(tun)QNQFull Qualified NameQ,在一个TreeCache中可以存在多|(wi)Q,卛_以有多个根节炏V当应用于分布式环境Ӟ׃TreeCache是基于复制的Q每个子节点 的值必L可序列化的?
     在下面中Q将通过例子来了(jin)解TreeCache的功能及(qing)光|,使用JBossCache1.4和JDK5.0。首先是一个最基本使用TreeCache 的程序例子ƈ配置一个TreeCache的配|骨Ӟ各种常用的配|可参见jboss-cache-dist-1.4.0.CR1版本的etc目录Q如? 各种配置参考也可见该目录下的范例配|,以下不再Q,见下Q?

treecache.xmlQ?


<server>
    <mbean code="org.jboss.cache.TreeCache"
        name="jboss.cache:service=TreeCache">
        <depends>jboss:service=Naming</depends>
        <depends>jboss:service=TransactionManager</depends>
        <attribute name="ClusterName">TreeCache-Cluster</attribute>
        <attribute name="ClusterConfig">
            <config>
                <UDP mcast_addr="228.1.2.3" mcast_port="48866"
                    ip_ttl="64" ip_mcast="true"
                    mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
                    ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
                    loopback="false"/>
                <PING timeout="2000" num_initial_members="3"
                    up_thread="false" down_thread="false"/>
                <MERGE2 min_interval="10000" max_interval="20000"/>
                <FD_SOCK/>
                <VERIFY_SUSPECT timeout="1500"
                    up_thread="false" down_thread="false"/>
                <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
                    max_xmit_size="8192" up_thread="false" down_thread="false"/>
                <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
                    down_thread="false"/>
                <pbcast.STABLE desired_avg_gossip="20000"
                    up_thread="false" down_thread="false"/>
                <FRAG frag_size="8192"
                    down_thread="false" up_thread="false"/>
                <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
                    shun="true" print_local_addr="true"/>
                <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>
            </config>
        </attribute>
    </mbean>
</server>
   其中ClusterConfig配置在前面JavaGroups的介l详l介l,其它配置比较单,需要进一步了(jin)解请参见TreeCache文档?
   一、Cache分类
   TreeCache按功能分Zc:(x)本地(Local)Cache、复?Replication)Cache和失? (Invalidation)Cache。本地Cache只应用于本地环境Q后两个Cache可应用于分布式环境,其中Q在分布式环境中Q复制Cache 当一个Cache实例的一个节点值发生变化时?x)将变化复制到其它实例中Q而失效Cache是当一个Cache实例的一个节点值发生变化时?x)将其它实例的? 应节点的D为空Q让光新去获得该|可通过q种方式~存大对象以减少在实例中复制对象的代仗分布式CacheQ复制和失效CacheQ又分ؓ(f)两种Q? 同步QREPL_ASYNCQ和异步QREPL_SYNCQ,同步Cache是在一个Cache实例做修Ҏ(gu)Q等待变化应用到其它实例后才q回Q而异? Cache是在一个Cache实例做修Ҏ(gu)Q即刻返回。其配置见下Q?
!--
  Valid modes are LOCAL
                  REPL_ASYNC
                  REPL_SYNC
                  INVALIDATION_ASYNC
                  INVALIDATION_SYNC
->
attribute name="CacheMode">REPL_SYNC</attribute>

   二、事务和q行(Transaction And Concurrent)
   TreeCache是一U事务CacheQ与JDBC一P其包括两斚w内容Q锁和隔ȝ别。锁分ؓ(f)(zhn)观锁和乐观锁,当用?zhn)观锁Ӟ分?f)五个隔离U别Q? 分别是SERIALIZABLE、REPEATABLE_READ (default)、READ_COMMITTED、READ_UNCOMMITTED和NONEQ隔ȝ别逐步减弱。乐观锁也叫版本锁,其对数据q行? 作时Q将其复制到临时区,操作之后版本与原有数据比较Q如果一致则递增版本q写回,如果不一致则回滚Q由于乐观锁仅在复制出数据和提交数据时对数据? 锁,所以ƈ行度更高Q但如果写操作比较频J地话则Ҏ(gu)出现冲突D回滚。TreeCache默认使用(zhn)观锁。用TreeCacheӞ需要用容器提? 的事务管理器Q一般JBossTransactionManagerLookup和GenericTransactionManagerLookupQ? 前者应用于JBOSS服务器,后者应用于其他服务器,也可使用DummyTransactionManagerLookup用于试。如上介l的配置? 下:(x)
attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
     <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>


   三、逐出{略(Eviction Policy)
   ׃内存数量的局限,不可能将所有的Cache数据存放在内存中Q但使用内存辑ֈ一定极限时Q会(x)部分数据清除出内存Q保存到其它持久媒质中,定义的什? 时候清除、如何清除的{略是逐出{略。自定义一个逐出{略需要实现org.jboss.cache.eviction.EvictionPolicy? org.jboss.cache.eviction.EvictionAlgorithm?
g.jboss.cache.eviction.EvictionQueue 和org.jboss.cache.eviction.EvictionConfiguration四个接口Q系l提供了(jin)LRU(Least recently usedQ最q最?、LFU(Least Frequently Used最不经怋?、FIFO(First In First Out先进先出)、MRU(Most Recently Used最q最l常使用)四种实现Q详l参见org.jboss.cache.eviction包的源代码。配|如下:(x)
<attribute name="EvictionPolicyConfig">
   <config>
      <attribute name="wakeUpIntervalSeconds">5</attribute>
      <region name="/_default_">
        <attribute name="maxNodes">5000</attribute>
        <attribute name="timeToLiveSeconds">1000</attribute>
      </region>
      <region name="/org/jboss/data"
policyClass="org.jboss.cache.eviction.FIFOPolicy">
        <attribute name="maxNodes">5000</attribute>
      </region>
      <region name="/test/" policyClass="org.jboss.cache.eviction.MRUPolicy">
        <attribute name="maxNodes">10000</attribute>
      </region>
      <region name="/maxAgeTest/">
        <attribute name="maxNodes">10000</attribute>
        <attribute name="timeToLiveSeconds">8</attribute>
        <attribute name="maxAgeSeconds">10</attribute>
      </region>
   </config>
</attribute>
     四、Cache加蝲
  ׃逐出{略的存在,那么当我们重新需要获得一个原来在~存中但由内存原因被逐出的数据时Q就需要定义一U加载策略,使地可以重新扑֛数据Q同 ӞCache加蝲也肩负在数据逐出时将数据保存到持久媒质的责Q?
  Ҏ(gu)数据保存媒质的不同QCache加蝲包括F(xin)ileCacheLoader、JDBCCacheLoader{等Q可以同时用多U加载器来灵zd? 加蝲{略。例见下Q?
<attribute name="CacheLoaderConfiguration">
    <config>
        <passivation>false</passivation>
        <preload>/</preload>
        <shared>true</shared>
        <cacheloader>
            <class>org.jboss.cache.loader.ClusteredCacheLoader</class>
            <properties>
                 timeout=1000
            </properties>
            <async>true</async>
            <fetchPersistentState>false</fetchPersistentState>
            ignoreModifications>false</ignoreModifications>
            <purgeOnStartup>false</purgeOnStartup>
        </cacheloader>
        <cacheloader>
            <class>org.jboss.cache.loader.JDBCCacheLoader</class>
            <properties>
                        cache.jdbc.table.name=jbosscache
                        cache.jdbc.table.create=true
                        cache.jdbc.table.drop=true
                        cache.jdbc.table.primarykey=jbosscache_pk
                        cache.jdbc.fqn.column=fqn
                        cache.jdbc.fqn.type=varchar(255)
                        cache.jdbc.node.column=node
                        cache.jdbc.node.type=longblob
                        cache.jdbc.parent.column=parent
                        cache.jdbc.driver=com.mysql.jdbc.Driver
                        cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
                        cache.jdbc.user=root
                        cache.jdbc.password=
             </properties>
             <async>true</async>
             <fetchPersistentState>false</fetchPersistentState>
             <purgeOnStartup>false</purgeOnStartup>
         </cacheloader>
    </config>
</attribute>

我们通过定制如上的配|信息以更有效地使用JBossCache。详l情况可参考JBoss TreeCache参考文档和范例?

TreeCache tree = new TreeCache();
tree.setClusterProperties("treecache.xml";
tree.createService();
tree.startService();
tree.put("/a/b/c", "name", "Ben";
tree.put("/a/b/c/d", "uid", new Integer(322649));
Integer tmp = (Integer) tree.get("/a/b/c/d", "uid";
tree.remove("/a/b";
tree.stopService();
tree.destroyService();


seal 2010-05-18 04:19 发表评论
]]>
Tomcat配置SSL后用代理碰到的问题http://www.aygfsteel.com/sealyu/archive/2010/01/13/309293.htmlsealsealWed, 13 Jan 2010 04:49:00 GMThttp://www.aygfsteel.com/sealyu/archive/2010/01/13/309293.htmlhttp://www.aygfsteel.com/sealyu/comments/309293.htmlhttp://www.aygfsteel.com/sealyu/archive/2010/01/13/309293.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/309293.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/309293.html 但是在别的机子上讉K时L报错Q?
|络讉K消息: 无法昄此页
 
技术信?供支持h员?
错误代码: 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)
IP 地址: xxx.xx.xxx.xx
日期: 2010-1-13 4:35:17 [GMT]
服务? isa-srv.xxxx.com

其中的IP地址是我们公总理的地址Q服务器是公总理服务器?br /> 在网上没有找到解x法,l过分析错误信息Q发现很多实?43端口而不是tomcat?443端口来访问SSL|址Q修改了(jin)tomcat下的server.xml文gQ果焉题解冟?br />


seal 2010-01-13 12:49 发表评论
]]>
Apache Tomcat 6.0 SSL Configuration HOW-TOhttp://www.aygfsteel.com/sealyu/archive/2010/01/13/309265.htmlsealsealWed, 13 Jan 2010 00:43:00 GMThttp://www.aygfsteel.com/sealyu/archive/2010/01/13/309265.htmlhttp://www.aygfsteel.com/sealyu/comments/309265.htmlhttp://www.aygfsteel.com/sealyu/archive/2010/01/13/309265.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/309265.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/309265.html阅读全文

seal 2010-01-13 08:43 发表评论
]]>
Tomcat SSL配置大全Q{Q?/title><link>http://www.aygfsteel.com/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.aygfsteel.com/sealyu/archive/2010/01/13/309264.html</guid><wfw:comment>http://www.aygfsteel.com/sealyu/comments/309264.html</wfw:comment><comments>http://www.aygfsteel.com/sealyu/archive/2010/01/13/309264.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sealyu/comments/commentRss/309264.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sealyu/services/trackbacks/309264.html</trackback:ping><description><![CDATA[<p>一、准备工?br />     1). 安装JDK 1.5 或更高版本, q|JAVA_HOME 环境变量;<br />     2). 安装tomcat 6 ;<br />    <br /> 二、配|过E?br />     1.生成 server key Q?br />       以命令行方式切换到目?tomcat_HOME%Q在command命o(h)行输入如下命令(jdk1.4以上带的工具Q:(x) <br />       keytool -genkey -alias tomcat -keyalg RSA -keypass changit -storepass changit -keystore server.keystore -validity 3600 <br />       <br />       用户名输入域名,如localhostQ开发或试用)(j)或hostname.domainname(用户拥有的域?Q其它全部以 enter 跌Q最后确认,<br />       此时?x)?JAVA_HOME%/bin下生成server.keystore 文g?br />       <br />       注:(x)参数 -validity 指证书的有效??Q缺省有效期很短Q只?0天?br />     <br />     2.证书导入的JDK的证书信d?<br />       q步对于tomcat的SSL配置不是必须Q但对于CAS SSO是必ȝQ否则会(x)出现如下错误Qedu.yale.its.tp.cas.client.CASAuthenticationException: Unable to validate ProxyTicketValidator。。?br />       <br />       导入q程?步,W一步是导出证书Q第二步是导入到证书信Q库,命o(h)如下Q?br />       keytool -export -trustcacerts -alias tomcat -file server.cer -keystore  server.keystore -storepass changit<br />       <br />       keytool -import -trustcacerts -alias tomcat -file server.cer -keystore  %JAVA_HOME%/jre/lib/security/cacerts -storepass changeit<br />       <br />       如果有提C,输入Y可以了(jin)?br />    <br />    其他有用keytool命o(h)Q列Z任证书库中所有已有证书,删除库中某个证书Q:(x)<br />    <br />    keytool -list -v -keystore %JAVA_HOME%/jre/lib/security/cacerts<br />    keytool -delete -trustcacerts -alias tomcat  -keystore  %JAVA_HOME%/jre/lib/security/cacerts -storepass changit</p> <p>  3.配置tomcat :<br />    修改%TOMCAT_HOME%"conf"server.xmlQ以文字~辑器打开Q查找这一行:(x)<br />    xml 代码<br />    <br />    之后的那段的注释去掉,q加?keystorePass?qing)keystoreFile属性?br />    注意Qtomcat不同版本配置是不同的:<br />    tomcat4.1.34配置Q?br />    xml 代码     <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"             port="8443" enableLookups="true" scheme="https" secure="true"             acceptCount="100"             useURIValidationHack="false" disableUploadTimeout="true"             clientAuth="false" sslProtocol="TLS"               keystoreFile="server.keystore"               keystorePass="changit"/>  tomcat5.5.9配置Q?br />    <br />      <br />    xml 代码<br />       <br />    <Connector port="8443" maxHttpHeaderSize="8192"   <br />               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"   <br />               enableLookups="false" disableUploadTimeout="true"   <br />               acceptCount="100" scheme="https" secure="true"   <br />               clientAuth="false" sslProtocol="TLS"     <br />               keystoreFile="server.keystore"     <br />               keystorePass="changit"/>   <br />    tomcat5.5.20配置(此配|同样可用于tomcat6.0)Q?br />     <br />    xml 代码<br />       <br />    <Connector protocol="org.apache.coyote.http11.Http11Protocol"     <br />                         port="8443" maxHttpHeaderSize="8192"   <br />               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"   <br />               enableLookups="false" disableUploadTimeout="true"   <br />               acceptCount="100" scheme="https" secure="true"   <br />               clientAuth="false" sslProtocol="TLS"                    <br />               keystoreFile="server.keystore"     <br />               keystorePass="changit"/>   <br />    tomcat6.0.10配置Q?br />    <br />    xml 代码<br />    <Connector protocol="org.apache.coyote.http11.Http11NioProtocol"   <br />               port="8443" minSpareThreads="5" maxSpareThreads="75"   <br />               enableLookups="true" disableUploadTimeout="true"     <br />               acceptCount="100"  maxThreads="200"   <br />               scheme="https" secure="true" SSLEnabled="true"   <br />               clientAuth="false" sslProtocol="TLS"   <br />               keystoreFile="server.keystore"     <br />               keystorePass="changit"/>   <br />    tomcat6支持3U,请参考以下文档:(x)<br />    <a >http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html</a> <br />    <br />   4.验证配置<br />    讉K <a href="https://localhost:8443/">https://localhost:8443/</a><br />    <connector protocol="org.apache.coyote.http11.Http11NioProtocol"></connector><br />    <br />   5. 如果默认想用HTTPS 方式q行|站, 可以作如下配|?<br />   一般Tomcat默认的SSL端口h8443Q但是对于SSL标准端口h443Q?br />   q样在访问网늚时候,直接使用https而不需要输入端口号可以访问,?a href="https://localhost/">https://localhost</a><br />   <br />    1).non-SSL HTTP/1.1 Connector定义的地方,一般如下:(x)<br />         <Connector port="80" maxHttpHeaderSize="8192"  scheme="https" <br />                 maxThreads="500" minSpareThreads="25" maxSpareThreads="75" <br />                 enableLookups="false" redirectPort="443" acceptCount="100" <br />                 connectionTimeout="20000" disableUploadTimeout="true" />   <br />   <br />       其中的redirectPort端口h为:(x)443 </p> <p>   2).SSL HTTP/1.1 Connector定义的地方,修改端口号ؓ(f)Q?43Q如下:(x)<br />        <Connector     <br />        port="443" maxHttpHeaderSize="8192" <br />        maxThreads="150" minSpareThreads="25" <br />        maxSpareThreads="75" <br />        enableLookups="false" <br />        disableUploadTimeout="true" <br />        acceptCount="100" scheme="https" <br />        secure="true" <br />        clientAuth="false" sslProtocol="TLS" <br />         SSLEnabled="true"   <br />        keystoreFile="e:/server.keystore" <br />        keystorePass="changit" /><br />     3).AJP 1.3 Connector定义的地方,修改redirectPort?43Q如下:(x)   <br />     <Connector port="8009" <br />           enableLookups="false" redirectPort="443" protocol="AJP/1.3" /><br />                     <br />                     <br />    如上配置好后便可以用 <a href="https://localhost/">Https://localhost</a> 方式直接讉K,无需输入端口?</p> <p>三、参考资?br />   1. Keytool使用指南Q?br />     <a >http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/keytool.html</a><br />  <br />   2. tomcat-ssl配置指南Q?br />     <a >http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html</a><br />     <a >http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html</a></p> <img src ="http://www.aygfsteel.com/sealyu/aggbug/309264.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sealyu/" target="_blank">seal</a> 2010-01-13 08:29 <a href="http://www.aygfsteel.com/sealyu/archive/2010/01/13/309264.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何I过防火墙调用JBoss(?http://www.aygfsteel.com/sealyu/archive/2009/10/29/300136.htmlsealsealThu, 29 Oct 2009 02:19:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/10/29/300136.htmlhttp://www.aygfsteel.com/sealyu/comments/300136.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/10/29/300136.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/300136.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/300136.html1.首先修改jboss-service.xmlQ在ejb端口1098附近Q修改CallByValuegؓ(f)true
<attribute name="CallByValue">true</attribute>

2.然后修改ejb3.deployer中jboss-service.xml文gQ主要是d域名?873的调用中
   <mbean code="org.jboss.remoting.transport.Connector"
          xmbean-dd="org/jboss/remoting/transport/Connector.xml"
          name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
      <depends>jboss.aop:service=AspectDeployer</depends>
      <attribute name="Configuration">
    <config>
     <invoker transport="socket">
     <attribute name="numAcceptThreads">1</attribute>
     <attribute name="maxPoolSize">300</attribute>
     <attribute name="clientMaxPoolSize" isParam="true">50</attribute>
     <attribute name="timeout" isParam="true">60000</attribute>
     <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
     <attribute name="serverBindPort">3873</attribute>
     <!-- that's the important setting -->
     <attribute name="clientConnectAddress">10.104.46.119</attribute>
     <attribute name="clientConnectPort">3873</attribute>
     <attribute name="backlog">200</attribute>
     </invoker>
     <handlers>
     <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
     </handlers>
    </config>
      </attribute>
   </mbean>

3.讄java启动选项Q添加rmi-server的外部地址和禁用本地域名解析到启动脚本
Windows脚本例:(x)set JAVA_OPTS=-Djava.rmi.server.hostname= external IP -Djava.rmi.server.useLocalHostname=false
Unix脚本例:(x)d到jboss启动配置文grun.conf中即可?/p>

4.用run.sh --host=192.168.1.25启动服务或添?-host=192.168.1.25到启动脚本?/p>

1.在?span style="background-color: #ffff00;">Jboss 4.2GA 遇到的问? 以下是以default 模式启动?span style="background-color: #ffff00;">Jboss .启动参数 -c default /all
(1). localhost可以讉K与本机IP不能讉K
解决方式Q?
修改JBOSS_HOME"server"default"deploy"jboss-web.deployer下的server.xml address改ؓ(f)0.0.0.0或者你的实际IP 重启 JBOSS 然后可以通过ip讉K?/p>

(3)在windows 客户端调?Linux 服务?遇到org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://127.0.0.1:3873/]
解决Ҏ(gu): 修改 JBOSS_HOME/server/default/deploy/ejb3.deployer/META-INF/jboss-services.xml 文g中的${jboss.bind.address}:3873 为linux_home_ip:3873

以上两个问题也可以通过以下讄解决Q?
For Windows, use
run.bat -b 0.0.0.0

for Linux use
run.sh -b 0.0.0.0



seal 2009-10-29 10:19 发表评论
]]>
tomcat错误QSetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to xxxxhttp://www.aygfsteel.com/sealyu/archive/2009/10/20/299061.htmlsealsealTue, 20 Oct 2009 08:44:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/10/20/299061.htmlhttp://www.aygfsteel.com/sealyu/comments/299061.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/10/20/299061.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/299061.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/299061.html
<Context docBase="..." path="/cont" source="org.eclipse.jst.j2ee.server:*"/>

解决Ҏ(gu)是在Server的配|界面中选中"Publish module contexts to separate XML files"选项?

seal 2009-10-20 16:44 发表评论
]]>
JBOSSl护l验Q{Q?/title><link>http://www.aygfsteel.com/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.aygfsteel.com/sealyu/archive/2009/09/22/296024.html</guid><wfw:comment>http://www.aygfsteel.com/sealyu/comments/296024.html</wfw:comment><comments>http://www.aygfsteel.com/sealyu/archive/2009/09/22/296024.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sealyu/comments/commentRss/296024.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/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">q设|环境变?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: 宋体;">q行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: 宋体;">–u 229.12.12.12</span><span style="font-size: 10.5pt; font-family: 宋体;">&</span></p> <p style="margin: 0cm 0cm 6pt;"><span style="font-size: 10.5pt; font-family: 宋体;">参数说明Q?/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: 宋体;">指定q行的配|,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: 宋体;">指定服务l定的IP地址Q即对外服务的IP地址Q?.0.0.0表示Ҏ(gu)器上所有的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: 宋体;">指定服务使用的UDPl播地址</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">~写脚本内容如下Q?/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;"> </span><span style="font-size: 12pt; line-height: 150%; font-family: 宋体;"> </span><span style="line-height: 150%; font-family: 宋体;">安装好j(lu)bossq启动jboss后,在浏览器H口的地址栏里键入 http://localhost:8080/jmx-console</span><span style="line-height: 150%; font-family: 宋体;">Qjboss默认的端口号?080,可以自定义修改)(j)?/span><span style="line-height: 150%; font-family: 宋体;">可以浏?jboss的部|管理的一些信息,默认情况下不键入M用户名和密码可以进入此面Q方便是方便Q但真正使用hq是有点安全隐?zhn)Q因ZQ何h只要知道server的ip 都可以进去访问。下面我们针Ҏ(gu)问题对jbossq行配置Q得访问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: 宋体;"> 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: 宋体;"> 1. </span><span style="line-height: 150%; font-family: 宋体;">q入jmx-console.warQ通常此目录在$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: 宋体;"> 2. </span><span style="line-height: 150%; font-family: 宋体;">~辑该目录下?WEB-INF/web.xmlQ把<security-constraint>部分注释L 3.</span><span style="line-height: 150%; font-family: 宋体;">~辑$jboss_home/server/vcom/conf/props目录下的jmx-console-roles.properties和jmx-console-users.propertiesQ?/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: 宋体;">       1) users.properties</span><span style="line-height: 150%; font-family: 宋体;">文g里定义用户名和密码,格式为username=password。可以依照此格式d多个用户?</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: 宋体;">文g里定义用户名和角Ԍ格式为username=role。这里的role必须和web.xml文g里的<role-name>相对应?</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文gQ打开<security-domain>部分注释Q这?lt;security- domain>内容对应的security-domain对应$jboss_home"server"vcom"conf"login-config.xmlq个jaas配置文g里的某个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: 宋体;"><security-domain>java:/jaas/jmx-console</security-domain> <br /> </span><span style="line-height: 150%; font-family: 宋体;">在login-config.xml里对应有Q?/span></font></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"><application-policy name = "jmx-console"> </font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"><authentication> </font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"><login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag = "required" /> </font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"></authentication> </font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"></application-policy> </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: 宋体;">Q重启jbossQ在览器中键入控制台地址Q就?x)出现输入username和password的提C窗口?</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>,使用名ؓ(f)jboss.cache:service=TomcatClustering MBean Members可以查看当前机群节点成员信息Q用jboss.cache:service=TomcatClusteringQ可以看到当前集的节点ip,在member 一中Q可以观察到当前集群中节点ip,如图Q?/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() </span><span style="font-family: 宋体;">Q?/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: 宋体;">操作Q点击invokeQ可以对session复制q行监控?/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: 宋体;">目前应用使用的数据库q接是应用程序自带的JDBC QAPIQ接口,配置如下Q?/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: 宋体;"> <</span><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">?xml version="1.0" encoding="UTF-8"?></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: 宋体;"><datasource></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: 宋体;"> <proxool></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: 宋体;">    <alias>pool</alias></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: 宋体;">    <driver-url>jdbc:oracle:thin:@192.168.104.32:1521:cportal</driver-url></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: 宋体;">    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class></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: 宋体;">    <driver-properties></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: 宋体;">      <property name="user" value="cportal"/></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: 宋体;">      <property name="password" value="cportal"/></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: 宋体;">    </driver-properties></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: 宋体;">    <house-keeping-sleep-time>30000</house-keeping-sleep-time></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: 宋体;">    <minimum-connection-count>0</minimum-connection-count></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: 宋体;">    <maximum-connection-count>300</maximum-connection-count></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: 宋体;">    <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql></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: 宋体;"> </proxool></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: 宋体;"></datasource></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: 宋体;">Qoracle服务端口?521Qcportal为数据库的实例名即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: 宋体;"><property name="user" value="cportal"/></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;"> <property name="password" value="cportal"/> </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: 宋体;">Q?Q?/span><font face="宋体"><maximum-connection-count>300</maximum-connection-count><span style="font-family: 宋体;">为客L(fng)</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中间件时,默认的访问端口是8080Q可以修攚w你想使用的端口,修改步骤如下Q?/font><br /> <font size="3">打开JBOSS目录$JBOSS_HOME/server/vcom/deploy/jboss-web.deployer/下的server.xml文g,搜烦(ch)8080,?080改ؓ(f)新的端口?保存文g,重启应用服务器即?讉K时用新的端口号</font><font size="3">. <br /> <Connector port="80" address="${jboss.bind.address}"    </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">         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">         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">         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">         connectionTimeout="20000" disableUploadTimeout="true" /></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中启动的最大线E数Q?00 为JVM辑ֈ最大线E阀值时Q可以放在队列中的HTTPh?/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-consoleQ?/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的系l资源,如:(x)jboss的基本配|情况,jvm的利用率Q线E池的用情况,可以使用web-consoleq行监控?/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="宋体">具体Ҏ(gu)同jmx-consoleQ就是位|不同,具体Ҏ(gu)参考jmx-console配置Q?/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;">· </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;">· </span><font size="3"><span style="font-family: 宋体;">login-config.xml</span><span style="font-family: 宋体;">q是原来的那个,把application-policy名ؓ(f)$webConsoleDomain的部分改成你需要的web-consoleQ?/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;">· </span><font size="3"><span style="font-family: 宋体;">web-console-users.properties</span><span style="font-family: 宋体;">、web-console-roles.properties定义?jin)访?web-console的用戗用戯Ԍ具体位置自己LQ用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应用模块的负载分担情况,q可以查看到当前JAVA虚拟机的内存使用情况Q及(qing)U程池用情c(din)?/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>Q可以进一步监控到每个U程的状态?/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: 宋体;">pȝ日志分析</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是用来记录JBOOSq行q程的日志记?boot.log用来记录JBOOS启动信息的,出现问题时可以通过sever.log对jbossq行分析?/span></font></p> <h2 style="margin: 13pt 0cm;"><span style="font-size: 15pt; line-height: 173%; font-family: 宋体;"> 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.xmlQ可以对日志的来源和U别q行定义Q也可以定义日志的记录方式?/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注释掉,pȝq行时会(x)在log目录下生cluster.log文gQ可以通过此文件对集群故障q行分析。在试调试q程可以使用此日?/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: 宋体;">日志记录方式?U:(x)</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">1Q?/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;">              </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">2Q?/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;">              </span></span><span style="line-height: 150%; font-family: 宋体;"><font size="3">按日志文件的大小q行记录</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">目前使用的是按照大小信息记录。如果要修改记录方式Q直接编辑jboss-log4j.xml文gQ将此段注释L?/font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"><!-- A time/date based rolling appender --></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">   <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender"></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">      <param name="File" value="${jboss.server.log.dir}/server.log"/></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">      <param name="Append" value="false"/></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"> </font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">      <!-- Rollover at midnight each day --></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">      <param name="DatePattern" value="'.'yyyy-MM-dd"/></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"> </font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">      …………………………………………………</font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">……………………………………………………………………….</font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">      </layout></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">   </appender></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: 宋体;">同时下D|释掉</span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"><!-- A size based file rolling appender--></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">   <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender"></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">     <param name="File" value="${jboss.server.log.dir}/server.log"/></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">     <param name="Append" value="false"/></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">     <param name="MaxFileSize" value="500KB"/></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">     <param name="MaxBackupIndex" value="1"/></font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3"> ……………………………………………………………</font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">…………………………………………………………</font></span></p> <p style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-family: 宋体;"><font size="3">     </layout></font></span></p> <p style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">   </appender></span></font></p> <font size="3"><span style="font-family: 宋体;">下?/span></font> <img src ="http://www.aygfsteel.com/sealyu/aggbug/296024.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sealyu/" target="_blank">seal</a> 2009-09-22 14:48 <a href="http://www.aygfsteel.com/sealyu/archive/2009/09/22/296024.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Seam 目部v?tomcat ??http://www.aygfsteel.com/sealyu/archive/2009/08/26/292632.htmlsealsealWed, 26 Aug 2009 04:36:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/08/26/292632.htmlhttp://www.aygfsteel.com/sealyu/comments/292632.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/08/26/292632.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/292632.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/292632.html JBoss Tools 生成?nbsp;Seam 目Q新建项目时Q服务器选择 tomcatQ,?x)生成一些必要的文gQ如Q连接数据库的数据源文gQ如Q?/font>project-ds.xml Q但它只能在 Jboss as 的环境中q行Q不适用?nbsp;tomcatQ,要想很我们的目Q?/font>warQ运行于 tomcat 中的Q我们得对它自动生成的文件做一些必要的修改?/font>

      一?span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">修改数据库的q接方式

         1、采用数据源的Ş?br />             ?nbsp;tomcat 中配|数据源方式如下:
            
在生成的目同目录中找此文Ӟ(x) context.xml 
                     
Servers/Tomcat 。。?/font>/context.xml  作如下配|:(x)
            
在标{?nbsp;<Context> 中间加入:
            <Resource  
                  
name="jdbc/demo" auth="Container" type="javax.sql.DataSource" 
                  
maxActive="30" maxIdle="5" maxWait="10000" username="root" 
                  
password="admindriverClassName="com.mysql.jdbc.Driver" 
                  
url="jdbc:mysql://localhost:3306/demo?useUnicode=true&amp;characterEncoding=UTF-8">

          </Resource>          

         2?span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">使用非数据源的Ş?br />             在文Ӟ(x)persistence.xml 中添?/font>hibernate 的连接数据库的方式,如下Q?br />               <property name="hibernate.connection.username" value="root"/>
            
<property name="hibernate.connection.password" value="admin"/>
            
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            <property name="hibernate.connection.url" 
                  
value="jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-8"/>

      二?span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">修改 JPA 配置文g persistence.xml

          1?/span>如果数据的连接方式采用数据源的Ş式,则只需修改里面数据源的名称Q如Q?br />             <jta-data-source>java:comp/env/jdbc/demo</jta-data-source>

          2、如果采?font face="Times New Roman">hibernate 的连接方式,则把此行删了(jin)?/font>        

          3?span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">删除里面的此行配|:(x)
             <property name="hibernate.transaction.manager_lookup_class" 
                  value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

          4、修改事务的{略方式?RESOURCE_LOCAL Q?nbsp;

            <persistence-unit name="demo" transaction-type="RESOURCE_LOCAL">

      三?span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">配置 Seam 的事务管理器
          ?nbsp;component.xml 文g加入Q?br />           <transaction:entity-transaction entity-manager="#{entityManager}"/>
         默认生成的此文g是不含有 transaction 的命名空_(d)需要手动在此文件加入它的命名空_(d)(x)

          xmlns:transaction=http://jboss.com/products/seam/transaction
         http://jboss.com/products/seam/transaction 
         http://jboss.com/products/seam/transaction-2.1.xsd

      四?span style="font-weight: normal; font-size: 10.5pt; font-family: '宋体';">为此目加入必要的依赖包 。。。。。?/span>



seal 2009-08-26 12:36 发表评论
]]>
JBoss中的TransactionTimeOut的设|?/title><link>http://www.aygfsteel.com/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.aygfsteel.com/sealyu/archive/2009/05/18/271239.html</guid><wfw:comment>http://www.aygfsteel.com/sealyu/comments/271239.html</wfw:comment><comments>http://www.aygfsteel.com/sealyu/archive/2009/05/18/271239.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sealyu/comments/commentRss/271239.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sealyu/services/trackbacks/271239.html</trackback:ping><description><![CDATA[q两天在作seam的时候不旉?#8220;org.jboss.util.NestedSQLException: Transaction is not active”的错误信息,后来到jboss的wiki上发C(jin)问题的原因和解决Ҏ(gu)Q?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(<=4.0.5) or JBossJTA-Arjuna(>=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 <= 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;"><transaction-timeout></span> element inside the <method> 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.aygfsteel.com/sealyu/aggbug/271239.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sealyu/" target="_blank">seal</a> 2009-05-18 10:01 <a href="http://www.aygfsteel.com/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.pathhttp://www.aygfsteel.com/sealyu/archive/2009/04/11/265054.htmlsealsealSat, 11 Apr 2009 14:22:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/04/11/265054.htmlhttp://www.aygfsteel.com/sealyu/comments/265054.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/04/11/265054.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/265054.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/265054.html

P1:Tomcat6启动的时候出C面这L(fng)提示Q?/p>

2007-12-31 9:51:51 org.apache.catalina.core.AprLifecycleListener init
信息: 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;

S1:实际q是使用apache的apr;apr 是apache portable runtime 用上q个后可以有效的提高tomcat处理?rn)态页面的能力.如果想用apr的话Q?实际操作很简单,

下蝲 http://tomcat.heanet.ie/native/1.1.1/binaries/win32/tcnative-1.dll

这个文件复制到C:\WINDOWS\system32\下面,然后重新启动tomcatQ就?x)发现tomcat 的控制台信息为:(x)
2007-12-31 9:55:40 org.apache.catalina.core.AprLifecycleListener init
信息: An older version 1.1.8 of the Apache Tomcat Native library is installed, while Tomcat recommends version greater then 1.1.10
2007-12-31 9:55:40 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded Apache Tomcat Native library 1.1.8.



seal 2009-04-11 22:22 发表评论
]]>
JBosscd载配|属?UseJBossWebLoaderhttp://www.aygfsteel.com/sealyu/archive/2009/02/24/256392.htmlsealsealTue, 24 Feb 2009 02:25:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/02/24/256392.htmlhttp://www.aygfsteel.com/sealyu/comments/256392.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/02/24/256392.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/256392.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/256392.htmlSee ClassLoadingConfiguration.

Available option in deploy/jbossweb-tomcat.sar/META-INF/jboss-service.xml

or deploy/jboss-web.deployer/META-INF/jboss-service.xml

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.

Example

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.

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.

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.



seal 2009-02-24 10:25 发表评论
]]>
How to use Django with Apache and mod_pythonhttp://www.aygfsteel.com/sealyu/archive/2008/11/07/239347.htmlsealsealFri, 07 Nov 2008 15:44:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/11/07/239347.htmlhttp://www.aygfsteel.com/sealyu/comments/239347.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/11/07/239347.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/239347.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/239347.htmlApache with mod_python currently is the preferred setup for using Django on a production server.

mod_python is similar to (and inspired by) mod_perl : 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.

Django requires Apache 2.x and mod_python 3.x, and you should use Apache’s prefork MPM, as opposed to the worker MPM.

You may also be interested in How to use Django with FastCGI, SCGI or AJP (which also covers SCGI and AJP).

Basic configuration

To configure Django with mod_python, first make sure you have Apache installed, with the mod_python module activated.

Then edit your httpd.conf file and add the following:

<Location "/mysite/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
</Location>

...and replace mysite.settings with the Python import path to your Django project's settings file.

This tells Apache: "Use mod_python for any URL at or under '/mysite/', using the Django mod_python handler." It passes the value of DJANGO_SETTINGS_MODULE so mod_python knows which settings to use.

New in Django 1.0: The PythonOption django.root ... is new in this version.

Because mod_python does not know we are serving this site from underneath the /mysite/ prefix, this value needs to be passed through to the mod_python handler in Django, via the PythonOption django.root ... line. The value set on that line (the last item) should match the string given in the <Location ...> directive. The effect of this is that Django will automatically strip the /mysite string from the front of any URLs before matching them against your URLConf patterns. If you later move your site to live under /mysite2, you will not have to change anything except the django.root option in the config file.

When using django.root 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 /mysite/admin/ to /admin/, we need to remove the string /mysite from the beginning, so that is the django.root value. It would be an error to use /mysite/ (with a trailing slash) in this case.

Note that we're using the <Location> directive, not the <Directory> directive. The latter is used for pointing at places on your filesystem, whereas <Location> points at places in the URL structure of a Web site. <Directory> would be meaningless here.

Also, if your Django project is not on the default PYTHONPATH for your computer, you'll have to tell mod_python where your project can be found:

<Location "/mysite/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/path/to/project'] + sys.path"
</Location>

The value you use for PythonPath 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 DJANGO_SETTINGS_MODULE 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 sys.path in turn, from first to last, and try to import from each directory until one succeeds.

An example might make this clearer. Suppose you have some applications under /usr/local/django-apps/ (for example, /usr/local/django-apps/weblog/ and so forth), your settings file is at /var/www/mysite/settings.py and you have specified DJANGO_SETTINGS_MODULE as in the above example. In this case, you would need to write your PythonPath directive as:

PythonPath "['/usr/local/django-apps/', '/var/www'] + sys.path"

With this path, import weblog and import mysite.settings will both work. If you had import blogroll in your code somewhere and blogroll lived under the weblog/ directory, you would also need to add /usr/local/django-apps/weblog/ to your PythonPath. Remember: the parent directories of anything you import directly must be on the Python path.

Note

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.)

This is valid even on a Windows system:

PythonPath "['c:/path/to/project'] + sys.path"

You can also add directives such as PythonAutoReload Off for performance. See the mod_python documentation for a full list of options.

Note that you should set PythonDebug Off on a production server. If you leave PythonDebug On, your users would see ugly (and revealing) Python tracebacks if something goes wrong within mod_python.

Restart Apache, and any request to /mysite/ or below will be served by Django. Note that Django's URLconfs won't trim the "/mysite/" -- they get passed the full URL.

When deploying Django sites on mod_python, you'll need to restart Apache each time you make changes to your Python code.

Multiple Django installations on the same Apache

It's entirely possible to run multiple Django installations on the same Apache instance. Just use VirtualHost for that, like so:

NameVirtualHost *

<VirtualHost *>
ServerName www.example.com
# ...
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
</VirtualHost>

<VirtualHost *>
ServerName www2.example.com
# ...
SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings
</VirtualHost>

If you need to put two Django installations within the same VirtualHost (or in different VirtualHost 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 PythonInterpreter directive to give different <Location> directives separate interpreters:

<VirtualHost *>
ServerName www.example.com
# ...
<Location "/something">
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonInterpreter mysite
</Location>

<Location "/otherthing">
SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings
PythonInterpreter othersite
</Location>
</VirtualHost>

The values of PythonInterpreter don't really matter, as long as they're different between the two Location blocks.

Running a development server with mod_python

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 MaxRequestsPerChild 1 in your httpd.conf 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.

If you're the type of programmer who debugs using scattered print statements, note that print 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:

assert False, the_value_i_want_to_see

Or add the debugging information to the template of your page.

Serving media files

Django doesn't serve media files itself; it leaves that job to whichever Web server you choose.

We recommend using a separate Web server -- i.e., one that's not also running Django -- for serving media. Here are some good choices:

If, however, you have no option but to serve media files on the same Apache VirtualHost as Django, here's how you can turn off mod_python for a particular part of the site:

<Location "/media">
SetHandler None
</Location>

Just change Location to the root URL of your media files. You can also use <LocationMatch> to match a regular expression.

This example sets up Django at the site root but explicitly disables Django for the media subdirectory and any URL that ends with .jpg, .gif or .png:

<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
</Location>

<Location "/media">
SetHandler None
</Location>

<LocationMatch "".(jpg|gif|png)$">
SetHandler None
</LocationMatch>

Serving the admin files

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.

The admin files live in (django/contrib/admin/media) of the Django distribution.

Here are two recommended approaches:

  1. Create a symbolic link to the admin media files from within your document root. This way, all of your Django-related files -- code and templates -- stay in one place, and you'll still be able to svn update your code to get the latest admin templates, if they change.
  2. Or, copy the admin media files so that they live within your Apache document root.

Using "eggs" with mod_python

If you installed Django from a Python egg 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:

import os
os.environ['PYTHON_EGG_CACHE'] = '/some/directory'

Here, /some/directory 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.

Then you have to tell mod_python to import this file before doing anything else. This is done using the PythonImport directive to mod_python. You need to ensure that you have specified the PythonInterpreter directive to mod_python as described above (you need to do this even if you aren't serving multiple installations in this case). Then add the PythonImport line in the main server configuration (i.e., outside the Location or VirtualHost sections). For example:

PythonInterpreter my_django
PythonImport /path/to/my/project/file.py my_django

Note that you can use an absolute path here (or a normal dotted import path), as described in the mod_python manual. 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 PythonImport line is processed.

Error handling

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 error_log.

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 error_log file. The error_log traceback is spread over multiple lines. (Yes, this is ugly and rather hard to read, but it's how mod_python does things.)

If you get a segmentation fault

If Apache causes a segmentation fault, there are two probable causes, neither of which has to do with Django itself.

  1. 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 Expat Causing Apache Crash.
  2. 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 mod_python FAQ entry.

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. Getting mod_python Working details this procedure.

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.



seal 2008-11-07 23:44 发表评论
]]>
Apache + Tomcat 配置多个应用http://www.aygfsteel.com/sealyu/archive/2008/08/25/224326.htmlsealsealMon, 25 Aug 2008 15:14:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/08/25/224326.htmlhttp://www.aygfsteel.com/sealyu/comments/224326.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/08/25/224326.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/224326.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/224326.html 刚开始在同一个tomcat中配|了(jin)多个应用Q后来感觉效果不好,改ؓ(f)每个tomcat对应一个应用。搜索资料如下:(x)
apache2.2与tomcat集成(可以多个tomcat)
1. 安装apache2.2 参见Q?a target="_blank">http://ttitfly.javaeye.com/admin/show/127337

2.需求概况:(x)
?个服务:(x)www.test.com, bbs.test.com。分别对?个tomcat下的2个web应用。由apache httpd作ؓ(f)互联|接入服务器Q在80端口接收对这2个服务的h?span class="hilite1">apache httpd再将q?个请求分别对应到不同的后端web服务?Tomcat)处理?

3.配置域名映射到本机即127.0.0.1Q同旉|service域名

  1. 127.0.0.1    localhost www.test.com www.service.test.com bbs.test.com bbs.service.test.com  


4. 分别?个tomcat里分别部|一个非常简单的应用?

W一个tomcat Q端?8080

~辑$TOMCAT_HOME/conf/server.xml

d一个Host
<Host name="www.service.test.com" unpackWARs="true" autoDeploy="true"  
  1. xmlValidation="false" xmlNamespaceAware="false"/>  


再在$TOMCAT_HOME/conf/Catalina下徏立一个目?www.service.test.com
然后在www.service.test.com目录下徏立一个ROOT.xml,内容为:(x)
 
  1. <Context docBase="/home/mahaibo/app/test"  
  2. privileged="true" antiResourceLocking="false" antiJARLocking="false">   
  3. </Context>  

docBase指向具体的项目\?/span>

同理W二个tomcatQ端?088Q也是一L(fng)做法Q?

~辑$TOMCAT_HOME/conf/server.xml

d一个Host:
 
  1. <Host name="bbs.service.test.com" unpackWARs="true" autoDeploy="true"  
  2. xmlValidation="false" xmlNamespaceAware="false"/>  



然后?TOMCAT_HOME/conf/Catalina下徏立一个目?bbs.service.test.com

再在bbs.service.test.com目录下徏立一个ROOT.xml,内容为:(x)
 
  1. <Context docBase="/home/mahaibo/app/bbs"  
  2. privileged="true" antiResourceLocking="false" antiJARLocking="false">   
  3. </Context>  


5. 分别启动tomcatQ可以通过http://www.service.test.com:8080和http://bbs.service.test.com:8088讉K

6. 配置apache httpd.conf文g?

扑ֈapach/conf/httpd.conf文gQ确认下面这些文字行前面没有"#"注释P(x)

 
  1. LoadModule proxy_module modules/mod_proxy.so   
  2. LoadModule proxy_ajp_module modules/mod_proxy_ajp.so   
  3. LoadModule proxy_balancer_module modules/mod_proxy_balancer.so   
  4. LoadModule proxy_connect_module modules/mod_proxy_connect.so   
  5. LoadModule proxy_http_module modules/mod_proxy_http.so   
  6. LoadModule proxy_ftp_module modules/mod_proxy_ftp.so  


q增加虚拟主机配|:(x)
 
  1. NameVirtualHost *:80  
  2. <VirtualHost *:80>   
  3. ServerName www.test.com   
  4. ProxyIOBufferSize 8192  
  5. ProxyRequests Off   
  6. ProxyVia Full   
  7. ProxyPass / http://www.service.test.com:8080/ smax=5 max=20 ttl=120 retry=300   
  8. </VirtualHost>   
  9.   
  10. <VirtualHost *:80>   
  11. ServerName bbs.test.com   
  12. ProxyIOBufferSize 8192  
  13. ProxyRequests Off   
  14. ProxyVia Full   
  15. ProxyPass / http://bbs.service.test.com:8088/ smax=5 max=20 ttl=120 retry=300   
  16. </VirtualHost>  


7.启动apache
 
  1. ./<SPAN class=hilite1>apache</SPAN>ctl start  



8 可以通过讉Khttp://www.test.com和http://bbs.test.com来分别访?个不同tomcat下的不同应用?jin)?br />  



apache+tomcat配置负蝲均衡的网?

1.   目标

使用 apache ?/span> tomcat 配置一个可以应用的 web |站Q要辑ֈ以下要求Q?/span>

1?nbsp;Apache 做ؓ(f) HttpServer Q后面连接多?/span> tomcat 应用实例Qƈq行负蝲均衡?/span>

2?nbsp;为系l设?/span> Session 时旉Q包?/span> Apache ?/span> tomcat

3?nbsp;为系l屏蔽文件列表,包括 Apache ?/span> tomcat

2.   安装 tomcat

2.1. 下蝲Q解?/span> tomcat

不要下蝲安装?/span> , 下蝲地址

http://tomcat.apache.org

2.2. 配置 tomcat

2.2.1.     配置 server 的关闭口

我们需要在一台机器上?/span> 2 个不同的 tomcat Q需要修改不同的 tomcat 的关闭口Q避免出现端口被占用的情c(din)在 server.xml 中找?/span> server, :(x)

<Server port="8005" shutdown="SHUTDOWN">

改ؓ(f)

<Server port="XXXX" shutdown="SHUTDOWN">

XXXX 在这里表CZ同的端口Q我的两?/span> tomcat 分别使用 8035 Q?/span> 8045

注意Q这里之所以要配置不同?/span> tomcat 关闭口,只是因ؓ(f)我们使用?jin)多?/span> tomcat Q其实用一?/span> server 多个实例也可以?/span>

2.2.2.     配置 service

我们需要对不同?/span> tomcat ?/span> service 取不同的名字Q在 server.xml 中找刎ͼ(x)

<Service name="Catalina">

改ؓ(f)Q?/span>

<Service name="XXXX">

两个 service 分别?/span> tomcat6 ?/span> tomcat5

2.2.3.     配置 Connector

q个部分主要是要改两?/span> Connector Q当然前提是你的 tomcat 只有两个 Connector ?/span>

修改 ajp1.3 的端口:(x)

扑ֈQ?/span> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

改ؓ(f)Q?/span> <Connector port="XXXX" protocol="AJP/1.3" redirectPort="8443" />

两个 Service ?/span> ajp/1.3 的端口分别ؓ(f)Q?/span> 8019 Q?/span> 8029

修改 http 的端口:(x)

扑ֈQ?/span>

<Connector port="8080" protocol="HTTP/1.1"

               maxThreads="150" connectionTimeout="20000"

               redirectPort="8443" />

改ؓ(f)Q?/span>

<Connector port="XXXX" protocol="HTTP/1.1"

               maxThreads="150" connectionTimeout="20000"

               redirectPort="8443" />

两个 Service ?/span> ajp/1.3 的端口分别ؓ(f)Q?/span> 8060 Q?/span> 8070

2.2.4.     配置 Engine

Engine 主要是配|?/span> jvmRoute 属性,扑ֈQ?/span>

<Engine name="Catalina" defaultHost="localhost">

改ؓ(f)Q?/span>

<Engine jvmRoute="XXXX" name="Catalina" defaultHost="localhost">

两个实例分别为:(x) tomcat6 ?/span> tomcat5.

2.2.5.     配置公用?/span> Context

如果?/span> Context 是多个系l公用的Q比如图片等的存攑֜Q可以做个配|:(x)

?/span> Host 中增加:(x)

<Context path="/image" docBase="D:"webRoot"image" debug="0" reloadable="false" crossContext="true">

</Context>

2.2.6.     屏蔽文g列表

打开 tomcat 目录下的 conf/web.xml Q?/span>

扑ֈQ?/span>

<servlet>

        <servlet-name>default</servlet-name>

        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>

        <init-param>

            <param-name>debug</param-name>

            <param-value>0</param-value>

        </init-param>

        <init-param>

            <param-name>listings</param-name>

            <param-value>true</param-value>

        </init-param>

        <load-on-startup>1</load-on-startup>

    </servlet>

?/span> listings 参数改ؓ(f) false;

2.3. 配置应用 (web.xml)

对系l应用做些控制?/span>

配置 session q期旉Q大多数|站用户都只是做些浏览性的操作Qؓ(f)?jin)减L务器负蝲压力Q我们将 session 时旉从默认的 30 分钟变ؓ(f) 5 分钟?/span>

?/span> web 应用E序?/span> web.xml ?/span> servlet-mapping 之后增加如下一D:(x)

<session-config>

    <session-timeout>5</session-timeout>

</session-config>

3.   安装 Apache

3.1. 下蝲、安?/span> Apache

下蝲地址 http://httpd.apache.org/download.cgi

下蝲后点d?/span> msi 文g?/span>

安装的时候没有什么特别需要注意的地方Q按照默认就行了(jin)。是否安装ؓ(f) service 看具体情况而定?/span>

3.2. 下蝲、安?/span> Apache ?/span> tomcat ?/span> Connector

http://tomcat.apache.org/download-connectors.cgi

注意Q很多网站上都介l是 JK2 Q可能是觉得 JK2 ?/span> JK 要新吧,其实 JK2 已经停止研发?jin),使?/span> jk1.2 ?/span>

下蝲压羃包,之后?/span> module 目录中的 mod_jk-apache****.so 文g攑օ /module/ 目录下?/span>

3.3. 配置 Apache Q?/span> httpd.conf Q?/span>

3.3.1.     配置端口Q?

扑ֈ

Listen 80

改ؓ(f)

Listen **

当然如果不需要改的话Q就不用改了(jin)。正常情冉|L攏V?/span>

3.3.2.     配置 DocumentRoot

扑ֈ DocumentRoot D,其改ؓ(f)Q?/span>

DocumentRoot "E:/MyWebsite"

q里?/span> "E:/MyWebsite" 指的是你?/span> web E序的根路径Q视具体应用而定?/span>

3.3.3.     配置 serverName

扑ֈ serverName q个D,其配置Z?/span> ServerName

如果没有配置为域名,配ؓ(f) IP 也可以,此处q不是很清楚Q多虚拟L的情늚配置?/span>

3.3.4.     配置虚拟L

<VirtualHost *:80>

    ServerAdmin flyffa@gmail.com

    DocumentRoot       E:/MyWebsite

    ServerName localhost

    DirectoryIndex index.html index.htm index.jsp

    ErrorLog logs/error_log

    CustomLog logs/access_log common

    ErrorDocument 404 /sys/logon.jsp

</VirtualHost>

3.4. 配置 JK 方式的负载均?/span>

3.4.1.     配置 module

我们需要与 tomcat 做连接,所以要?/span> tomcat ?/span> connector 的模块配|进厅R?/span>

?/span> LoadModule 部分加入Q?/span>

LoadModule jk_module modules/mod_jk-apache-2.0.55.so Q加载模?/span>

q个 so 是我下蝲的版本,个h可以Ҏ(gu)自己下蝲的文件名加以配置

JkWorkersFile conf/workers.properties Q指?/span> connector 的配|文件名U?/span>

JkLogFile logs/mod_jk.log Q指?/span> connector 的日志文件名U?/span>

JkLogLevel info Q指?/span> connector 的日志等U?/span>

3.4.2.     配置 worker 列表 (conf/workers.properties)

定义列表

worker.list=tomcat6,tomcat5,loadbalancer

定义一个名?/span> “loadbalancer” ?/span> worker

其作为对多个 Tomcat q程的负载^衡用:(x)

worker.loadbalancer.type=lb

worker.loadbalancer.balanced_workers=tomcat5, tomcat6

Q?/span> 负蝲qcd?/span> worker q不?/span> Tomcat worker 通讯Q它负责理q些 Tomcat worker ?/span> Q?/span>

定义多个 worker 列表

# Set properties for tomcat6 (ajp13)

worker.tomcat6.type=ajp13

worker.tomcat6.host=localhost

worker.tomcat6.port=8019

worker.tomcat6.lbfactor=50

worker.tomcat6.cachesize=10

worker.tomcat6.cache_timeout=600

worker.tomcat6.socket_keepalive=1

worker.tomcat6.reclycle_timeout=300

# Set properties for tomcat5 (ajp13)

worker.tomcat5.type=ajp13

worker.tomcat5.host=localhost

worker.tomcat5.port=8029

worker.tomcat5.lbfactor=50

worker.tomcat5.cachesize=10

worker.tomcat5.cache_timeout=600

worker.tomcat5.socket_keepalive=1

worker.tomcat5.reclycle_timeout=300

注意Q?/span> lbfactor= 50 Q?/span> 当此 Tomcat worker 被用于一个负载^?/span> worker 使用Ӟ此属性将被用。它定义?jin)?/span> worker 的负载^衡权倹{?/span> Q?/span>

cachesize= 10 Q?/span> 当在多线E的 web server Q例?/span> apache2.0 ?/span> IIS ?/span> Netscape Q中使用 JK Ӟ此属性是有效的。如果将 cachesize 的D|ؓ(f)较高的|q些支持多线E的 web server 获得很好的处理能力。如果此属性不被设|,则连?/span> cache Ҏ(gu)将失效?/span> Q?/span>

3.4.3.     配置 Apache ?/span> tomcat 的桥?/span>

?/span> DocumnetRoot 片段下加?/span>

JkMount /*.jsp tomcat6

JkMount /*.do tomcat6

JkMount /*Servlet tomcat6

q里只是单的?/span> apache 的请求{到其中的一?/span> tomcat 中,形成桥接Q至于负载均衡的时候,无进行这步操作,直接启动负蝲均衡。启动负载均衡见下一节?/span>

3.4.4.     启动负蝲均衡

?/span> DocumnetRoot 片段下加?/span>

JkMount /*.jsp loadbalancer

JkMount /*.do loadbalancer

JkMount /*Servlet loadbalancer

Q指定对所有的h启动负蝲均衡Q这里的 loadbalancer ?span style="color: #ff6600">定义?/span> worker 的名?/span>

q里我在配置的时候犯?jin)两个错误?x)

W一是没有配|?/span> JkWorkersFile conf/workers.properties Q以?/span> Apache ?x)自动认识(其?/span> apache 是自动生了(jin)一个叫?/span> ajp13 ?/span> worker Q指向本机的 8009 端口Q?/span>

W二是以?/span> JkMount 语句中出?/span> loadbalancer,ajp13 之类的是pȝ讑֮的东西,其实都是?/span> workers.properties 文g中定义的Q结果出现名字不匚w的情c(din)后来配|了(jin) JkLogFile logs/mod_jk.log 之后看到错误日志才明白?/span>

3.5. 配置 Proxy 方式的负载均?/span>

使用 Apache2.1 以上的版本,可以用 mod_proxy_ajp 来完成负载均衡的配置Q不q到目前为止Q没有看到如何让 Apache 负责?rn)态部分, tomcat 负责动态部分的配置方式Q只能用 path q行区分分发h。如Q在虚拟L的配|中增加Q?/span>

ProxyPass / ajp://localhost:8019/

ProxyPassReverse / ajp://localhost:8019/

而Ş如:(x)

ProxyPass /*.jsp ajp://localhost:8019/

ProxyPassReverse /*.jsp ajp://localhost:8019/

q样的配|是不能通过的?/span>



seal 2008-08-25 23:14 发表评论
]]>
java.lang.OutOfMemoryError: PermGen space?qing)其解决?gu)http://www.aygfsteel.com/sealyu/archive/2008/08/25/224195.htmlsealsealMon, 25 Aug 2008 08:22:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/08/25/224195.htmlhttp://www.aygfsteel.com/sealyu/comments/224195.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/08/25/224195.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/224195.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/224195.html

1?br />

PermGen space的全U是Permanent Generation space,是指内存的永久保存区域OutOfMemoryError: PermGen space从表面上看就是内存益出,解决Ҏ(gu)也一定是加大内存。说说ؓ(f)什么会(x)内存益出Q这一部分用于存放Class和Meta的信?Class在被 Load的时候被攑օPermGen space区域Q它和和存放Instance的Heap区域不同,GC(Garbage Collection)不会(x)在主E序q行期对PermGen spaceq行清理Q所以如果你的APP?x)LOAD很多CLASS的话,很可能出现PermGen space错误。这U错误常见在web服务器对JSPq行pre compile的时候?/p> Ҏ(gu)Ҏ(gu)Q?Xms256m -Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256m

2?/p>

在tomcat中redeploy时出现outofmemory的错?

可以有以下几个方面的原因:

Q?使用?u>proxool,因ؓ(f)proxool内部包含?jin)一个老版本的cglib.

2, log4j,最好不?只用common-logging

3, 老版本的cglib,快点更新到最新版?/font>

Q,更新到最新的hibernate3.2

3?br />
q里以tomcat环境ZQ其它WEB服务器如jboss,weblogic{是同一个道理?br /> 一、java.lang.OutOfMemoryError: PermGen space

PermGen space的全U是Permanent Generation space,是指内存的永久保存区?
q块内存主要是被JVM存放Class和Meta信息?Class在被Loader时就?x)被攑ֈPermGen space?
它和存放cd?Instance)的Heap区域不同,GC(Garbage Collection)不会(x)在主E序q行期对
PermGen spaceq行清理Q所以如果你的应用中有很多CLASS的话,很可能出现PermGen space错误,
q种错误常见在web服务器对JSPq行pre compile的时候。如果你的WEB APP下都用了(jin)大量的第三方jar, 其大?br /> 过?jin)jvm默认的大?4M)那么׃(x)产生此错误信息了(jin)?br /> 解决Ҏ(gu)Q?手动讄MaxPermSize大小

修改TOMCAT_HOME/bin/catalina.sh
?#8220;echo "Using CATALINA_BASE:   $CATALINA_BASE"”上面加入以下行:(x)
JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m
Q将相同的第三方jar文gUȝ到tomcat/shared/lib目录下,q样可以辑ֈ减少jar 文档重复占用内存的目的?/p>

二、java.lang.OutOfMemoryError: Java heap space
Heap size 讄
JVM堆的讄是指javaE序q行q程中JVM可以调配使用的内存空间的讄.JVM在启动的时候会(x)自动讄Heap size的|
其初始空??Xms)是物理内存的1/64Q最大空?-Xmx)是物理内存的1/4。可以利用JVM提供?Xmn -Xms -Xmx{选项?br /> q行讄。Heap size 的大是Young Generation 和Tenured Generaion 之和?br /> 提示Q在JVM中如?8Q的旉是用于GC且可用的Heap size 不2Q的时候将抛出此异怿息?br /> 提示QHeap Size 最大不要超q可用物理内存的80Q,一般的要将-Xms?Xmx选项讄为相同,?Xmn?/4?Xmx倹{?
解决Ҏ(gu)Q手动设|Heap size
修改TOMCAT_HOME/bin/catalina.sh
?#8220;echo "Using CATALINA_BASE:   $CATALINA_BASE"”上面加入以下行:(x)
JAVA_OPTS="-server -Xms800m -Xmx800m   -XX:MaxNewSize=256m"

三、实例,以下l出1G内存环境下java jvm 的参数设|参考:(x)

JAVA_OPTS="-server -Xms800m -Xmx800m  -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true "


三、相兌?/p>

/show/3/7/20061112220131.htm

/show/3/7/20061112220054.htm

/show/3/7/20061112220201.htm

题外话:(x)l常看到|友抱怨tomcat的性能不如...Q不E_{,其实Ҏ(gu)W者几q的l验Q从"互联星空“到现在的房门户|,我们
均用tomcat作ؓ(f)WEB服务器,每天讉K量百万多Qtomcat仍然q行良好。徏议大家有问题多从自己E序入手Q多看看java的DOC文档
q详l了(jin)解JVM的知识。这样开发的E序才会(x)健壮?br />
延阅读Q?/span>

JVM 性能调整的一些基本概?/font>

apache+Tomcat负蝲q讄详解[转]

java - the Java application launcher

JVM调优[转]



seal 2008-08-25 16:22 发表评论
]]>
Redhat AS4使用jsvc~写tomcat自启动安全脚??http://www.aygfsteel.com/sealyu/archive/2008/08/18/222685.htmlsealsealMon, 18 Aug 2008 02:10:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/08/18/222685.htmlhttp://www.aygfsteel.com/sealyu/comments/222685.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/08/18/222685.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/222685.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/222685.html #cd /usr/local/xiaobai/apache-tomcat-5.5.20/bin
#tar xvfz jsvc.tar.gz
#cd jsvc-src
#sh support/buildconf.sh
#chmod 755 configure
#./configure --with-java=/usr/local/xiaobai/jdk1.5.0_09 (Ҏ(gu)你的JDK的位|?
#make

2、添加脚本让tomcat自动启动
#useradd tomcat5 d用户
#groupadd tomcat  dl?
#usermod -G tomcat tomcat5  把tomcat5加入tomcatl?

#chown -R tomcat5 /usr/local/xiaobai/apache-tomcat-5.5.20
讄用户tomcat5对tomcat的权?

#cp /usr/local/xiaobai/apache-tomcat-5.5.20/bin/jsvc-src/native/Tomcat5.sh /etc/init.d/tomcat
Ud文gtomcat5.sh?etc/init.d/里面q改名ؓ(f)tomcat

#chmod 755 /etc/init.d/tomcat
#vi /etc/init.d/tomcat

删除原有内容d如下内容

#!/bin/sh
#
# Startup Script for Tomcat5
#
# chkconfig: 345 88 14
# description: Tomcat Daemon
# processname: jsvc
# pidfile: /var/run/jsvc.pid
# config:
#
# Source function library.
. /etc/rc.d/init.d/functions
#
prog=tomcat
#
JAVA_HOME=/usr/local/xiaobai/jdk1.5.0_09
CATALINA_HOME=/usr/local/xiaobai/apache-tomcat-5.5.20
DAEMON_HOME=/usr/local/xiaobai/apache-tomcat-5.5.20/bin
#TOMCAT_USER=tomcat5
TOMCAT_USER=tomcat5

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/usr/local/xiaobai/apache-tomcat-5.5.20

CATALINA_OPTS=
CLASSPATH="
$JAVA_HOME/lib/tools.jar:"
$CATALINA_HOME/bin/commons-daemon.jar:"
$CATALINA_HOME/bin/bootstrap.jar

case "$1" in
start)
#
# Start Tomcat
#
$DAEMON_HOME/jsvc-src/jsvc "
-user $TOMCAT_USER "
-home $JAVA_HOME "
-Dcatalina.home=$CATALINA_HOME "
-Dcatalina.base=$CATALINA_BASE "
-Djava.io.tmpdir=$TMP_DIR "
-wait 10 "
-pidfile $PID_FILE "
-outfile $CATALINA_HOME/logs/catalina.out "
-errfile '&1' "
$CATALINA_OPTS "
-cp $CLASSPATH "
org.apache.catalina.startup.Bootstrap
#
# To get a verbose JVM
#-verbose "
# To get a debug of jsvc.
#-debug "
exit $?
;;

stop)
#
# Stop Tomcat
#
$DAEMON_HOME/jsvc-src/jsvc "
-stop "
-pidfile $PID_FILE "
org.apache.catalina.startup.Bootstrap
exit $?
;;

*)
echo "Usage tomcat.sh start/stop"
exit 1;;
esac

#service tomcat start 试tomcat能不能启?
#chkconfig tomcat on
#chkconfig --list tomcat
完成自启动脚?

注意Q?
在tomcat文g的头两行的注释语句中Q需要包含chkconfig和description两部分内?认不要拼写错误Q?Q否则在执行“chkconfig --add tomcat”Ӟ?x)出?#8220;tomcat服务不支持chkconfig”的错误提C?
chkconfigq行表示~省启动的运行别以?qing)启动和停止的优先Q如该服务缺省不再Q何运行启动Q则?- 代替q行U别。在tomcat中表C本在q行U????启动Q启动优先权?0Q停止优先权?0?
description行对服务q行描述Q可以用 “"” 跨行注释?/span>

seal 2008-08-18 10:10 发表评论
]]>
Apache讄虚拟站点ȝhttp://www.aygfsteel.com/sealyu/archive/2008/08/14/221988.htmlsealsealThu, 14 Aug 2008 06:10:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/08/14/221988.htmlhttp://www.aygfsteel.com/sealyu/comments/221988.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/08/14/221988.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/221988.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/221988.html

在整合Apache和Tomcat之后Q发现该服务器的两个|站一个是?rn)态的Q一个是动态jsp的,讄ȝ如下

主要讄httpd.conf

1、DirectoryIndex的设|?/p>

如果多个虚拟站点中包含多U文件格式和文g名的首页文gQ必dq里全部出现

2、多个站点的定义如下

#NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
NameVirtualHost 220.231.32.*:80

<VirtualHost 220.231.32.*:80>
    ServerAdmin liubin@sina.com
    DocumentRoot /usr/local/tomcat/webapps/ronglian
    ServerName www.ronglian.com
    ErrorLog logs/ronglian.com-error_log
    CustomLog logs/ronglian.com-access_log common
</VirtualHost>

<VirtualHost 220.231.32.*:80>
    ServerAdmin wellboby@tom.com
    DocumentRoot /usr/local/wwwroot/chinaface
    ServerName www.chinaface.net
    ErrorLog logs/chinaface.net-error_log
    CustomLog logs/chinaface.net-access_log common
</VirtualHost>

Q! 在这里,NameVirtualHost的字D不能省略,否则起apache时报错:(x)VirtualHost 220.231.32.*.80 overlaps with VirtualHost 220.231.32.*:80, the first has precedence, perhaps you need a NameVirtualHost directive——虽然apache能vQ同错误描述一PW二个站点的定义被第一个站点的定义所覆盖Q即讉KW二个站Ҏ(gu)向的其实是第一?/p>

Q! NameVirtualHost字段的端口号不能忽略Q否则vapache时报错:(x)VirtualHost 220.231.32.*:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[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>

Q!如果VirtualHost 字段的端口号实Qvapache时报错:(x)VirtualHost 220.231.32.28:0 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results——但apache可以启动Q访问也正常



seal 2008-08-14 14:10 发表评论
]]>
TomCat多虚拟站炚w|(转)(j)http://www.aygfsteel.com/sealyu/archive/2008/08/14/221921.htmlsealsealThu, 14 Aug 2008 03:25:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/08/14/221921.htmlhttp://www.aygfsteel.com/sealyu/comments/221921.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/08/14/221921.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/221921.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/221921.html阅读全文

seal 2008-08-14 11:25 发表评论
]]>
apache2.2与tomcat集成(可以多个tomcat)http://www.aygfsteel.com/sealyu/archive/2008/08/11/221381.htmlsealsealMon, 11 Aug 2008 14:05:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/08/11/221381.htmlhttp://www.aygfsteel.com/sealyu/comments/221381.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/08/11/221381.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/221381.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/221381.htmlhttp://ttitfly.javaeye.com/admin/show/127337

2.需求概况:(x)
?个服务:(x)www.test.com, bbs.test.com。分别对?个tomcat下的2个web应用。由apache httpd作ؓ(f)互联|接入服务器Q在80端口接收对这2个服务的h。apache httpd再将q?个请求分别对应到不同的后端web服务?Tomcat)处理?

3.配置域名映射到本机即127.0.0.1Q同旉|service域名

Java代码 复制代码
  1. 127.0.0.1    localhost www.test.com www.service.test.com bbs.test.com bbs.service.test.com  


4. 分别?个tomcat里分别部|一个非常简单的应用?

W一个tomcat Q端?8080

~辑$TOMCAT_HOME/conf/server.xml

d一个Host
Java代码 复制代码
  1. <Host name="www.service.test.com" unpackWARs="true" autoDeploy="true"  
  2. xmlValidation="false" xmlNamespaceAware="false"/>  


再在$TOMCAT_HOME/conf/Catalina下徏立一个目?www.service.test.com
然后在www.service.test.com目录下徏立一个ROOT.xml,内容为:(x)
Java代码 复制代码
  1. <Context docBase="/home/mahaibo/app/test"  
  2. privileged="true" antiResourceLocking="false" antiJARLocking="false">  
  3. </Context>  

docBase指向具体的项目\?/span>

同理W二个tomcatQ端?088Q也是一L(fng)做法Q?

~辑$TOMCAT_HOME/conf/server.xml

d一个Host:
Java代码 复制代码
  1. <Host name="bbs.service.test.com" unpackWARs="true" autoDeploy="true"  
  2. xmlValidation="false" xmlNamespaceAware="false"/>  



然后?TOMCAT_HOME/conf/Catalina下徏立一个目?bbs.service.test.com

再在bbs.service.test.com目录下徏立一个ROOT.xml,内容为:(x)
Java代码 复制代码
  1. <Context docBase="/home/mahaibo/app/bbs"  
  2. privileged="true" antiResourceLocking="false" antiJARLocking="false">  
  3. </Context>  


5. 分别启动tomcatQ可以通过http://www.service.test.com:8080和http://bbs.service.test.com:8088讉K

6. 配置a(chn)pache httpd.conf文g?

扑ֈapach/conf/httpd.conf文gQ确认下面这些文字行前面没有"#"注释P(x)

Java代码 复制代码
  1. LoadModule proxy_module modules/mod_proxy.so  
  2. LoadModule proxy_ajp_module modules/mod_proxy_ajp.so  
  3. LoadModule proxy_balancer_module modules/mod_proxy_balancer.so  
  4. LoadModule proxy_connect_module modules/mod_proxy_connect.so  
  5. LoadModule proxy_http_module modules/mod_proxy_http.so  
  6. LoadModule proxy_ftp_module modules/mod_proxy_ftp.so  


q增加虚拟主机配|:(x)
Java代码 复制代码
  1. NameVirtualHost *:80  
  2. <VirtualHost *:80>  
  3. ServerName www.test.com  
  4. ProxyIOBufferSize 8192  
  5. ProxyRequests Off  
  6. ProxyVia Full  
  7. ProxyPass / http://www.service.test.com:8080/ smax=5 max=20 ttl=120 retry=300  
  8. </VirtualHost>  
  9.   
  10. <VirtualHost *:80>  
  11. ServerName bbs.test.com  
  12. ProxyIOBufferSize 8192  
  13. ProxyRequests Off  
  14. ProxyVia Full  
  15. ProxyPass / http://bbs.service.test.com:8088/ smax=5 max=20 ttl=120 retry=300  
  16. </VirtualHost>  


7.启动apache
Java代码 复制代码
  1. ./apachectl start  


8 可以通过讉Khttp://www.test.com和http://bbs.test.com来分别访?个不同tomcat下的不同应用?jin)?

seal 2008-08-11 22:05 发表评论
]]>
Apache配置 虚拟转向实例Q{Q?/title><link>http://www.aygfsteel.com/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.aygfsteel.com/sealyu/archive/2008/08/11/221312.html</guid><wfw:comment>http://www.aygfsteel.com/sealyu/comments/221312.html</wfw:comment><comments>http://www.aygfsteel.com/sealyu/archive/2008/08/11/221312.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sealyu/comments/commentRss/221312.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sealyu/services/trackbacks/221312.html</trackback:ping><description><![CDATA[NameVirtualHost *:80 q个一定要 <br /> 然后把主的ServerAdmin丢最下面 <br /> ///////////////////// <br /> NameVirtualHost *:80 <br /> <VirtualHost *:80> <br /> ServerName abccccc.com <br /> ProxyPass / http://localhost:8088/ <br /> ProxyPassReverse / http://localhost:8088/ <br /> </VirtualHost> <br /> <br /> #讄虚拟L <br /> <VirtualHost *:80> <br /> ServerAdmin www.adddd.com <br /> DocumentRoot E:/Tomcat/webapps/ROOT  <br /> #(zhn)的站点目所在\径,应与tomcat中的目录讄相同 <br /> ServerName www.adddd.com <br /> Alias /p "F:""uploadFiles" <br /> <Directory "F:""uploadFiles"> <br />     Options -Indexes MultiViews <br />     AllowOverride None <br />     Order allow,deny <br />     Allow from all <br /> </Directory> <br /> <br /> Alias /aaaaaa "F:""aaaaaa" <br /> <Directory "F:""aaaaaa"abcc"> <br />     Options -Indexes MultiViews <br />     AllowOverride None <br />     Order allow,deny <br />     Allow from all <br /> </Directory> <br /> DirectoryIndex index.html index.htm index.jsp <br /> ErrorLog logs/shsc-error_log.txt <br /> CustomLog logs/shsc-<a target="_blank"><font color="red">access</font></a>_log.txt common <br /> JkMount /servlet/* ajp13  <br /> #让Apache支持对servlet传送,用以Tomcat解析 <br /> JkMount /*.jsp ajp13  <br /> #让Apache支持对jsp传送,用以Tomcat解析 <br /> JkMount /*.do ajp13  <br /> #让Apache支持?do传送,用以Tomcat解析 <br /> </VirtualHost> <br /> ///////////////////// <img src ="http://www.aygfsteel.com/sealyu/aggbug/221312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sealyu/" target="_blank">seal</a> 2008-08-11 15:32 <a href="http://www.aygfsteel.com/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.aygfsteel.com/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.aygfsteel.com/sealyu/archive/2008/07/17/215597.html</guid><wfw:comment>http://www.aygfsteel.com/sealyu/comments/215597.html</wfw:comment><comments>http://www.aygfsteel.com/sealyu/archive/2008/07/17/215597.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sealyu/comments/commentRss/215597.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/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 来访问。这个功能用了(jin)一?mod_jk.so 的模块,有关q个斚w的配|曾l困C(jin)我很久,我相信也l不h带来?jin)麻烦(ch)。这ơ我要说的是一U更加简便的配置方式Q自动化配置?/span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">自动化配|的前提是只有一?Tomcat 实例?Apache 在同一台机器上q行。自动化配置是通过?Tomcat 的配|文?server.xml 中的 Engine 元素中添加相应的 ApacheConfig 监听?Listener)来实现的?/span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">下面是具体的配置Q?/span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">W一步:(x)下蝲q安?Apache httpd?Tomcat</span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">下蝲q安?Apache 2.2.9 ?Tomcat 5.5.26Q假设他们的安装目录如下Q?/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: 宋体;">q两个服务器可以在以下地址下蝲Q?/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 >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: 宋体;">W二步:(x)下蝲q安?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: 宋体;">的下载地址如下Q?/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: 宋体;">下蝲后将光命名q复制到?D:/apps/Apache/Apache2.2/modules ?/span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">W三步:(x)创徏 workers.properties 文g</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: 宋体;">定义?jin)每?worker 的类型、协议、端口等信息。如果手上没有现成的配置文gQ可以用以下最单的配置Q?/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 目录中,如果攑֜其他地方Q则需要在 server.xml 的配|中明确指定?/span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">W四步:(x)修改 Tomcat server.xml 文g</span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">扑ֈ下面q行内容q在后面d配置信息Q?/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;"><Engine name="Catalina" defaultHost="localhost"></span></span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">配置信息如下Q?/span></p> <p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">    <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;">       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;">       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;">       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;">       jkDebug="info"</span></p> <p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">       jkWorker="worker1" </span></p> <p style="text-align: left; font-family: Courier New; color: #800000;" class="MsoNormal" align="left"><span style="font-size: 12pt;">       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;">    /></span></span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">其中Q?/span></p> <ul> <li><span style="font-size: 12pt; font-family: 宋体;">workersConfig </span><span style="font-size: 12pt; font-family: 宋体;">?workers.properties 的位|,q里我没有用默认的位置Q所以在此明说明了(jin)?/span></li> </ul> <ul> <li><span style="font-size: 12pt; font-family: 宋体;">modJk</span><span style="font-size: 12pt; font-family: 宋体;">Q定义了(jin) 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 的位|,q里?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: 宋体;">Q定义日志别,可以使用的别有Qdebug, info, error, 或?emergQ默认ؓ(f) 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: 宋体;">Q定?worker 的名Uͼ必须是在 workers.properties 中定义过的名Uͼ否则可能?x)出?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: 宋体;">Q如果ؓ(f) trueQ则根目录不?x)映?Tomcat 的根目录Qfalse 则映到 Tomcat 根目录,如果?false 的话Q?a href="http://localhost/">http://localhost/</a> ?x)打开 Tomcat 的欢q页面(ROOTQ?/span></span></li> </ul> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">W五步:(x)修改 Apache httpd.conf 文g</span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">扑ֈ httpd.conf 文gq在最后加上如下配|:(x)</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: 宋体;">要注意的是,q里 Include 后面的\径必L,q里 $TOMCAT_HOME ?Tomcat 安装目录QD:/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: 宋体;">W六步:(x)重启 Tomcat q自动生?mod_jk.conf</span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">重启 TomcatQ重启成功后?x)在?conf 下面生成 mod_jk.conf 文gQ这个配|文件就是在 httpd.conf 中要用到的那个,q个文g的\径必d?httpd.conf 中的一致。下面是生成的一个mod_jk.confQ?/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;"><IfModule !mod_jk.c></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;"> 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;"></IfModule></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;"><VirtualHost 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;">    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;">    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;">    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;">    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;">    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;">    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;">    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;">    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;">    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;">    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;">    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;"></VirtualHost></span></span></p> <p style="text-align: left;" class="MsoNormal" align="left"><span style="font-size: 12pt; font-family: 宋体;">W七步:(x)启动 Apache q测试配|?/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: 宋体;">启动完成后,试如下地址Q?/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: 宋体;">如果面能正常显C,说明配置成功Q如果出?/span> internal server error <span style="font-family: 宋体;">之类的错误,说明上面的配|有误,需要检查ƈ试?/span></p> <img src ="http://www.aygfsteel.com/sealyu/aggbug/215597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sealyu/" target="_blank">seal</a> 2008-07-17 22:27 <a href="http://www.aygfsteel.com/sealyu/archive/2008/07/17/215597.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Working with mod_jkhttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215595.htmlsealsealThu, 17 Jul 2008 14:01:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215595.htmlhttp://www.aygfsteel.com/sealyu/comments/215595.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215595.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/215595.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/215595.htmlBy Gal Shachor <shachor@il.ibm.com>

Table of Contents


What is mod_jk?

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.


Why mod_jk?

Several reasons:

  • mod_jserv was too complex. Because it was ported from Apache/JServ, it brought with it lots of JServ specific bits that aren't needed by Apache.
  • mod_jserv supported only Apache. 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.
  • The layered approach provided by the jk library makes it easier to support both Apache1.3.x and Apache2.xx.
  • Better support for SSL. mod_jserv couldn't reliably identify whether a request was made via HTTP or HTTPS. mod_jk can, using the newer Ajpv13 protocol.

What does it mean to me?

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.


Definitions and Terminology

In this document I am going to use a few terms, so let's define them:

Term

Meaning

Worker Process

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.

In-Process Worker

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.

Web Server Plug-in/Tomcat Redirector

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.

Plug-in Configuration

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.

Web Server Configuration

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.


Obtaining mod_jk

mod_jk can be obtained in two formats - binary and source.  Depending on the platform you are running your web server on, a binary version of mod_jk may be available.  It is recommended to use the binary version if one is available.  If the binary is not available, follow the instructions for building mod_jk from source.  Notes at the end of this section offer recommendations for specific platforms.

mod_jk Binaries

Binaries for mod_jk are available for several platforms in the same area as the Tomcat Binary Release.  The binaries are located in subdirectories by platform.  For some platforms, such as Windows, this is the typical way of obtaining mod_jk since most Windows systems do not have C compilers.  For others, the binary distribution of mod_jk offers simpler installation.

For example, the Tomcat 3.3 M1 Release at http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.3-m1/bin/ contains the following:

linux/i386/ Contains mod_jk.so for Apache 1.3 for the standard API as well as EAPI and mod_jk.so for Apache 2.0
netware/ Contains the mod_jk.nlm and nsapi.nlm
win32/ Contains the mod_jk.dll for Windows as well as other useful binaries.

Check the site for the latest binaries.

Note: The version of mod_jk is not dependent on the version of Tomcat.  The Tomcat 3.3 distribution of mod_jk will function correctly with other 3.x versions of Tomcat, such as Tomcat 3.2.1.

Building mod_jk

mod_jk is available in source distribution for all Windows and most Unix platforms.  The source for mod_jk is included in the Binary Distribution of Tomcat in the TOMCAT_HOME/native/mod_jk/ directory.  This directory is organized by Web Server name and version.  Each directory contains the source as well as the appropriate build scripts, make files, or project files.

Building mod_jk for NT

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.

The steps that you need to take are:

  1. Change directory to the apache1.3 or apache2.0 source directory depending on your version of Apache.
  2. Set an APACHE1_HOME environment variable which points to where your Apache is installed.
  3. Execute the following command:

    MSDEV mod_jk.dsp /MAKE ALL

    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.
  4. Copy mod_jk.dll to Apache's modules directory.

This will build both release and debug versions of the redirector plug-in (mod_jk).

An alternative will be to open mod_jk.dsp in msdev and build it using the build menu.

Building mod_jk for Unix

Apache

  1. Make sure your Apache has DSO support. You can check this with $APACHE_HOME/bin/httpd -l. 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.
  2. 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, $APACHE_HOME/bin/apachectl configtest will warn you.
  3. Make sure you have Perl 5 installed. The apxs script used to build the module is written in Perl.
  4. Change directory to TOMCAT_HOME/native/mod_jk/apache1.3 (or apache2.0).
  5. Build mod_jk.so. Following are three techniques you can try, in order of simplicity:

    1. Run the build script for your platform.  If a build script is not available for your platform, you may be able to build mod_jk using ./build-unix.sh. This script will set some variables, call apxs as below, and try to copy mod_jk.so to $APACHE_HOME/libexec. If it fails, you need to do the following manually:
      • set JAVA_HOME in your shell, e.g. "set JAVA_HOME=/usr/local/jdk1.2.2; export JAVA_HOME"
      • set APACHE_HOME in your shell, e.g. "set APACHE_HOME=/usr/local/apache; export APACHE_HOME"
      • uncomment the following line in the build-unix.sh file, replacing "linux" with the name of your platform as specified in the Java include directory for your installation
        # JAVA_INCLUDE="-I ${JAVA_HOME}/include -I ${JAVA_HOME}/include/linux"
    2. If build-unix.sh fails, you may have better luck with the Makefiles in the same directory, e.g. "make -f Makefile.linux mod_jk.so"
    3. Finally, you can try to build it manually. Run the apxs 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.


      For Linux:

      apxs -o mod_jk.so -I../jk -I/usr/local/jdk/include -I/usr/local/jdk/include/linux -c *.c ../jk/*.c

      Your build may fail because the object files from the ../jk directory have been compiled to the current directory, rather than their source directory. Running gcc -shared -o mod_jk.so *.o should finish the build.


      For Solaris:

      Use the build-solaris.sh script as follows:

      # sh build-solaris.sh

      This will build and install mod_jk.so in your apache/libexec directory.  This script contains settings for your Java and Apache home locations.  Make sure that these are set according to your installation.  The default settings are JAVA_HOME=/usr/java and APACHE_HOME=/usr/local/apache.  If your installation is different, you will need to edit the build-solaris.sh script and change these values appropriately.

      See README.solaris located in TOMCAT_HOME/native/mod_jk/apache1.3 for more information.

      If the build script does not work, you can also build mod_jk as follows:

      $APACHE_HOME/bin/apxs -o mod_jk.so -DSOLARIS -I../jk -I/usr/java/include -I/usr/java/include/solaris -c *.c ../jk/*.c

      On some systems, this will build the module correctly, but will fail at runtime with a "symbol "fdatasync" not found". To fix, add -lposix4 just before the -c in the above command.


      For HP-UX 11.00:

      Use the build-hpux.sh script as follows:

      # sh build-hpux.sh

      This will build and install mod_jk.so in your apache/libexec directory.  This script contains settings for your Java and Apache home locations.  Make sure that these are set according to your installation.  The default settings are JAVA_HOME=/opt/java1.3 and APACHE_HOME=/usr/local/apache.  If your installation is different, you will need to edit the build-hpux.sh script and change these values appropriately.

      Also note that there are two HP-UX build scripts.  One script was written to build mod_jk without JNI support using GNU GCC.  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).  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.

      The build-hpux.sh script should also work for HP-UX 10.00.

      See README.hpux located in TOMCAT_HOME/native/mod_jk/apache1.3 for more information.


      For other Unixes (including FreeBSD):

      You may need to replace fdatasync() with fsync() in jk_util.c.

      The build-hpux-cc.sh script should be modifiable for IRIX and AIX.  Edit the script and change the APACHE_HOME and JAVA_HOME locations as required.


      If you are using EAPI, try adding -DEAPI to the apxs command after mod_jk.so.

      If apxs fails with apxs:Break: Command failed with rc=255, it may have been damaged by mod_ssl. Search for:

      my $CFG_LD_SHLIB      = q();          # substituted via Makefile.tmpl
      my $CFG_LDFLAGS_SHLIB = q(); # substituted via Makefile.tmpl

      and change to:

      my $CFG_LD_SHLIB      = q(ld);          # substituted via Makefile.tmpl
      my $CFG_LDFLAGS_SHLIB = q(-G); # substituted via Makefile.tmpl

      If you've installed Java in another directory, adjust accordingly.

      For other Unixes you should be able to work it out, but remember that the order of the arguments to apxs is important!.

  6. Now, copy the mod_jk library.  # cp mod_jk.so $APACHE_HOME/libexec. (Note that the build scripts attempt to do this, but you may have to su first.)

Other Webservers

There are several Makefiles in the other directories under the TOMCAT_HOME/native/mod_jk/ directory.  You should also check the Tomcat documentation for specific information related to other web servers.


Configuring Apache

This section details the configuration that is required for the Apache Web Server to support mod_jk.

Removing mod_jserv directives

If you've previously configured Apache to use mod_jserv, remove any ApJServMount directives from your httpd.conf. If you're including tomcat-apache.conf or tomcat.conf, you'll want to remove them as well - they are specific to mod_jserv.  The mod_jserv configuration directives are not compatible with mod_jk!

Configure Apache to use mod_jk

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:

Include TOMCAT_HOME/conf/jk/mod_jk.conf-auto

Example:

Include /usr/local/jakarta-tomcat/conf/jk/mod_jk.conf-auto

This will tell Apache to use directives in the mod_jk.conf-auto file in the Apache configuration.  This file is created by enabling the Apache auto-configuration as described in the configuring Tomcat section below [Configuring Tomcat].

NOTE:  If you plan to use the Tomcat-Apache auto-configuration, skip the rest of this section and continue with the Configuring Tomcat section.

Custom configurations can be created by enabling the auto-configuration and copying the TOMCAT_HOME/conf/jk/mod_jk.conf-auto file to your own configuration file, such as TOMCAT_HOME/conf/jk/mod_jk.conf-local.

The basic configuration is as follows:

  • You will need to instruct Apache to load Tomcat. This can be done with Apache's LoadModule and AddModule configuration directives.
  • You must inform mod_jk the location of your workers.properties file. Use mod_jk's JkWorkersFile configuration directive.
  • You should specify a location where mod_jk is going to place its log file and a log level to be used. Use the JkLogFile and JkLogLevel configuration directives. Possible log levels are debug, info, error and emerg, but info should be your default selection.
  • The directive JkLogStampFormat will configure the date/time format found on mod_jk logfile. Using strftime() format string it's set by default to "[%a %b %d %H:%M:%S %Y] "
A simple example would be to include the following lines in your httpd.conf file:
LoadModule    jk_module  libexec/mod_jk.so
AddModule mod_jk.c
JkWorkersFile /usr/local/jakarta-tomcat/conf/workers.properties
JkLogFile /usr/local/apache/logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

Assigning URLs to Tomcat

If you have created a custom or local version of mod_jk.conf-local as noted above, you can change settings such as the workers or URL prefix.

Use mod_jk's JkMount directive to assign specific URLs to Tomcat. In general the structure of a JkMount directive is:

JkMount <URL prefix> <Worker name>

For example the following directives will send all requests ending in .jsp or beginning with /servlet to the "ajp13" worker, but jsp requests to files located in /otherworker will go to "remoteworker".

JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /otherworker/*.jsp remoteworker
You can use the JkMount directive at the top level or inside <VirtualHost> sections of your httpd.conf file.

Configuring Tomcat

Enabling Tomcat's Apache Auto-Config

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 "Include TOMCAT_HOME/conf/jk/mod_jk.conf-auto") in your httpd.conf, as shown in the previous section (Configuring Apache).

To configure Tomcat to generate the Apache auto-configuration add the following block to your TOMCAT_HOME/conf/server.xml file after <AutoWebApp ... />.

<ApacheConfig />

That's it, you can now start Tomcat and Apache and access Tomcat from the Apache server.

Note: Settings for mod_jk auto-configuration is new in Tomcat 3.3.  Older versions of Tomcat create the auto-config file without a directive in server.xml.  The new directive in Tomcat 3.3 allows for additional configuration options as detailed later in this section.  For older versions of Tomcat, refere to the documentation that came with that version.

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.

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 TOMCAT_HOME/conf/jk/mod_jk.conf-auto is generated when tomcat starts, so you'll need to start Tomcat before Apache. Tomcat will overwrite TOMCAT_HOME/conf/jk/mod_jk.conf-auto each startup so customized configuration should be kept elsewhere.  For example, copy  TOMCAT_HOME/conf/jk/mod_jk.conf-auto to TOMCAT_HOME/conf/jk/mod_jk.conf-local before making changes.  You'll need to startup Tomcat once to generate this file with your configuration for the first time.

It is also possible to specify the location of the auto generated files by setting options in the <ApacheConfig /> block.  The following details the syntax:

< ContextManager ... >
...
<ApacheConfig options />
...
< /ContextManager >

 where options can include any of the following attributes:

  • confighome - default parent directory for the following paths. If not set, this defaults to TOMCAT_HOME. Ignored whenever any of the following paths is absolute.
  • jservconfig - path to write apache jserv conf file to. If not set, defaults to "conf/jserv/tomcat-apache.conf".
  • jkconfig - path to write apacke mod_jk conf file to. If not set, defaults to "conf/jk/mod_jk.conf".
  • workersconfig - path to workers.properties file used by mod_jk. If not set, defaults to "conf/jk/workers.properties".
  • modjserv - 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.
  • modjk - 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.
  • jklog - path to log file to be used by mod_jk.

 Example:

...

<AutoWebApp dir="webapps" host="DEFAULT" />

<ApacheConfig confighome="/home/mydir" />

...

(Optional) Configuring Tomcat to use the Ajpv13 protocol

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.

The following block enables Ajpv13 in your TOMCAT_HOME/conf/server.xml file.
<RequestInterceptor
className="org.apache.tomcat.modules.server.Ajp13Interceptor"
port="8009"/>

The server.xml 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.

(Optional) Defining "workers"

Configuring workers manually.

Workers are configured using the file TOMCAT_HOME/conf/jk/workers.properties. There is a great deal of information in the workers.properties howto 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 workers.properties and setting the workers.tomcat_home, workers.java_home and ps variables to the correct values for your system.


Example Configuration

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).

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.

The example are over-simplified and incomplete but should get you started. Also note the virtual host setup is new in Tomcat 3.2 - this example won't work with Tomcat 3.1.

.
.
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
<Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/>
<Parameter name="port" value="8007"/>
</Connector>

<Connector className="org.apache.tomcat.service.PoolTcpConnector">
<Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp13ConnectionHandler"/>
<Parameter name="port" value="8009"/>
</Connector>

<Host name="host1.apache.org">
<Context path="" docBase="/web/host1" debug="0"/>
</Host>
<Host name="host2.apache.org">
<Context path="" docBase="/web/host2" debug="0"/>
</Host>
.
.
Table 1 - Excerpt from server.xml showing the Ajp13 Connector and two virtual hosts.

# Setup for Solaris system
#
workers.tomcat_home=/usr/local/jakarta-tomcat
workers.java_home=/usr/java
ps=/
worker.list=ajp12, ajp13

# Definition for Ajp13 worker (Ajp12 left to readers imagination)
#
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
Table 2 - Excerpt from workers.properties showing the Ajp13 worker

# Load mod_jk
#
LoadModule jk_module libexec/mod_jk.so
AddModule mod_jk.c

# Configure mod_jk
#
JkWorkersFile /usr/local/jakarta-tomcat/conf/jk/workers.properties
JkLogFile /usr/local/apache/logs/mod_jk.log
JkLogLevel info

# First Virtual Host.
#
<VirtualHost 10.0.0.1:80>
DocumentRoot /web/host1
ServerName host1.apache.org
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
</VirtualHost>

# Second Virtual Host. Also accessible via HTTPS
#
<VirtualHost 10.0.0.2:80>
DocumentRoot /web/host2
ServerName host2.apache.org
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
</VirtualHost>

<VirtualHost 10.0.0.2:443>
DocumentRoot /web/host2
ServerName host2.apache.org
SSLEngine On
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
</VirtualHost>

Table 3 - Excerpt from Apaches httpd.conf showing JK directives.

Troubleshooting and F.A.Q.s

Q. Where can I get help/support for mod_jk?

A. The primary mechanism for support is through the Tomcat Documentation included in the TOMCAT_HOME/doc directory.  These documents are viewable via browser through Tomcat http://localhost:8080/doc/index.html.  Documentation is also available on the Apache Jakarta web site for Tomcat at http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/index.html.

For additional help, the best resource is the Tomcat Users Discussion list.  You should start by searching the mail list archives located at http://mikal.org/interests/java/tomcat/index.html before you post questions to the list.  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.  Make sure that you include the version of Apache and Tomcat that you are using as well as the platform you are running on. http://jakarta.apache.org/site/mail.html

Q. I can't find mod_jk anywhere. Where is it?

A. Starting with Tomcat 3.3, the source for mod_jk is included in the native/mod_jk directory.  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.  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)

Q. Which protocol should I use? Ajp12 or Ajp13?

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 workers.properties howto document.

Q. Whenever I restart Tomcat, Apache locks up!

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.

Q. Why did exist two files mod_jk.so (-eapi ad -noeapi) in download dir for Linux ?

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

Q. What's that message about 'garbled DSO ?'

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.

Q. And the message about 'module might crash under EAPI! '

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.

Q. Where can I get more information?

A. The workers.properties howto 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.

Q. APXS is getting an error during the build of mod_jk, like rc=0 or rc=255.  I tried all of the steps in the build section, what do I do now?

A. APXS is a Perl script that is created when you build the Apache web server from source.  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.  Your best bet is to get the Apache source from http://httpd.apache.org and build it yourself.  Use the following for a basic build (read the Apache docs for other options):
# cd /usr/local/src
# gzip -dc apache_1.3.19.tar.gz|tar xvf -
# cd apache_1.3.19
# ./configure --prefix=/usr/local/apache "
--enable-module=most "
--enable-shared=max
# make
# make install

Note: The above steps assume that you downloaded the Apache source and placed it in your /usr/local/src directory.


Credits

This document was originally created by Gal Shachor

Revisions by (Alphabetical)

Mike Braden <mikeb@mwbinc.com>
Mike Bremford
Chris Pepper

With help from countless others on the tomcat-dev and tomcat-user lists!

Copyright ©1999-2001 The Apache Software Foundation
Legal Stuff They Make Us Say
Contact Information



seal 2008-07-17 22:01 发表评论
]]>
Tomcat-Apache HOWTOhttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215545.htmlsealsealThu, 17 Jul 2008 08:56:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215545.htmlhttp://www.aygfsteel.com/sealyu/comments/215545.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215545.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/215545.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/215545.html阅读全文

seal 2008-07-17 16:56 发表评论
]]>
The Apache Tomcat Connector - Webserver HowTohttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215541.htmlsealsealThu, 17 Jul 2008 08:51:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215541.htmlhttp://www.aygfsteel.com/sealyu/comments/215541.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215541.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/215541.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/215541.html阅读全文

seal 2008-07-17 16:51 发表评论
]]>
tomcat5.5下配|manager用户名密?/title><link>http://www.aygfsteel.com/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.aygfsteel.com/sealyu/archive/2008/07/17/215540.html</guid><wfw:comment>http://www.aygfsteel.com/sealyu/comments/215540.html</wfw:comment><comments>http://www.aygfsteel.com/sealyu/archive/2008/07/17/215540.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sealyu/comments/commentRss/215540.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sealyu/services/trackbacks/215540.html</trackback:ping><description><![CDATA[在tomcat-users.xml中添加:(x)<br /> <role rolename="manager"/><br /> <role rolename="admin"/><br /> <br /> <user username="admin" password="admin" roles="admin,manager"/> <img src ="http://www.aygfsteel.com/sealyu/aggbug/215540.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sealyu/" target="_blank">seal</a> 2008-07-17 16:48 <a href="http://www.aygfsteel.com/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整合http://www.aygfsteel.com/sealyu/archive/2008/07/17/215507.htmlsealsealThu, 17 Jul 2008 07:24:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215507.htmlhttp://www.aygfsteel.com/sealyu/comments/215507.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/07/17/215507.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/215507.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/215507.html 2.在apache|站下蝲jk文g mod_jk_1.2.25_http_2.0.59.soQ将该文件拷入apache的安装目录下的modules目录下?
修改apache安装目录下的httpd_conf文gQ?
LoadModule jk_module modules/ mod_jk_1.2.25_http_2.0.59.so
JkWorkersFile “Conf/workers.properties”
JkLogFile “logs/mod_jk.log
JkLogLevel debug
JkMount /*.jsp worker1
JkMount /test/* worker1

Listen 192.168.0.1:80

DocumentRoot “/web/tomcat5028/webapps/test”
<Directory “/web/tomcat5028/webapps/test”>
在conf下徏立workers.properties文gQ键入以下内容:(x)
ps=/
worker. .list = worker1
worker.worker1.typye = ajp13
worker.worker1.host = 192.168.0.1
worker.worker1.port = 8009
worker.worker1.lbfactor = 1
最后测试,重启Tomcat服务器和Apache服务器,通过IE讉Khttp://192.168.0.1/如果出现
Tomcat的默认主,表明配置以成功?

seal 2008-07-17 15:24 发表评论
]]>
Apache HTTP Server ?Tomcat 的三U连接方式介l?/title><link>http://www.aygfsteel.com/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.aygfsteel.com/sealyu/archive/2008/07/16/215337.html</guid><wfw:comment>http://www.aygfsteel.com/sealyu/comments/215337.html</wfw:comment><comments>http://www.aygfsteel.com/sealyu/archive/2008/07/16/215337.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sealyu/comments/commentRss/215337.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sealyu/services/trackbacks/215337.html</trackback:ping><description><![CDATA[<blockquote>整合 Apache Http Server ?Tomcat 可以提升寚w(rn)态文件的处理性能、利?Web 服务器来做负载均衡以?qing)容错、无~的升应用E序。本文介l了(jin)三种整合 Apache ?Tomcat 的方式?/blockquote> <p>首先我们先介l一下ؓ(f)什么要? Apache ?Tomcat 之间q行q接。事实上 Tomcat 本n已经提供?HTTP 服务Q该服务默认的端口是 8080Q装? tomcat 后通过 8080 端口可以直接使用 Tomcat 所q行的应用程序,你也可以该端口改ؓ(f) 80?/p> <p>既然 Tomcat 本n已经可以提供q样的服务,我们Z么还要引?Apache 或者其他的一些专门的 HTTP 服务器呢Q原因有下面几个Q?/p> <p>1. 提升寚w(rn)态文件的处理性能</p> <p>2. 利用 Web 服务器来做负载均衡以?qing)容?/p> <p>3. 无缝的升U应用程?/p> <p>q? 三点对一?web |站来说是非怹重要的,我们希望我们的网站不仅是速度快,而且要稳定,不能因ؓ(f)某个 Tomcat 宕机或者是升E序D用户讉K不了(jin)Q而能完成q几个功能的、最好的 HTTP 服务器也只?apache ?http server ?jin),它? tomcat 的结合是最紧密和可靠的?/p> <p>接下来我们介l三U方法将 apache ?tomcat 整合在一赗?/p> <p><a name="N1005F">JK</a></p> <p>q是最常见的方式,你可以在|上扑ֈ很多关于配置JK的网,当然最全的q是其官Ҏ(gu)提供的文档。JK 本n有两个版本分别是 1 ?2Q目?1 最新的版本?1.2.19Q而版?2 早已l废弃了(jin)Q以后不再有新版本的推出?jin),所以徏议你采用版本 1?/p> <p>JK 是通过 AJP 协议?Tomcat 服务器进行通讯的,Tomcat 默认?AJP Connector 的端口是 8009。JK 本n提供?jin)一个监控以?qing)管理的?jkstatusQ通过 jkstatus 可以监控 JK 目前的工作状态以?qing)对?tomcat 的连接进行设|,如下图所C:(x)</p> <br /> <a name="N1006D"><strong>?1Q监控以?qing)管理的?jkstatus</strong></a><br /> <img alt="?1Q监控以?qing)管理的?jkstatus" src="http://www.ibm.com/developerworks/cn/opensource/os-lo-apache-tomcat/images/image002.jpg" border="0" height="228" width="554" /> <br /> <p>? q个图中我们可以看到当前JK配了(jin)两个q接分别?8109 ?8209 端口上,目前 s2 q个q接是停止状态,?s1 q个q接自上ơ重启后已经处理?47 万多个请求,量辑ֈ 6.2 ?GQ最大的q发数有 13 {等。我们也可以利用 jkstatus 的管理功能来切换 JK C同的 Tomcat 上,例如?s2 启用Qƈ停用 s1Q这个在更新应用E序的时候非常有用,而且整个切换q程对用h说是透明的,也就辑ֈ?jin)无~升U的目的。关?JK 的配|文章网上已l非常多?jin),q里我们不再详细的介l整个配|过E,但我要讲一下配|的思\Q只要明白了(jin)配置的思\QJK 是一个非常灵zȝlg?/p> <p>JK 的配|最关键的有三个文gQ分别是 </p> <p> <strong>httpd.conf </strong> <br /> Apache 服务器的配置文gQ用来加?JK 模块以及(qing)指定 JK 配置文g信息</p> <p> <strong>workers.properties</strong> <br /> ?Tomcat 服务器的q接定义文g</p> <p> <strong>uriworkermap.properties</strong> <br /> URI 映射文gQ用来指定哪?URL ?Tomcat 处理Q你也可以直接在 httpd.conf 中配|这?URIQ但是独立这些配|的好处?JK 模块?x)定期更新该文g的内容,使得我们修改配置的时候无需重新启动 Apache 服务器?/p> <p>其中W二、三个配|文件名都可以自定义。下面是一个典型的 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 目录下新Z个文件分别是 workers.properties、uriworkermap.properties。这两个文g的内容大概如?/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 配置是我们前面那个屏幕抓图的页面所用的配置。首先我们配|了(jin)两个cd?ajp13 ?worker 分别?s1 ? s2Q它们指向同一台服务器上运行在两个不同端口 8109 ?8209 ?Tomcat 上。接下来我们配置?jin)一个类型ؓ(f) lbQ也是负蝲均衡的意思)(j)?workerQ它的名字是 DLOG4JQ这是一个逻辑?workerQ它用来理前面配置的两个物理连?s1 ?s2。最后还配置?jin)一个类型ؓ(f) status ?workerQ这是用来监?JK 本n的模块。有?jin)这三?worker q不够,我们q需要告?JKQ哪?worker 是可用的Q所以就?<strong>worker.list = DLOG4J, status</strong> q行配置?/p> <p>接下来便?URI 的映配|了(jin)Q我们需要指定哪些链接是?Tomcat 处理的,哪些是由 Apache 直接处理的,看看下面q个文g你就能明白其中配|的意义</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>怿你已l明白了(jin)一大半?jin)?x)所有的h都由 DLOG4J q个 worker q行处理Q但是有几个例外Q?jkstatus h?status q个 worker 处理。另外这个配|中每一行数据前面的感叹h什么意思呢Q感叹号表示接下来的 URI 不要?JK q行处理Q也是 Apache 直接处理所有的囄、css 文g、js 文g以及(qing)?rn)?html 文本文g?/p> <p> 通过?workers.properties ?uriworkermap.properties 的配|,可以有各U各L(fng)l合来满x们前面提出对一?web |站的要求。?zhn)不妨动手试试Q?/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 class="fbox"><strong>回页?/strong></a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <br /> <br /> <p><a name="N100CB">http_proxy</a></p> <p>q是利用 Apache 自带?mod_proxy 模块使用代理技术来q接 Tomcat。在配置之前L(fng)保是否用的?2.2.x 版本?Apache 服务器。因?2.2.x 版本对这个模块进行了(jin)重写Q大大的增强?jin)其功能和稳定性?/p> <p>http_proxy 模式是基?HTTP 协议的代理,因此它要?Tomcat 必须提供 HTTP 服务Q也是说必d?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>在这个配|中Q我们把所? http://localhost 的请求代理到 http://localhost:8080/ Q这也就?Tomcat 的访问地址Q除? images、css、js 几个目录除外。我们同样可以利?mod_proxy 来做负蝲均衡Q再看看下面q个配置</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 /> <Proxy balancer://example/><br /> BalancerMember http://server1:8080/<br /> BalancerMember http://server2:8080/<br /> BalancerMember http://server3:8080/<br /> </Proxy><br /> </pre> </td> </tr> </tbody> </table> <br /> <p>配置?JK 单多?jin),而且它也可以通过一个页面来监控集群q行的状态,q做一些简单的l护讄?/p> <br /> <a name="N100F1"><strong>?2Q监控集运行状?/strong></a><br /> <img alt="?2Q监控集运行状? 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 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 q接方式其实?http_proxy 方式一P都是?mod_proxy 所提供的功能。配|也是一P只需要把 http:// 换成 ajp:// Q同时连接的?Tomcat ?AJP Connector 所在的端口。上面例子的配置可以改ؓ(f)Q?/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 /> <Proxy balancer://example/><br /> BalancerMember ajp://server1:8080/<br /> BalancerMember ajp://server2:8080/<br /> BalancerMember ajp://server3:8080/<br /> </Proxy><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.soQ?其中 mod_proxy_ajp.so 只在 Apache 2.2.x 中才有。如果是采用 http_proxy 方式则需要加?mod_proxy.so ?mod_proxy_http.soQ如果是 ajp_proxy 则需要加? mod_proxy.so ?mod_proxy_ajp.soq两个模块?/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 class="fbox"><strong>回页?/strong></a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <br /> <br /> <p><a name="N10116">三者比?/a></p> <p>? 对于 JK 的连接方式,后两U在配置上是比较单的Q灵zL方面也一炚w不逊色。但q定性而言׃?JK q样久经考验Q毕?Apache 2.2.3 推出的时间ƈ不长Q采用这U连接方式的|站q不多,因此Q如果是应用于关键的互联|网站,q是采用 JK 的连接方式?/p> <br /> <br /> <p><a name="resources">参考资?</a></p> <ul> <li> 获得 <a >Apache Http Server</a>? <br /> <br /> </li> <li> 获得 <a >Apache Tomcat</a>? <br /> <br /> </li> <li> <a >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>刘冬Q一直?J2EE/J2ME 从事Ud互联|方面的开发。?zhn)可以通过 Java 自由人网站来跟他联系Q网址是:(x)<a >http://www.dlog.cn/javayou</a> Q另外他的邮件地址?a href="mailto:javayou@gmail.com?cc=">javayou@gmail.com</a>?/p> </td> </tr> </tbody> </table> <img src ="http://www.aygfsteel.com/sealyu/aggbug/215337.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sealyu/" target="_blank">seal</a> 2008-07-16 22:41 <a href="http://www.aygfsteel.com/sealyu/archive/2008/07/16/215337.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> JBoss 4.0.4GA 启动参数解释(转蝲)http://www.aygfsteel.com/sealyu/archive/2008/04/10/191991.htmlsealsealThu, 10 Apr 2008 14:29:00 GMThttp://www.aygfsteel.com/sealyu/archive/2008/04/10/191991.htmlhttp://www.aygfsteel.com/sealyu/comments/191991.htmlhttp://www.aygfsteel.com/sealyu/archive/2008/04/10/191991.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/191991.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/191991.html     -V, --version                                               昄版本信息
      -D<name>[=<value>]                            讄pȝ属?br />     -d, --bootdir=<dir>                                   讄启动补丁目录的位|;必须是绝对\径或者url
    -p, --patchdir=<dir>                                 讄补丁目录的位|;必须是绝对\径或者url
    -n, --netboot=<url>                                  从指定的url|络位置启动
    -c, --configuration=<name>                  指定服务器启动的配置Qdefault、all、minimalQ?br />     -B, --bootlib=<filename>                        其它的jar包添加到bootclasspath的前?br />     -L, --library=<filename>                         其它的jar包添加到 loaders classpath
    -C, --classpath=<url>                            其它的urld到l(f)oaders classpath
    -P, --properties=<url>                           从指定的url加蝲pȝ属?br />     -b, --host=<host or ip>                          所有JBoss Servicel定的地址
    -g, --partition=<name>                          HA分区的名Uͼ~省为DefaultDomainQ?br />     -u, --udp=<ip>                                         UDP的多播地址
    -l, --log=<log4j|jdk>                                讄日志记录插gcd

JBoss 4.0.4GA环境变量

    JBOSS_HOME                                        JBoss的位|?br />     JAVA                                                         Javaq行E序的位|?br />     JAVA_OPTS                                            JVM启动参数
    MAX_FD                                                  JBoss能够使用文g描述W的最大数量(仅用于Un*xQ?/p>

seal 2008-04-10 22:29 发表评论
]]>
վ֩ģ壺 | | żҽ| | | | Ϸ| | ɽʡ| ǰ| ˱| | Դ| | | | ɽ| | Ϫ| | | ƺ| Ǩ| | | ʡ| | | Ͷ| | ˰| Ĵʡ| | | Ľ| Ǹ| | | | | ÷|