锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
鍦ㄤ笅闈腑錛屽皢閫氳繃渚嬪瓙鏉ヤ簡瑙reeCache鐨勫姛鑳藉強鍏墮厤緗紝浣跨敤JBossCache1.4鍜孞DK5.0銆傞鍏堟槸涓涓渶鍩烘湰浣跨敤TreeCache
鐨勭▼搴忎緥瀛愬茍閰嶇疆涓涓猅reeCache鐨勯厤緗鏋訛紙鍚勭甯哥敤鐨勯厤緗彲鍙傝jboss-cache-dist-1.4.0.CR1鐗堟湰鐨別tc鐩綍錛屽涓?
鍚勭閰嶇疆鍙傝冧篃鍙璇ョ洰褰曚笅鐨勮寖渚嬮厤緗紝浠ヤ笅涓嶅啀寮鴻皟錛夛紝瑙佷笅錛?
treecache.xml錛?
<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閰嶇疆鍦ㄥ墠闈avaGroups鐨勪粙緇嶈緇嗕粙緇嶏紝鍏跺畠閰嶇疆姣旇緝綆鍗曪紝闇瑕佽繘涓姝ヤ簡瑙h鍙傝TreeCache鏂囨。銆?
涓銆丆ache鍒嗙被
TreeCache鎸夊姛鑳藉垎涓轟笁綾伙細鏈湴(Local)Cache銆佸鍒?Replication)Cache鍜屽け鏁?
(Invalidation)Cache銆傛湰鍦癈ache鍙簲鐢ㄤ簬鏈湴鐜錛屽悗涓や釜Cache鍙簲鐢ㄤ簬鍒嗗竷寮忕幆澧冿紝鍏朵腑錛屽湪鍒嗗竷寮忕幆澧冧腑錛屽鍒禖ache
褰撲竴涓狢ache瀹炰緥鐨勪竴涓妭鐐瑰煎彂鐢熷彉鍖栨椂浼氬皢鍙樺寲澶嶅埗鍒板叾瀹冨疄渚嬩腑錛岃屽け鏁圕ache鏄綋涓涓狢ache瀹炰緥鐨勪竴涓妭鐐瑰煎彂鐢熷彉鍖栨椂浼氬皢鍏跺畠瀹炰緥鐨勭浉
搴旇妭鐐圭殑鍊艱涓虹┖錛岃鍏墮噸鏂板幓鑾峰緱璇ュ鹼紝鍙氳繃榪欑鏂瑰紡緙撳瓨澶у璞′互鍑忓皯鍦ㄥ疄渚嬩腑澶嶅埗瀵硅薄鐨勪唬浠楓傚垎甯冨紡Cache錛堝鍒跺拰澶辨晥Cache錛夊張鍒嗕負涓ょ錛?
鍚屾錛圧EPL_ASYNC錛夊拰寮傛錛圧EPL_SYNC錛夛紝鍚屾Cache鏄湪涓涓狢ache瀹炰緥鍋氫慨鏀規(guī)椂錛岀瓑寰呭彉鍖栧簲鐢ㄥ埌鍏跺畠瀹炰緥鍚庢墠榪斿洖錛岃屽紓姝?
Cache鏄湪涓涓狢ache瀹炰緥鍋氫慨鏀規(guī)椂錛屽嵆鍒昏繑鍥炪傚叾閰嶇疆瑙佷笅錛?
!--
Valid modes are LOCAL
REPL_ASYNC
REPL_SYNC
INVALIDATION_ASYNC
INVALIDATION_SYNC
->
attribute name="CacheMode">REPL_SYNC</attribute>
浜屻佷簨鍔″拰騫惰(Transaction And Concurrent)
TreeCache鏄竴縐嶄簨鍔ache錛屼笌JDBC涓鏍鳳紝鍏跺寘鎷袱鏂歸潰鍐呭錛氶攣鍜岄殧紱葷駭鍒傞攣鍒嗕負鎮(zhèn)茶閿佸拰涔愯閿侊紝褰撲嬌鐢ㄦ?zhèn)茶閿佹椨灱屽垎湄撲簲涓殧绂痪Uу埆錛?
鍒嗗埆鏄疭ERIALIZABLE銆丷EPEATABLE_READ
(default)銆丷EAD_COMMITTED銆丷EAD_UNCOMMITTED鍜孨ONE錛岄殧紱葷駭鍒愭鍑忓急銆備箰瑙傞攣涔熷彨鐗堟湰閿侊紝鍏跺鏁版嵁榪涜鎿?
浣滄椂錛屽皢鍏跺鍒跺埌涓存椂鍖猴紝鎿嶄綔涔嬪悗灝嗙増鏈笌鍘熸湁鏁版嵁姣旇緝錛屽鏋滀竴鑷村垯灝嗛掑鐗堟湰騫跺啓鍥烇紝濡傛灉涓嶄竴鑷村垯鍥炴粴錛岀敱浜庝箰瑙傞攣浠呭湪澶嶅埗鍑烘暟鎹拰鎻愪氦鏁版嵁鏃跺鏁版嵁鍔?
閿侊紝鎵浠ュ茍琛屽害鏇撮珮錛屼絾濡傛灉鍐欐搷浣滄瘮杈冮綣佸湴璇濆垯瀹規(guī)槗鍑虹幇鍐茬獊瀵艱嚧鍥炴粴銆俆reeCache榛樿浣跨敤鎮(zhèn)茶閿併備嬌鐢═reeCache鏃訛紝闇瑕佷嬌鐢ㄥ鍣ㄦ彁渚?
鐨勪簨鍔$鐞嗗櫒錛屼竴鑸嬌JBossTransactionManagerLookup鍜孏enericTransactionManagerLookup錛?
鍓嶈呭簲鐢ㄤ簬JBOSS鏈嶅姟鍣紝鍚庤呭簲鐢ㄤ簬鍏朵粬鏈嶅姟鍣紝涔熷彲浣跨敤DummyTransactionManagerLookup鐢ㄤ簬嫻嬭瘯銆傚涓婁粙緇嶇殑閰嶇疆濡?
涓嬶細
attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
<attribute
name="IsolationLevel">REPEATABLE_READ</attribute>
<attribute
name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>
涓夈侀愬嚭絳栫暐(Eviction Policy)
鐢變簬鍐呭瓨鏁伴噺鐨勫眬闄愶紝涓嶅彲鑳藉皢鎵鏈夌殑Cache鏁版嵁瀛樻斁鍦ㄥ唴瀛樹腑錛屼絾浣跨敤鍐呭瓨杈懼埌涓瀹氭瀬闄愭椂錛屼細灝嗛儴鍒嗘暟鎹竻闄ゅ嚭鍐呭瓨錛屼繚瀛樺埌鍏跺畠鎸佷箙濯掕川涓紝瀹氫箟鐨勪粈涔?
鏃跺欐竻闄ゃ佸浣曟竻闄ょ殑絳栫暐灝辨槸閫愬嚭絳栫暐銆傝嚜瀹氫箟涓涓愬嚭絳栫暐闇瑕佸疄鐜皁rg.jboss.cache.eviction.EvictionPolicy銆?
org.jboss.cache.eviction.EvictionAlgorithm銆?
g.jboss.cache.eviction.EvictionQueue
鍜宱rg.jboss.cache.eviction.EvictionConfiguration鍥涗釜鎺ュ彛錛岀郴緇熸彁渚涗簡LRU(Least
recently used錛屾渶榪戞渶灝戜嬌鐢?銆丩FU(Least Frequently Used鏈涓嶇粡甯鎬嬌鐢?銆丗IFO(First In
First Out鍏堣繘鍏堝嚭)銆丮RU(Most Recently
Used鏈榪戞渶緇忓父浣跨敤)鍥涚瀹炵幇錛岃緇嗗弬瑙乷rg.jboss.cache.eviction鍖呯殑婧愪唬鐮併傞厤緗涓嬶細
<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>
鍥涖丆ache鍔犺澆
鐢變簬閫愬嚭絳栫暐鐨勫瓨鍦紝閭d箞褰撴垜浠噸鏂伴渶瑕佽幏寰椾竴涓師鏉ュ湪緙撳瓨涓絾紜敱鍐呭瓨鍘熷洜琚愬嚭鐨勬暟鎹椂錛屽氨闇瑕佸畾涔変竴縐嶅姞杞界瓥鐣ワ紝浣垮湴鍙互閲嶆柊鎵懼洖鏁版嵁錛屽悓
鏃訛紝Cache鍔犺澆涔熻偐璐熷湪灝嗘暟鎹愬嚭鏃跺皢鏁版嵁淇濆瓨鍒版寔涔呭獟璐ㄧ殑璐d換銆?
鏍規(guī)嵁灝嗘暟鎹繚瀛樺獟璐ㄧ殑涓嶅悓錛孋ache鍔犺澆鍖呮嫭F(xiàn)ileCacheLoader銆丣DBCCacheLoader絳夌瓑錛屽彲浠ュ悓鏃朵嬌鐢ㄥ縐嶅姞杞藉櫒鏉ョ伒媧誨畾鍒?
鍔犺澆絳栫暐銆備緥瑙佷笅錛?
<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銆傝緇嗘儏鍐靛彲鍙傝僇Boss TreeCache鍙傝冩枃妗e拰鑼冧緥銆?
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();
]]>
緗戠粶璁塊棶娑堟伅: 鏃犳硶鏄劇ず姝ら〉
鎶鏈俊鎭?渚涙敮鎸佷漢鍛樹嬌鐢?
閿欒浠g爜: 502 Proxy Error銆俆he 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
鍏朵腑鐨処P鍦板潃鏄垜浠叕鍙鎬唬鐞嗙殑鍦板潃錛屾湇鍔″櫒鏄叕鍙鎬唬鐞嗘湇鍔″櫒銆?br />
鍦ㄧ綉涓婃病鏈夋壘鍒拌В鍐蟲柟娉曪紝緇忚繃鍒嗘瀽閿欒淇℃伅錛屽彂鐜板緢澶氬疄鐢?43绔彛鑰屼笉鏄痶omcat鐨?443绔彛鏉ヨ闂甋SL緗戝潃錛屼慨鏀逛簡tomcat涓嬬殑server.xml鏂囦歡錛屾灉鐒墮棶棰樿В鍐熾?br />
]]>
]]>
2). 瀹夎tomcat 6 ;
浜屻侀厤緗繃紼?br />
1.鐢熸垚 server key 錛?br />
浠ュ懡浠よ鏂瑰紡鍒囨崲鍒扮洰褰?tomcat_HOME%錛屽湪command鍛戒護琛岃緭鍏ュ涓嬪懡浠わ紙jdk1.4浠ヤ笂甯︾殑宸ュ叿錛夛細
keytool -genkey -alias tomcat -keyalg RSA -keypass changit -storepass changit -keystore server.keystore -validity 3600
鐢ㄦ埛鍚嶈緭鍏ュ煙鍚嶏紝濡俵ocalhost錛堝紑鍙戞垨嫻嬭瘯鐢級鎴杊ostname.domainname(鐢ㄦ埛鎷ユ湁鐨勫煙鍚?錛屽叾瀹冨叏閮ㄤ互 enter 璺寵繃錛屾渶鍚庣‘璁わ紝
姝ゆ椂浼氬湪%JAVA_HOME%/bin涓嬬敓鎴恠erver.keystore 鏂囦歡銆?br />
娉細鍙傛暟 -validity 鎸囪瘉涔︾殑鏈夋晥鏈?澶?錛岀己鐪佹湁鏁堟湡寰堢煭錛屽彧鏈?0澶┿?br />
2.灝嗚瘉涔﹀鍏ョ殑JDK鐨勮瘉涔︿俊浠誨簱涓?
榪欐瀵逛簬tomcat鐨凷SL閰嶇疆涓嶆槸蹇呴』錛屼絾瀵逛簬CAS
SSO鏄繀欏葷殑錛屽惁鍒欎細鍑虹幇濡備笅閿欒錛歟du.yale.its.tp.cas.client.CASAuthenticationException:
Unable to validate ProxyTicketValidator銆傘傘?br />
瀵煎叆榪囩▼鍒?姝ワ紝絎竴姝ユ槸瀵煎嚭璇佷功錛岀浜屾鏄鍏ュ埌璇佷功淇′換搴擄紝鍛戒護濡備笅錛?br />
keytool -export -trustcacerts -alias tomcat -file server.cer -keystore server.keystore -storepass changit
keytool -import -trustcacerts -alias tomcat -file server.cer -keystore
%JAVA_HOME%/jre/lib/security/cacerts -storepass changeit
濡傛灉鏈夋彁紺猴紝杈撳叆Y灝卞彲浠ヤ簡銆?br />
鍏朵粬鏈夌敤keytool鍛戒護錛堝垪鍑轟俊浠昏瘉涔﹀簱涓墍鏈夊凡鏈夎瘉涔︼紝鍒犻櫎搴撲腑鏌愪釜璇佷功錛夛細
keytool -list -v -keystore %JAVA_HOME%/jre/lib/security/cacerts
keytool -delete -trustcacerts -alias tomcat -keystore %JAVA_HOME%/jre/lib/security/cacerts -storepass changit
3.閰嶇疆tomcat :
淇敼%TOMCAT_HOME%"conf"server.xml錛屼互鏂囧瓧緙栬緫鍣ㄦ墦寮錛屾煡鎵捐繖涓琛岋細
xml 浠g爜
灝嗕箣鍚庣殑閭f鐨勬敞閲婂幓鎺夛紝騫跺姞涓?keystorePass鍙妅eystoreFile灞炴с?br />
娉ㄦ剰錛宼omcat涓嶅悓鐗堟湰閰嶇疆鏄笉鍚岀殑:
tomcat4.1.34閰嶇疆錛?br />
xml
浠g爜 <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閰嶇疆錛?br />
xml 浠g爜
<Connector port="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="server.keystore"
keystorePass="changit"/>
tomcat5.5.20閰嶇疆(姝ら厤緗悓鏍峰彲鐢ㄤ簬tomcat6.0)錛?br />
xml 浠g爜
<Connector protocol="org.apache.coyote.http11.Http11Protocol"
port="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="server.keystore"
keystorePass="changit"/>
tomcat6.0.10閰嶇疆錛?br />
xml 浠g爜
<Connector protocol="org.apache.coyote.http11.Http11NioProtocol"
port="8443" minSpareThreads="5" maxSpareThreads="75"
enableLookups="true" disableUploadTimeout="true"
acceptCount="100" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="server.keystore"
keystorePass="changit"/>
tomcat6鏀寔3縐嶏紝璇峰弬鑰冧互涓嬫枃妗o細
http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html
4.楠岃瘉閰嶇疆
璁塊棶 https://localhost:8443/
<connector protocol="org.apache.coyote.http11.Http11NioProtocol"></connector>
5. 濡傛灉榛樿鎯崇敤HTTPS 鏂瑰紡榪涜緗戠珯, 鍙互浣滃涓嬮厤緗?
涓鑸琓omcat榛樿鐨凷SL绔彛鍙鋒槸8443錛屼絾鏄浜嶴SL鏍囧噯绔彛鍙鋒槸443錛?br />
榪欐牱鍦ㄨ闂綉欏電殑鏃跺欙紝鐩存帴浣跨敤https鑰屼笉闇瑕佽緭鍏ョ鍙e彿灝卞彲浠ヨ闂紝濡?a href="https://localhost/">https://localhost
1).non-SSL HTTP/1.1 Connector瀹氫箟鐨勫湴鏂癸紝涓鑸涓嬶細
<Connector port="80" maxHttpHeaderSize="8192" scheme="https"
maxThreads="500" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
灝嗗叾涓殑redirectPort绔彛鍙鋒敼涓猴細443
2).SSL HTTP/1.1 Connector瀹氫箟鐨勫湴鏂癸紝淇敼绔彛鍙蜂負錛?43錛屽涓嬶細
<Connector
port="443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25"
maxSpareThreads="75"
enableLookups="false"
disableUploadTimeout="true"
acceptCount="100" scheme="https"
secure="true"
clientAuth="false" sslProtocol="TLS"
SSLEnabled="true"
keystoreFile="e:/server.keystore"
keystorePass="changit" />
3).AJP 1.3 Connector瀹氫箟鐨勫湴鏂癸紝淇敼redirectPort涓?43錛屽涓嬶細
<Connector port="8009"
enableLookups="false" redirectPort="443" protocol="AJP/1.3" />
濡備笂閰嶇疆濂藉悗渚垮彲浠ョ敤 Https://localhost 鏂瑰紡鐩存帴璁塊棶,鏃犻渶杈撳叆绔彛鍙?
涓夈佸弬鑰冭祫鏂?br />
1. Keytool浣跨敤鎸囧崡錛?br />
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/keytool.html
2. tomcat-ssl閰嶇疆鎸囧崡錛?br />
http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html
http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html
2.鐒跺悗淇敼ejb3.deployer涓璲boss-service.xml鏂囦歡錛屼富瑕佹槸娣誨姞鍩熷悕鍒?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鍚姩閫夐」錛屾坊鍔爎mi-server鐨勫閮ㄥ湴鍧鍜岀鐢ㄦ湰鍦板煙鍚嶈В鏋愬埌鍚姩鑴氭湰
Windows鑴氭湰渚嬶細set JAVA_OPTS=-Djava.rmi.server.hostname= external IP -Djava.rmi.server.useLocalHostname=false
Unix鑴氭湰渚嬶細娣誨姞鍒癹boss鍚姩閰嶇疆鏂囦歡run.conf涓嵆鍙?/p>
4.鐢╮un.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鍙互璁塊棶涓庢湰鏈篒P涓嶈兘璁塊棶
瑙e喅鏂瑰紡錛?
淇敼JBOSS_HOME"server"default"deploy"jboss-web.deployer涓嬬殑server.xml 灝哸ddress鏀逛負0.0.0.0鎴栬呬綘鐨勫疄闄匢P 閲嶅惎 JBOSS 鐒跺悗灝卞彲浠ラ氳繃ip璁塊棶銆?/p>
(3)鍦╳indows 瀹㈡埛绔皟鐢?Linux 鏈嶅姟绔?閬囧埌org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://127.0.0.1:3873/]
瑙e喅鏂規(guī)硶: 淇敼 JBOSS_HOME/server/default/deploy/ejb3.deployer/META-INF/jboss-services.xml 鏂囦歡涓殑${jboss.bind.address}:3873 涓簂inux_home_ip:3873
浠ヤ笂涓や釜闂涔熷彲浠ラ氳繃浠ヤ笅璁劇疆瑙e喅錛?
For Windows, use
run.bat -b 0.0.0.0
for Linux use
run.sh -b 0.0.0.0
鍦ㄥ惎鍔↗BOSS鑺傜偣鍓嶏紝瑕佹紜?/span>瀹夎SUN JDK1.5
騫惰緗幆澧冨彉閲?JAVA_HOME
瑙e帇緙㎎BOOS-TGZ鍖?/font>
cd $JBOSS_HOME/bin
nohup ./run.sh -c vcom -b 0.0.0.0 –u 229.12.12.12&
鍙傛暟璇存槑錛?/span>
-c: 鎸囧畾榪愯鐨勯厤緗紝default閰嶇疆涓嶅甫闆嗙兢鏀寔,all 鍜岃嚜瀹氫箟鐨剉com鐩綍閰嶇疆甯︽湁闆嗙兢鏀寔鍔熻兘
-b: 鎸囧畾鏈嶅姟緇戝畾鐨処P鍦板潃錛屽嵆瀵瑰鏈嶅姟鐨処P鍦板潃錛?.0.0.0琛ㄧず瀵規(guī)満鍣ㄤ笂鎵鏈夌殑IP鎻愪緵鏈嶅姟
-u 鎸囧畾鏈嶅姟浣跨敤鐨刄DP緇勬挱鍦板潃
緙栧啓鑴氭湰鍐呭濡備笅錛?/font>
#!/bin/bash
for i in ` ps -ef | grep -w java |grep -v grep |awk '{print $2 ""t"$3}'`;do kill -9 $i
done
瀹夎濂絡(luò)boss騫跺惎鍔╦boss鍚庯紝鍦ㄦ祻瑙堝櫒紿楀彛鐨勫湴鍧鏍忛噷閿叆 http://localhost:8080/jmx-console錛坖boss榛樿鐨勭鍙e彿涓?080,鍙互鑷畾涔変慨鏀癸級銆?/span>灝卞彲浠ユ祻瑙?jboss鐨勯儴緗茬鐞嗙殑涓浜涗俊鎭紝榛樿鎯呭喌涓嬩笉閿叆浠諱綍鐢ㄦ埛鍚嶅拰瀵嗙爜灝卞彲浠ヨ繘鍏ユ欏甸潰錛屾柟渚挎槸鏂逛究錛屼絾鐪熸浣跨敤璧鋒潵榪樻槸鏈夌偣瀹夊叏闅愭?zhèn)eQ屽洜涓轟笉綆′換浣曚漢鍙鐭ラ亾server鐨刬p 閮藉彲浠ヨ繘鍘昏闂備笅闈㈡垜浠拡瀵規(guī)闂瀵筳boss榪涜閰嶇疆錛屼嬌寰楄闂甹mx-console涔熷繀欏?瑕佺煡閬撶敤鎴峰悕鍜屽瘑鐮佹墠鍙繘鍘昏闂?
2.1 璁劇疆jmx-console瀹夊叏璁劇疆
1. 榪涘叆jmx-console.war錛岄氬父姝ょ洰褰曞湪$JBOSS_HOME/server/vcom/deploy鐩綍涓嬨?/span>
2. 緙栬緫璇ョ洰褰曚笅鐨?WEB-INF/web.xml錛屾妸<security-constraint>閮ㄥ垎娉ㄩ噴鍘繪帀 3.緙栬緫$jboss_home/server/vcom/conf/props鐩綍涓嬬殑jmx-console-roles.properties鍜宩mx-console-users.properties錛?/span>
1) users.properties鏂囦歡閲屽畾涔夌敤鎴峰悕鍜屽瘑鐮侊紝鏍煎紡涓簎sername=password銆傚彲浠ヤ緷鐓ф鏍煎紡娣誨姞澶氫釜鐢ㄦ埛銆?
2) roles.propertie鏂囦歡閲屽畾涔夌敤鎴峰悕鍜岃鑹詫紝鏍煎紡涓簎sername=role銆傝繖閲岀殑role蹇呴』鍜寃eb.xml鏂囦歡閲岀殑<role-name>鐩稿搴斻?
4. 緙栬緫/WEB-INF/jboss-web.xml鏂囦歡錛屾墦寮<security-domain>閮ㄥ垎娉ㄩ噴錛涜繖閲?lt;security- domain>鍐呭瀵瑰簲鐨剆ecurity-domain瀵瑰簲$jboss_home"server"vcom"conf"login-config.xml榪欎釜jaas閰嶇疆鏂囦歡閲岀殑鏌愪釜application-policy銆?
濡?
<security-domain>java:/jaas/jmx-console</security-domain>
鍦╨ogin-config.xml閲屽搴旀湁錛?/span>
<application-policy name = "jmx-console">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag = "required" />
</authentication>
</application-policy>
5錛庨噸鍚痡boss錛屽湪嫻忚鍣ㄤ腑閿叆鎺у埗鍙板湴鍧錛屽氨浼氬嚭鐜拌緭鍏sername鍜宲assword鐨勬彁紺虹獥鍙c?
浣跨敤http://localhost:8080/jmx-console,浣跨敤鍚嶄負jboss.cache:service=TomcatClustering MBean Members鍙互鏌ョ湅褰撳墠鏈虹兢鑺傜偣鎴愬憳淇℃伅錛屼嬌鐢╦boss.cache:service=TomcatClustering錛屽彲浠ョ湅鍒板綋鍓嶉泦緹ょ殑鑺傜偣ip,鍦╩ember 涓欏逛腑錛屽彲浠ヨ瀵熷埌褰撳墠闆嗙兢涓妭鐐筰p,濡傚浘錛?/font>
鍦ㄦ欏甸潰涓嬫壘鍒?/span>java.lang.String printDetails() 錛?/span>
invoke the printDetails鎿嶄綔錛岀偣鍑籭nvoke錛屽彲浠ュsession澶嶅埗榪涜鐩戞帶銆?/span>
鐩墠搴旂敤浣跨敤鐨勬暟鎹簱榪炴帴鏄簲鐢ㄧ▼搴忚嚜甯︾殑JDBC 錛圓PI錛夋帴鍙o紝閰嶇疆濡備笅錛?/span>
Cd /$JBOSS_HOME/server/vcom/deploy/*.war/WEB-INF/class/
Vi proxool.xml
<?xml version="1.0" encoding="UTF-8"?>
<datasource>
<proxool>
<alias>pool</alias>
<driver-url>jdbc:oracle:thin:@192.168.104.32:1521:cportal</driver-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver-properties>
<property name="user" value="cportal"/>
<property name="password" value="cportal"/>
</driver-properties>
<house-keeping-sleep-time>30000</house-keeping-sleep-time>
<minimum-connection-count>0</minimum-connection-count>
<maximum-connection-count>300</maximum-connection-count>
<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
</proxool>
</datasource>
(1) jdbc:oracle:thin:@192.168.104.32:1521:cportal錛宱racle鏈嶅姟绔彛鏄?521錛宑portal涓烘暟鎹簱鐨勫疄渚嬪悕鍗硈id銆?/span>
(2) <property name="user" value="cportal"/>
<property name="password" value="cportal"/> 涓烘暟鎹簱鐨勭敤鎴峰悕鍜屽瘑鐮?/span>
錛?錛?/span><maximum-connection-count>300</maximum-connection-count>涓哄鎴風(fēng) 鏈澶х殑鏁版嵁搴撹繛鎺ユ暟
浣跨敤JBOSS涓棿浠舵椂,榛樿鐨勮闂鍙f槸8080錛屽彲浠ヤ慨鏀歸棶浣犳兂浣跨敤鐨勭鍙o紝淇敼姝ラ濡備笅錛?/font>
鎵撳紑JBOSS鐩綍$JBOSS_HOME/server/vcom/deploy/jboss-web.deployer/涓嬬殑server.xml鏂囦歡,鎼滅儲8080,灝?080鏀逛負鏂扮殑绔彛鍙?淇濆瓨鏂囦歡,閲嶅惎搴旂敤鏈嶅姟鍣ㄥ嵆鍙?璁塊棶鏃朵嬌鐢ㄦ柊鐨勭鍙e彿.
<Connector port="80" address="${jboss.bind.address}"
maxThreads="150" maxHttpHeaderSize="8192"
emptySessionPath="true" protocol="HTTP/1.1"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
鍏朵腑150鏄疛VM涓惎鍔ㄧ殑鏈澶х嚎紼嬫暟錛?00 涓篔VM杈懼埌鏈澶х嚎紼嬮榾鍊兼椂錛屽彲浠ユ斁鍦ㄩ槦鍒椾腑鐨凥TTP璇鋒眰鏁?/font>
濡傛灉闇瑕佺洃鎺boss鐨勭郴緇熻祫婧愶紝濡傦細jboss鐨勫熀鏈厤緗儏鍐碉紝jvm鐨勫埄鐢ㄧ巼錛岀嚎紼嬫睜鐨勪嬌鐢ㄦ儏鍐碉紝鍙互浣跨敤web-console榪涜鐩戞帶銆?/span>
鍏蜂綋鏂規(guī)硶鍚宩mx-console錛屽氨鏄綅緗笉鍚岋紝鍏蜂綋鏂規(guī)硶鍙傝僯mx-console閰嶇疆錛?/font>
· jboss-web.xml銆亀eb.xml鍦?JBOSS_HOME/vcom/deploy/management/console-mgr.sar/web-console.war/WEB-INF涓嬶紱
· login-config.xml榪樻槸鍘熸潵鐨勯偅涓紝鎶奱pplication-policy鍚嶄負$webConsoleDomain鐨勯儴鍒嗘敼鎴愪綘闇瑕佺殑web-console錛?/span>
· web-console-users.properties銆亀eb-console-roles.properties瀹氫箟浜嗚闂?web-console鐨勭敤鎴楓佺敤鎴瘋鑹詫紝鍏蜂綋浣嶇疆鑷繁鍘繪壘錛屼嬌鐢╢ind /jboss -name web-console-users.properties 鎵懼埌浠ュ悗鍙互淇敼鐢ㄦ埛鍚嶃佸瘑鐮併?/span>
浣跨敤http://localhost:8080/web-console/ 涓紝鑾峰彇褰撳墠JBOSS-WEB搴旂敤妯″潡鐨勮礋杞藉垎鎷呮儏鍐碉紝騫跺彲浠ユ煡鐪嬪埌褰撳墠JAVA铏氭嫙鏈虹殑鍐呭瓨浣跨敤鎯呭喌錛屽強綰跨▼姹犱嬌鐢ㄦ儏鍐點?/font>
浣跨敤http://localhost:8080/web-console/status錛屽彲浠ヨ繘涓姝ョ洃鎺у埌姣忎釜綰跨▼鐨勭姸鎬併?/font>
鍦?/span>$JBOSS_HOME /server/vcom/log涓嬶紝鏈夊叧浜巎boss鐨勬棩蹇楄褰曪紝 鍏朵腑server.log鏄敤鏉ヨ褰旿BOOS榪愯榪囩▼鐨勬棩蹇楄褰?boot.log鐢ㄦ潵璁板綍JBOOS鍚姩淇℃伅鐨勶紝鍑虹幇闂鏃跺彲浠ラ氳繃sever.log瀵筳boss榪涜鍒嗘瀽銆?/span>
$JBOSS_HOME /server/vcom/conf涓嬬殑jboss-log4j.xml錛屽彲浠ュ鏃ュ織鐨勬潵婧愬拰綰у埆榪涜瀹氫箟錛屼篃鍙互瀹氫箟鏃ュ織鐨勮褰曟柟寮忋?/span>
鍙互鎶妀boss-log4j.xml涓渶鍚庢湁鍏砪luster.log鐨凙PPENDER娉ㄩ噴鎺夛紝緋葷粺榪愯鏃朵細鍦╨og鐩綍涓嬩駭鐢焎luster.log鏂囦歡錛屽彲浠ラ氳繃姝ゆ枃浠跺闆嗙兢鏁呴殰榪涜鍒嗘瀽銆傚湪嫻嬭瘯璋冭瘯榪囩▼鍙互浣跨敤姝ゆ棩蹇?/font>
Jboss鏃ュ織璁板綍鏂瑰紡鏈?縐嶏細
1錛?/font> 鎸夋棩鏈熻繘琛岃褰?/font>
2錛?/font> 鎸夋棩蹇楁枃浠剁殑澶у皬榪涜璁板綍
鐩墠浣跨敤鐨勬槸鎸夌収澶у皬淇℃伅璁板綍銆傚鏋滆淇敼璁板綍鏂瑰紡錛岀洿鎺ョ紪杈慾boss-log4j.xml鏂囦歡錛屽皢姝ゆ娉ㄩ噴鍘繪帀銆?/font>
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/server.log"/>
<param name="Append" value="false"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
…………………………………………………
……………………………………………………………………….
</layout>
</appender>
鍚屾椂灝嗕笅孌墊敞閲婃帀
<!-- A size based file rolling appender-->
<appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/server.log"/>
<param name="Append" value="false"/>
<param name="MaxFileSize" value="500KB"/>
<param name="MaxBackupIndex" value="1"/>
……………………………………………………………
…………………………………………………………
</layout>
</appender>
涓嬨?/span>涓銆?span style="font-weight: normal; font-size: 10.5pt; font-family: '瀹嬩綋';">淇敼鏁版嵁搴撶殑榪炴帴鏂瑰紡
1銆侀噰鐢ㄦ暟鎹簮鐨勫艦寮?br />
鍦?nbsp;tomcat 涓厤緗暟鎹簮鏂瑰紡濡備笅:
鍦ㄧ敓鎴愮殑欏圭洰鍚岀駭鐩綍涓壘姝ゆ枃浠訛細 context.xml
Servers/Tomcat 銆傘傘?/font>/context.xml 浣滃涓嬮厤緗細
鍦ㄦ爣絳?nbsp;<Context> 涓棿鍔犲叆:
<Resource
name="jdbc/demo" auth="Container" type="javax.sql.DataSource"
maxActive="30" maxIdle="5" maxWait="10000" username="root"
password="admin" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-8">
</Resource>
2銆?span style="font-weight: normal; font-size: 10.5pt; font-family: '瀹嬩綋';">浣跨敤闈炴暟鎹簮鐨勫艦寮?br />
鍦ㄦ枃浠訛細persistence.xml 涓坊鍔?/font>hibernate 鐨勮繛鎺ユ暟鎹簱鐨勬柟寮忥紝濡備笅錛?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 閰嶇疆鏂囦歡 persistence.xml
1銆?/span>濡傛灉鏁版嵁鐨勮繛鎺ユ柟寮忛噰鐢ㄦ暟鎹簮鐨勫艦寮忥紝鍒欏彧闇淇敼閲岄潰鏁版嵁婧愮殑鍚嶇О錛屽錛?br /> <jta-data-source>java:comp/env/jdbc/demo</jta-data-source>
2銆佸鏋滈噰鐢?font face="Times New Roman">hibernate
鐨勮繛鎺ユ柟寮忥紝鍒欐妸姝よ鍒犱簡銆?/font> 3銆?span style="font-weight: normal; font-size: 10.5pt; font-family: '瀹嬩綋';">鍒犻櫎閲岄潰鐨勬琛岄厤緗細
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
4銆佷慨鏀逛簨鍔$殑絳栫暐鏂瑰紡涓?RESOURCE_LOCAL 錛?nbsp;
<persistence-unit name="demo" transaction-type="RESOURCE_LOCAL">
涓夈?span style="font-weight: normal; font-size: 10.5pt; font-family: '瀹嬩綋';">閰嶇疆 Seam 鐨勪簨鍔$鐞嗗櫒
鍦?nbsp;component.xml 鏂囦歡鍔犲叆錛?br />
<transaction:entity-transaction entity-manager="#{entityManager}"/>
榛樿鐢熸垚鐨勬鏂囦歡鏄笉鍚湁 transaction 鐨勫懡鍚嶇┖闂達紝闇瑕佹墜鍔ㄥ湪姝ゆ枃浠跺姞鍏ュ畠鐨勫懡鍚嶇┖闂達細
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>
Transaction timeout (unit is always seconds) can be configured in various ways:
This argument is the same no matter if you are using JBossTM(<=4.0.5) or JBossJTA-Arjuna(>=4.2).
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)
Version <= 4.0.5
This part is the same for either JBossTM or JBossJTA and is the same for ejb2 and ejb3
Per-method basis: Modifying the <transaction-timeout> 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:
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:
@TransactionTimeout(1500)
P1:Tomcat6鍚姩鐨勬椂鍊欏嚭鐜頒笅闈㈣繖鏍風(fēng)殑鎻愮ず錛?/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:瀹為檯榪欐槸寤鴻浣跨敤apache鐨刟pr;apr 鏄痑pache portable runtime 鐢ㄤ笂榪欎釜鍚庡彲浠ユ湁鏁堢殑鎻愰珮tomcat澶勭悊闈欐侀〉闈㈢殑鑳藉姏.濡傛灉鎯充嬌鐢╝pr鐨勮瘽錛?瀹為檯鎿嶄綔寰堢畝鍗曪紝
涓嬭澆 http://tomcat.heanet.ie/native/1.1.1/binaries/win32/tcnative-1.dll
灝嗚繖涓枃浠跺鍒跺埌C:\WINDOWS\system32\涓嬮潰,鐒跺悗閲嶆柊鍚姩tomcat錛屽氨浼氬彂鐜皌omcat 鐨勬帶鍒跺彴淇℃伅涓猴細
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.
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.
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).
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.
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.
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.
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.
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>
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:
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.
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 Apache causes a segmentation fault, there are two probable causes, neither of which has to do with Django itself.
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.
浣跨敤 apache 鍜?/span> tomcat 閰嶇疆涓涓彲浠ュ簲鐢ㄧ殑 web 緗戠珯錛岃杈懼埌浠ヤ笅瑕佹眰錛?/span>
1銆?nbsp;Apache 鍋氫負 HttpServer 錛屽悗闈㈣繛鎺ュ涓?/span> tomcat 搴旂敤瀹炰緥錛屽茍榪涜璐熻澆鍧囪 銆?/span>
2銆?nbsp;涓虹郴緇熻瀹?/span> Session 瓚呮椂鏃墮棿錛屽寘鎷?/span> Apache 鍜?/span> tomcat
3銆?nbsp;涓虹郴緇熷睆钄芥枃浠跺垪琛紝鍖呮嫭 Apache 鍜?/span> tomcat
涓嶈涓嬭澆瀹夎鐗?/span> , 涓嬭澆鍦板潃
鎴戜滑闇瑕佸湪涓鍙版満鍣ㄤ笂璺?/span> 2 涓笉鍚岀殑 tomcat 錛岄渶瑕佷慨鏀逛笉鍚岀殑 tomcat 鐨勫叧闂彛錛岄伩鍏嶅嚭鐜扮鍙h鍗犵敤鐨勬儏鍐點傚湪 server.xml 涓壘鍒?/span> server, 灝嗭細
<Server port="8005" shutdown="SHUTDOWN">
鏀逛負
<Server port="XXXX" shutdown="SHUTDOWN">
XXXX 鍦ㄨ繖閲岃〃紺轟笉鍚岀殑绔彛錛氭垜鐨勪袱涓?/span> tomcat 鍒嗗埆浣跨敤 8035 錛?/span> 8045
娉ㄦ剰錛氳繖閲屼箣鎵浠ヨ閰嶇疆涓嶅悓鐨?/span> tomcat 鍏抽棴鍙o紝鍙槸鍥犱負鎴戜滑浣跨敤浜嗗涓?/span> tomcat 錛屽叾瀹炵敤涓涓?/span> server 澶氫釜瀹炰緥涔熷彲浠ャ?/span>
鎴戜滑闇瑕佸涓嶅悓鐨?/span> tomcat 鐨?/span> service 鍙栦笉鍚岀殑鍚嶅瓧錛屽湪 server.xml 涓壘鍒幫細
<Service name="Catalina">
鏀逛負錛?/span>
<Service name="XXXX">
涓や釜 service 鍒嗗埆涓?/span> tomcat6 鍜?/span> tomcat5
榪欎釜閮ㄥ垎涓昏鏄鏀逛袱涓?/span> Connector 錛屽綋鐒跺墠鎻愭槸浣犵殑 tomcat 鍙湁涓や釜 Connector 銆?/span>
淇敼 ajp1.3 鐨勭鍙o細
鎵懼埌錛?/span> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
鏀逛負錛?/span> <Connector port="XXXX" protocol="AJP/1.3" redirectPort="8443" />
涓や釜 Service 鐨?/span> ajp/1.3 鐨勭鍙e垎鍒負錛?/span> 8019 錛?/span> 8029
淇敼 http 鐨勭鍙o細
鎵懼埌錛?/span>
<Connector port="8080" protocol="HTTP/1.1"
maxThreads="150" connectionTimeout="20000"
redirectPort="8443" />
鏀逛負錛?/span>
<Connector port="XXXX" protocol="HTTP/1.1"
maxThreads="150" connectionTimeout="20000"
redirectPort="8443" />
涓や釜 Service 鐨?/span> ajp/1.3 鐨勭鍙e垎鍒負錛?/span> 8060 錛?/span> 8070
Engine 涓昏鏄厤緗?/span> jvmRoute 灞炴э紝鎵懼埌錛?/span>
<Engine name="Catalina" defaultHost="localhost">
鏀逛負錛?/span>
<Engine jvmRoute="XXXX" name="Catalina" defaultHost="localhost">
涓や釜瀹炰緥鍒嗗埆涓猴細 tomcat6 鍜?/span> tomcat5.
濡傛灉鏈?/span> Context 鏄涓郴緇熷叕鐢ㄧ殑錛屾瘮濡傚浘鐗囩瓑鐨勫瓨鏀懼湴錛屽彲浠ュ仛涓厤緗細
鍦?/span> Host 涓鍔狅細
<Context path="/image" docBase="D:"webRoot"image" debug="0" reloadable="false" crossContext="true">
</Context>
鎵撳紑 tomcat 鐩綍涓嬬殑 conf/web.xml 錛?/span>
鎵懼埌錛?/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 鍙傛暟鏀逛負 false;
瀵圭郴緇熷簲鐢ㄥ仛浜涙帶鍒躲?/span>
閰嶇疆 session 榪囨湡鏃墮棿錛屽ぇ澶氭暟緗戠珯鐢ㄦ埛閮藉彧鏄仛浜涙祻瑙堟х殑鎿嶄綔錛屼負浜嗗噺杞繪湇鍔″櫒璐熻澆鍘嬪姏錛屾垜浠皢 session 瓚呮椂鏃墮棿浠庨粯璁ょ殑 30 鍒嗛挓鍙樹負 5 鍒嗛挓銆?/span>
鍦?/span> web 搴旂敤紼嬪簭鐨?/span> web.xml 涓?/span> servlet-mapping 涔嬪悗澧炲姞濡備笅涓孌碉細
<session-config>
<session-timeout>5</session-timeout>
</session-config>
涓嬭澆鍦板潃 http://httpd.apache.org/download.cgi
涓嬭澆鍚庣偣鍑誨畨瑁?/span> msi 鏂囦歡銆?/span>
瀹夎鐨勬椂鍊欐病鏈変粈涔堢壒鍒渶瑕佹敞鎰忕殑鍦版柟錛屾寜鐓ч粯璁ゅ氨琛屼簡銆傛槸鍚﹀畨瑁呬負 service 鐪嬪叿浣撴儏鍐佃屽畾銆?/span>
http://tomcat.apache.org/download-connectors.cgi
娉ㄦ剰錛屽緢澶氱綉绔欎笂閮戒粙緇嶆槸 JK2 錛屽彲鑳芥槸瑙夊緱 JK2 姣?/span> JK 瑕佹柊鍚э紝鍏跺疄 JK2 宸茬粡鍋滄鐮斿彂浜嗭紝寤鴻浣跨敤 jk1.2 銆?/span>
涓嬭澆鍘嬬緝鍖咃紝涔嬪悗灝?/span> module 鐩綍涓殑 mod_jk-apache****.so 鏂囦歡鏀懼叆 /module/ 鐩綍涓嬨?/span>
鎵懼埌
Listen 80
鏀逛負
Listen **
褰撶劧濡傛灉涓嶉渶瑕佹敼鐨勮瘽錛屽氨涓嶇敤鏀逛簡銆傛甯告儏鍐墊棤欏繪洿鏀廣?/span>
鎵懼埌 DocumentRoot 孌碉紝灝嗗叾鏀逛負錛?/span>
DocumentRoot "E:/MyWebsite"
榪欓噷鐨?/span> "E:/MyWebsite" 鎸囩殑鏄綘鐨?/span> web 紼嬪簭鐨勬牴璺緞錛岃鍏蜂綋搴旂敤鑰屽畾銆?/span>
鎵懼埌 serverName 榪欎釜孌碉紝灝嗗叾閰嶇疆涓轟綘鐨?/span> ServerName
濡傛灉娌℃湁閰嶇疆涓哄煙鍚嶏紝閰嶄負 IP 涔熷彲浠ワ紝姝ゅ榪樹笉鏄緢娓呮錛屽铏氭嫙涓繪満鐨勬儏鍐電殑閰嶇疆銆?/span>
<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>
鎴戜滑闇瑕佷笌 tomcat 鍋氳繛鎺ワ紝鎵浠ヨ鎶?/span> tomcat 鐨?/span> connector 鐨勬ā鍧楅厤緗繘鍘匯?/span>
鍦?/span> LoadModule 閮ㄥ垎鍔犲叆錛?/span>
LoadModule jk_module modules/mod_jk-apache-2.0.55.so 錛嶅姞杞芥ā鍧?/span>
榪欎釜 so 鏄垜涓嬭澆鐨勭増鏈紝涓漢鍙互鏍規(guī)嵁鑷繁涓嬭澆鐨勬枃浠跺悕鍔犱互閰嶇疆
JkWorkersFile conf/workers.properties 錛嶆寚瀹?/span> connector 鐨勯厤緗枃浠跺悕縐?/span>
JkLogFile logs/mod_jk.log 錛嶆寚瀹?/span> connector 鐨勬棩蹇楁枃浠跺悕縐?/span>
JkLogLevel info 錛嶆寚瀹?/span> connector 鐨勬棩蹇楃瓑綰?/span>
瀹氫箟鍒楄〃
worker.list=tomcat6,tomcat5,loadbalancer
瀹氫箟涓涓悕涓?/span> “loadbalancer” 鐨?/span> worker
鍏朵綔涓哄澶氫釜 Tomcat 榪涚▼鐨勮礋杞藉鉤琛′嬌鐢細
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat5, tomcat6
錛?/span> 璐熻澆騫寵 綾誨瀷鐨?/span> worker 騫朵笉涓?/span> Tomcat worker 閫氳錛屽畠璐熻矗綆$悊榪欎簺 Tomcat worker 銆?/span> 錛?/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
娉ㄦ剰錛?/span> lbfactor= 50 錛?/span> 褰撴 Tomcat worker 琚敤浜庝竴涓礋杞藉鉤琛?/span> worker 浣跨敤鏃訛紝姝ゅ睘鎬у皢琚嬌鐢ㄣ傚畠瀹氫箟浜嗘 worker 鐨勮礋杞藉鉤琛℃潈鍊箋?/span> 錛?/span>
cachesize= 10 錛?/span> 褰撳湪澶氱嚎紼嬬殑 web server 錛堜緥濡?/span> apache2.0 銆?/span> IIS 銆?/span> Netscape 錛変腑浣跨敤 JK 鏃訛紝姝ゅ睘鎬ф槸鏈夋晥鐨勩傚鏋滃皢 cachesize 鐨勫艱緗負杈冮珮鐨勫鹼紝榪欎簺鏀寔澶氱嚎紼嬬殑 web server 灝嗚幏寰楀緢濂界殑澶勭悊鑳藉姏銆傚鏋滄灞炴т笉琚緗紝鍒欒繛鎺?/span> cache 鐗規(guī)у皢澶辨晥銆?/span> 錛?/span>
鍦?/span> DocumnetRoot 鐗囨涓嬪姞鍏?/span>
JkMount /*.jsp tomcat6
JkMount /*.do tomcat6
JkMount /*Servlet tomcat6
榪欓噷鍙槸綆鍗曠殑灝?/span> apache 鐨勮姹傝漿鍒板叾涓殑涓涓?/span> tomcat 涓紝褰㈡垚妗ユ帴錛岃嚦浜庤礋杞藉潎琛$殑鏃跺欙紝灝辨棤欏昏繘琛岃繖姝ユ搷浣滐紝鐩存帴鍚姩璐熻澆鍧囪 銆傚惎鍔ㄨ礋杞藉潎琛¤涓嬩竴鑺傘?/span>
鍦?/span> DocumnetRoot 鐗囨涓嬪姞鍏?/span>
JkMount /*.jsp loadbalancer
JkMount /*.do loadbalancer
JkMount /*Servlet loadbalancer
錛嶆寚瀹氬鎵鏈夌殑璇鋒眰鍚姩璐熻澆鍧囪 錛岃繖閲岀殑 loadbalancer 鏄?span style="color: #ff6600">瀹氫箟鐨?/span> worker 鐨勫悕瀛?/span>
榪欓噷鎴戝湪閰嶇疆鐨勬椂鍊欑姱浜嗕袱涓敊璇細
絎竴鏄病鏈夐厤緗?/span> JkWorkersFile conf/workers.properties 錛屼互涓?/span> Apache 浼氳嚜鍔ㄨ璇嗭紙鍏跺疄 apache 鏄嚜鍔ㄤ駭鐢熶簡涓涓彨鍋?/span> ajp13 鐨?/span> worker 錛屾寚鍚戞湰鏈虹殑 8009 绔彛錛夈?/span>
絎簩鏄互涓?/span> JkMount 璇彞涓嚭鐜?/span> loadbalancer,ajp13 涔嬬被鐨勬槸緋葷粺璁懼畾鐨勪笢瑗匡紝鍏跺疄閮芥槸鍦?/span> workers.properties 鏂囦歡涓畾涔夌殑錛岀粨鏋滃嚭鐜板悕瀛椾笉鍖歸厤鐨勬儏鍐點傚悗鏉ラ厤緗簡 JkLogFile logs/mod_jk.log 涔嬪悗鐪嬪埌閿欒鏃ュ織鎵嶆槑鐧姐?/span>
浣跨敤 Apache2.1 浠ヤ笂鐨勭増鏈紝灝卞彲浠ョ敤 mod_proxy_ajp 鏉ュ畬鎴愯礋杞藉潎琛$殑閰嶇疆錛屼笉榪囧埌鐩墠涓烘錛屾病鏈夌湅鍒板浣曡 Apache 璐熻矗闈欐侀儴鍒嗭紝 tomcat 璐熻矗鍔ㄦ侀儴鍒嗙殑閰嶇疆鏂瑰紡錛屽彧鑳界敤 path 榪涜鍖哄垎鍒嗗彂璇鋒眰銆傚錛氬湪铏氭嫙涓繪満鐨勯厤緗腑澧炲姞錛?/span>
ProxyPass / ajp://localhost:8019/
ProxyPassReverse / ajp://localhost:8019/
鑰屽艦濡傦細
ProxyPass /*.jsp ajp://localhost:8019/
ProxyPassReverse /*.jsp ajp://localhost:8019/
榪欐牱鐨勯厤緗槸涓嶈兘閫氳繃鐨勩?/span>
1銆?br />
PermGen space鐨勫叏縐版槸Permanent Generation space,鏄寚鍐呭瓨鐨勬案涔呬繚瀛樺尯鍩烵utOfMemoryError: PermGen space浠庤〃闈笂鐪嬪氨鏄唴瀛樼泭鍑猴紝瑙e喅鏂規(guī)硶涔熶竴瀹氭槸鍔犲ぇ鍐呭瓨銆傝璇翠負浠涔堜細鍐呭瓨鐩婂嚭錛氳繖涓閮ㄥ垎鐢ㄤ簬瀛樻斁Class鍜孧eta鐨勪俊鎭?Class鍦ㄨ Load鐨勬椂鍊欒鏀懼叆PermGen space鍖哄煙錛屽畠鍜屽拰瀛樻斁Instance鐨凥eap鍖哄煙涓嶅悓,GC(Garbage Collection)涓嶄細鍦ㄤ富紼嬪簭榪愯鏈熷PermGen space榪涜娓呯悊錛屾墍浠ュ鏋滀綘鐨凙PP浼歀OAD寰堝CLASS鐨勮瘽,灝卞緢鍙兘鍑虹幇PermGen space閿欒銆傝繖縐嶉敊璇父瑙佸湪web鏈嶅姟鍣ㄥJSP榪涜pre compile鐨勬椂鍊欍?/p> 鏀規(guī)鏂規(guī)硶錛?Xms256m -Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256m
2銆?/p>
鍦╰omcat涓璻edeploy鏃跺嚭鐜皁utofmemory鐨勯敊璇?
鍙互鏈変互涓嬪嚑涓柟闈㈢殑鍘熷洜:
錛?浣跨敤浜?u>proxool,鍥犱負proxool鍐呴儴鍖呭惈浜嗕竴涓佺増鏈殑cglib.
2, log4j,鏈濂戒笉鐢?鍙敤common-logging
3, 鑰佺増鏈殑cglib,蹇偣鏇存柊鍒版渶鏂扮増銆?/font>
錛旓紝鏇存柊鍒版渶鏂扮殑hibernate3.2
PermGen space鐨勫叏縐版槸Permanent Generation space,鏄寚鍐呭瓨鐨勬案涔呬繚瀛樺尯鍩?
榪欏潡鍐呭瓨涓昏鏄JVM瀛樻斁Class鍜孧eta淇℃伅鐨?Class鍦ㄨLoader鏃跺氨浼氳鏀懼埌PermGen space涓?
瀹冨拰瀛樻斁綾誨疄渚?Instance)鐨凥eap鍖哄煙涓嶅悓,GC(Garbage Collection)涓嶄細鍦ㄤ富紼嬪簭榪愯鏈熷
PermGen space榪涜娓呯悊錛屾墍浠ュ鏋滀綘鐨勫簲鐢ㄤ腑鏈夊緢澶欳LASS鐨勮瘽,灝卞緢鍙兘鍑虹幇PermGen space閿欒,
榪欑閿欒甯歌鍦╳eb鏈嶅姟鍣ㄥJSP榪涜pre compile鐨勬椂鍊欍傚鏋滀綘鐨刉EB APP涓嬮兘鐢ㄤ簡澶ч噺鐨勭涓夋柟jar, 鍏跺ぇ灝?br />
瓚呰繃浜唈vm榛樿鐨勫ぇ灝?4M)閭d箞灝變細浜х敓姝ら敊璇俊鎭簡銆?br />
瑙e喅鏂規(guī)硶錛?鎵嬪姩璁劇疆MaxPermSize澶у皬
淇敼TOMCAT_HOME/bin/catalina.sh
鍦?#8220;echo "Using CATALINA_BASE: $CATALINA_BASE"”涓婇潰鍔犲叆浠ヤ笅琛岋細
JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m
寤鴻錛氬皢鐩稿悓鐨勭涓夋柟jar鏂囦歡縐葷疆鍒皌omcat/shared/lib鐩綍涓嬶紝榪欐牱鍙互杈懼埌鍑忓皯jar 鏂囨。閲嶅鍗犵敤鍐呭瓨鐨勭洰鐨勩?/p>
浜屻乯ava.lang.OutOfMemoryError: Java heap space
Heap size 璁劇疆
JVM鍫嗙殑璁劇疆鏄寚java紼嬪簭榪愯榪囩▼涓璊VM鍙互璋冮厤浣跨敤鐨勫唴瀛樼┖闂寸殑璁劇疆.JVM鍦ㄥ惎鍔ㄧ殑鏃跺欎細鑷姩璁劇疆Heap size鐨勫鹼紝
鍏跺垵濮嬬┖闂?鍗?Xms)鏄墿鐞嗗唴瀛樼殑1/64錛屾渶澶х┖闂?-Xmx)鏄墿鐞嗗唴瀛樼殑1/4銆傚彲浠ュ埄鐢↗VM鎻愪緵鐨?Xmn -Xms -Xmx絳夐夐」鍙?br />
榪涜璁劇疆銆侶eap size 鐨勫ぇ灝忔槸Young Generation 鍜孴enured Generaion 涔嬪拰銆?br />
鎻愮ず錛氬湪JVM涓鏋?8錛呯殑鏃墮棿鏄敤浜嶨C涓斿彲鐢ㄧ殑Heap size 涓嶈凍2錛呯殑鏃跺欏皢鎶涘嚭姝ゅ紓甯鎬俊鎭?br />
鎻愮ず錛欻eap Size 鏈澶т笉瑕佽秴榪囧彲鐢ㄧ墿鐞嗗唴瀛樼殑80錛咃紝涓鑸殑瑕佸皢-Xms鍜?Xmx閫夐」璁劇疆涓虹浉鍚岋紝鑰?Xmn涓?/4鐨?Xmx鍊箋?
瑙e喅鏂規(guī)硶錛氭墜鍔ㄨ緗瓾eap size
淇敼TOMCAT_HOME/bin/catalina.sh
鍦?#8220;echo "Using CATALINA_BASE: $CATALINA_BASE"”涓婇潰鍔犲叆浠ヤ笅琛岋細
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:MaxNewSize=256m"
涓夈佸疄渚嬶紝浠ヤ笅緇欏嚭1G鍐呭瓨鐜涓媕ava jvm 鐨勫弬鏁拌緗弬鑰冿細
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true "
涓夈佺浉鍏寵祫鏂?/p>
鍦ㄦ暣鍚圓pache鍜孴omcat涔嬪悗錛屽彂鐜拌鏈嶅姟鍣ㄧ殑涓や釜緗戠珯涓涓槸闈欐佺殑錛屼竴涓槸鍔ㄦ乯sp鐨勶紝璁劇疆鎬葷粨濡備笅
涓昏璁劇疆httpd.conf
1銆丏irectoryIndex鐨勮緗?/p>
濡傛灉澶氫釜铏氭嫙绔欑偣涓寘鍚縐嶆枃浠舵牸寮忓拰鏂囦歡鍚嶇殑棣栭〉鏂囦歡錛屽繀欏誨湪榪欓噷鍏ㄩ儴鍑虹幇
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>
錛侊紒 鍦ㄨ繖閲岋紝NameVirtualHost鐨勫瓧孌典笉鑳界渷鐣ワ紝鍚﹀垯璧穉pache鏃舵姤閿欙細VirtualHost 220.231.32.*.80 overlaps with VirtualHost 220.231.32.*:80, the first has precedence, perhaps you need a NameVirtualHost directive鈥斺旇櫧鐒禷pache鑳借搗錛屽悓閿欒鎻忚堪涓鏍鳳紝絎簩涓珯鐐圭殑瀹氫箟琚涓涓珯鐐圭殑瀹氫箟鎵瑕嗙洊錛屽嵆璁塊棶絎簩涓珯鐐規(guī)寚鍚戠殑鍏跺疄鏄涓涓?/p>
錛侊紒
NameVirtualHost瀛楁鐨勭鍙e彿涓嶈兘蹇界暐錛屽惁鍒欒搗apache鏃舵姤閿欙細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鈥斺攁pache涓嶈兘璧?/p>
錛侊紒濡傛灉VirtualHost 瀛楁鐨勭鍙e彿紜疄錛岃搗apache鏃舵姤閿欙細VirtualHost 220.231.32.28:0 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results鈥斺斾絾apache鍙互鍚姩錛岃闂篃姝e父
鑷姩鍖栭厤緗殑鍓嶆彁鏄彧鏈変竴涓?Tomcat 瀹炰緥鍜?Apache 鍦ㄥ悓涓鍙版満鍣ㄤ笂榪愯銆傝嚜鍔ㄥ寲閰嶇疆鏄氳繃鍦?Tomcat 鐨勯厤緗枃浠?server.xml 涓殑 Engine 鍏冪礌涓坊鍔犵浉搴旂殑 ApacheConfig 鐩戝惉鍣?Listener)鏉ュ疄鐜扮殑銆?/span>
涓嬮潰鏄叿浣撶殑閰嶇疆錛?/span>
絎竴姝ワ細涓嬭澆騫跺畨瑁?Apache httpd鍜?Tomcat
涓嬭澆騫跺畨瑁?Apache 2.2.9 鍜?Tomcat 5.5.26錛屽亣璁句粬浠殑瀹夎鐩綍濡備笅錛?/span>
D:/apps/Apache/Apache2.2
D:/apps/Apache/apache-tomcat-5.5.26
榪欎袱涓湇鍔″櫒鍙互鍦ㄤ互涓嬪湴鍧涓嬭澆錛?/span>
Tomcat:
http://apache.osuosl.org/tomcat/tomcat-5/v5.5.26/bin/apache-tomcat-5.5.26.zip
Apache:
http://apache.osuosl.org/httpd/binaries/win32/apache_2.2.9-win32-x86-openssl-0.9.8h-r2.msi
絎簩姝ワ細涓嬭澆騫跺畨瑁?mod_jk.so
mod_jk 鐨勪笅杞藉湴鍧濡備笅錛?/span>
http://apache.osuosl.org/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.26/mod_jk-1.2.26-httpd-2.2.4.so
涓嬭澆鍚庡皢鍏墮噸鍛藉悕騫跺鍒跺埌鍒?D:/apps/Apache/Apache2.2/modules 涓?/span>
絎笁姝ワ細鍒涘緩 workers.properties 鏂囦歡
workers.properties 瀹氫箟浜嗘瘡涓?worker 鐨勭被鍨嬨佸崗璁佺鍙g瓑淇℃伅銆傚鏋滄墜涓婃病鏈夌幇鎴愮殑閰嶇疆鏂囦歡錛屽彲浠ヤ嬌鐢ㄤ互涓嬫渶綆鍗曠殑閰嶇疆錛?/span>
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
灝嗚繖涓枃浠舵斁鍦?Tomcat 涓嬬殑 conf/jk 鐩綍涓紝濡傛灉鏀懼湪鍏朵粬鍦版柟錛屽垯闇瑕佸湪 server.xml 鐨勯厤緗腑鏄庣‘鎸囧畾銆?/span>
絎洓姝ワ細淇敼 Tomcat server.xml 鏂囦歡
鎵懼埌涓嬮潰榪欒鍐呭騫跺湪鍚庨潰娣誨姞閰嶇疆淇℃伅錛?/span>
<Engine name="Catalina" defaultHost="localhost">
閰嶇疆淇℃伅濡備笅錛?/span>
<Listener className="org.apache.jk.config.ApacheConfig"
workersConfig="conf/workers.properties"
modJk="D:/apps/Apache/Apache2.2/modules/mod_jk.so"
jkLog="logs/mod_jk.log"
jkDebug="info"
jkWorker="worker1"
noRoot="true"
/>
鍏朵腑錛?/span>
絎簲姝ワ細淇敼 Apache httpd.conf 鏂囦歡
鎵懼埌 httpd.conf 鏂囦歡騫跺湪鏈鍚庡姞涓婂涓嬮厤緗細
#To be added at the end of your httpd.conf
Include $TOMCAT_HOME/conf/auto/mod_jk.conf
瑕佹敞鎰忕殑鏄紝榪欓噷 Include 鍚庨潰鐨勮礬寰勫繀欏繪紜紝榪欓噷 $TOMCAT_HOME 鏄?Tomcat 瀹夎鐩綍錛孌:/apps/Apache/apache-tomcat-5.5.26銆?/span>
絎叚姝ワ細閲嶅惎 Tomcat 騫惰嚜鍔ㄧ敓鎴?mod_jk.conf
閲嶅惎 Tomcat錛岄噸鍚垚鍔熷悗浼氬湪鍏?conf 涓嬮潰鐢熸垚 mod_jk.conf 鏂囦歡錛岃繖涓厤緗枃浠跺氨鏄湪 httpd.conf 涓鐢ㄥ埌鐨勯偅涓紝榪欎釜鏂囦歡鐨勮礬寰勫繀欏誨拰鍦?httpd.conf 涓殑涓鑷淬備笅闈㈡槸鐢熸垚鐨勪竴涓猰od_jk.conf錛?/span>
########## Auto generated on Sun Jun 29 11:21:57 CST 2008##########
<IfModule !mod_jk.c>
LoadModule jk_module "D:/apps/Apache/Apache2.2/modules/mod_jk.so"
</IfModule>
JkWorkersFile "D:/apps/Apache/apache-tomcat-5.5.26/conf/workers.properties"
JkLogFile "D:/apps/Apache/apache-tomcat-5.5.26/logs/mod_jk.log"
JkLogLevel info
<VirtualHost localhost>
ServerName localhost
JkMount /webdav worker1
JkMount /webdav/* worker1
JkMount /servlets-examples worker1
JkMount /servlets-examples/* worker1
JkMount /tomcat-docs worker1
JkMount /tomcat-docs/* worker1
JkMount /jsp-examples worker1
JkMount /jsp-examples/* worker1
JkMount /balancer worker1
JkMount /balancer/* worker1
</VirtualHost>
絎竷姝ワ細鍚姩 Apache 騫舵祴璇曢厤緗?/span>
Apache 鍚姩瀹屾垚鍚庯紝嫻嬭瘯濡備笅鍦板潃錛?/span>
濡傛灉欏甸潰鑳芥甯告樉紺猴紝璇存槑閰嶇疆鎴愬姛錛佸鏋滃嚭鐜?/span> internal server error 涔嬬被鐨勯敊璇紝璇存槑涓婇潰鐨勯厤緗湁璇紝闇瑕佹鏌ュ茍嫻嬭瘯銆?/span>
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.
Several reasons:
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.
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. |
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.
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.
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.
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:
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.
Build mod_jk.so. Following are three techniques you can try, in order of simplicity:
# JAVA_INCLUDE="-I ${JAVA_HOME}/include -I ${JAVA_HOME}/include/linux"
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!.
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.
This section details the configuration that is required for the Apache Web Server to support mod_jk.
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!
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:
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] "
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".
You can use the JkMount directive at the top level or inside <VirtualHost> sections of your httpd.conf file.JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /otherworker/*.jsp remoteworker
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:
Example:
...
<AutoWebApp dir="webapps" host="DEFAULT" />
<ApacheConfig confighome="/home/mydir" />
...
<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.
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.
. |
# Setup for Solaris system |
# Load mod_jk |
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
# 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.
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
棣栧厛鎴戜滑鍏堜粙緇嶄竴涓嬩負浠涔堣璁? Apache 涓?Tomcat 涔嬮棿榪涜榪炴帴銆備簨瀹炰笂 Tomcat 鏈韓宸茬粡鎻愪緵浜?HTTP 鏈嶅姟錛岃鏈嶅姟榛樿鐨勭鍙f槸 8080錛岃濂? tomcat 鍚庨氳繃 8080 绔彛鍙互鐩存帴浣跨敤 Tomcat 鎵榪愯鐨勫簲鐢ㄧ▼搴忥紝浣犱篃鍙互灝嗚绔彛鏀逛負 80銆?/p>
鏃㈢劧 Tomcat 鏈韓宸茬粡鍙互鎻愪緵榪欐牱鐨勬湇鍔★紝鎴戜滑涓轟粈涔堣繕瑕佸紩鍏?Apache 鎴栬呭叾浠栫殑涓浜涗笓闂ㄧ殑 HTTP 鏈嶅姟鍣ㄥ憿錛熷師鍥犳湁涓嬮潰鍑犱釜錛?/p>
1. 鎻愬崌瀵歸潤鎬佹枃浠剁殑澶勭悊鎬ц兘
2. 鍒╃敤 Web 鏈嶅姟鍣ㄦ潵鍋氳礋杞藉潎琛′互鍙婂閿?/p>
3. 鏃犵紳鐨勫崌綰у簲鐢ㄧ▼搴?/p>
榪? 涓夌偣瀵逛竴涓?web 緗戠珯鏉ヨ鏄潪甯鎬箣閲嶈鐨勶紝鎴戜滑甯屾湜鎴戜滑鐨勭綉绔欎笉浠呮槸閫熷害蹇紝鑰屼笖瑕佺ǔ瀹氾紝涓嶈兘鍥犱負鏌愪釜 Tomcat 瀹曟満鎴栬呮槸鍗囩駭紼嬪簭瀵艱嚧鐢ㄦ埛璁塊棶涓嶄簡錛岃岃兘瀹屾垚榪欏嚑涓姛鑳界殑銆佹渶濂界殑 HTTP 鏈嶅姟鍣ㄤ篃灝卞彧鏈?apache 鐨?http server 浜嗭紝瀹冭窡 tomcat 鐨勭粨鍚堟槸鏈绱у瘑鍜屽彲闈犵殑銆?/p>
鎺ヤ笅鏉ユ垜浠粙緇嶄笁縐嶆柟娉曞皢 apache 鍜?tomcat 鏁村悎鍦ㄤ竴璧楓?/p>
榪欐槸鏈甯歌鐨勬柟寮忥紝浣犲彲浠ュ湪緗戜笂鎵懼埌寰堝鍏充簬閰嶇疆JK鐨勭綉欏碉紝褰撶劧鏈鍏ㄧ殑榪樻槸鍏跺畼鏂規(guī)墍鎻愪緵鐨勬枃妗c侸K 鏈韓鏈変袱涓増鏈垎鍒槸 1 鍜?2錛岀洰鍓?1 鏈鏂扮殑鐗堟湰鏄?1.2.19錛岃岀増鏈?2 鏃╁凡緇忓簾寮冧簡錛屼互鍚庝笉鍐嶆湁鏂扮増鏈殑鎺ㄥ嚭浜嗭紝鎵浠ュ緩璁綘閲囩敤鐗堟湰 1銆?/p>
JK 鏄氳繃 AJP 鍗忚涓?Tomcat 鏈嶅姟鍣ㄨ繘琛岄氳鐨勶紝Tomcat 榛樿鐨?AJP Connector 鐨勭鍙f槸 8009銆侸K 鏈韓鎻愪緵浜嗕竴涓洃鎺т互鍙婄鐞嗙殑欏甸潰 jkstatus錛岄氳繃 jkstatus 鍙互鐩戞帶 JK 鐩墠鐨勫伐浣滅姸鎬佷互鍙婂鍒?tomcat 鐨勮繛鎺ヨ繘琛岃緗紝濡備笅鍥炬墍紺猴細
鍦? 榪欎釜鍥句腑鎴戜滑鍙互鐪嬪埌褰撳墠JK閰嶄簡涓や釜榪炴帴鍒嗗埆鍒?8109 鍜?8209 绔彛涓婏紝鐩墠 s2 榪欎釜榪炴帴鏄仠姝㈢姸鎬侊紝鑰?s1 榪欎釜榪炴帴鑷笂嬈¢噸鍚悗宸茬粡澶勭悊浜?47 涓囧涓姹傦紝嫻侀噺杈懼埌 6.2 涓?G錛屾渶澶х殑騫跺彂鏁版湁 13 絳夌瓑銆傛垜浠篃鍙互鍒╃敤 jkstatus 鐨勭鐞嗗姛鑳芥潵鍒囨崲 JK 鍒頒笉鍚岀殑 Tomcat 涓婏紝渚嬪灝?s2 鍚敤錛屽茍鍋滅敤 s1錛岃繖涓湪鏇存柊搴旂敤紼嬪簭鐨勬椂鍊欓潪甯告湁鐢紝鑰屼笖鏁翠釜鍒囨崲榪囩▼瀵圭敤鎴鋒潵璇存槸閫忔槑鐨勶紝涔熷氨杈懼埌浜嗘棤緙濆崌綰х殑鐩殑銆傚叧浜?JK 鐨勯厤緗枃绔犵綉涓婂凡緇忛潪甯稿浜嗭紝榪欓噷鎴戜滑涓嶅啀璇︾粏鐨勪粙緇嶆暣涓厤緗繃紼嬶紝浣嗘垜瑕佽涓涓嬮厤緗殑鎬濊礬錛屽彧瑕佹槑鐧戒簡閰嶇疆鐨勬濊礬錛孞K 灝辨槸涓涓潪甯哥伒媧葷殑緇勪歡銆?/p>
JK 鐨勯厤緗渶鍏抽敭鐨勬湁涓変釜鏂囦歡錛屽垎鍒槸
httpd.conf
Apache 鏈嶅姟鍣ㄧ殑閰嶇疆鏂囦歡錛岀敤鏉ュ姞杞?JK 妯″潡浠ュ強鎸囧畾 JK 閰嶇疆鏂囦歡淇℃伅
workers.properties
鍒?Tomcat 鏈嶅姟鍣ㄧ殑榪炴帴瀹氫箟鏂囦歡
uriworkermap.properties
URI 鏄犲皠鏂囦歡錛岀敤鏉ユ寚瀹氬摢浜?URL 鐢?Tomcat 澶勭悊錛屼綘涔熷彲浠ョ洿鎺ュ湪 httpd.conf 涓厤緗繖浜?URI錛屼絾鏄嫭绔嬭繖浜涢厤緗殑濂藉鏄?JK 妯″潡浼氬畾鏈熸洿鏂拌鏂囦歡鐨勫唴瀹癸紝浣垮緱鎴戜滑淇敼閰嶇疆鐨勬椂鍊欐棤闇閲嶆柊鍚姩 Apache 鏈嶅姟鍣ㄣ?/p>
鍏朵腑絎簩銆佷笁涓厤緗枃浠跺悕閮藉彲浠ヨ嚜瀹氫箟銆備笅闈㈡槸涓涓吀鍨嬬殑 httpd.conf 瀵?JK 鐨勯厤緗?/p>
# (httpd.conf) |
鎺ヤ笅鏉ユ垜浠湪 Apache 鐨?conf 鐩綍涓嬫柊寤轟袱涓枃浠跺垎鍒槸 workers.properties銆乽riworkermap.properties銆傝繖涓や釜鏂囦歡鐨勫唴瀹瑰ぇ姒傚涓?/p>
# |
浠ヤ笂鐨?workers.properties 閰嶇疆灝辨槸鎴戜滑鍓嶉潰閭d釜灞忓箷鎶撳浘鐨勯〉闈㈡墍鐢ㄧ殑閰嶇疆銆傞鍏堟垜浠厤緗簡涓や釜綾誨瀷涓?ajp13 鐨?worker 鍒嗗埆鏄?s1 鍜? s2錛屽畠浠寚鍚戝悓涓鍙版湇鍔″櫒涓婅繍琛屽湪涓や釜涓嶅悓绔彛 8109 鍜?8209 鐨?Tomcat 涓娿傛帴涓嬫潵鎴戜滑閰嶇疆浜嗕竴涓被鍨嬩負 lb錛堜篃灝辨槸璐熻澆鍧囪 鐨勬剰鎬濓級鐨?worker錛屽畠鐨勫悕瀛楁槸 DLOG4J錛岃繖鏄竴涓昏緫鐨?worker錛屽畠鐢ㄦ潵綆$悊鍓嶉潰閰嶇疆鐨勪袱涓墿鐞嗚繛鎺?s1 鍜?s2銆傛渶鍚庤繕閰嶇疆浜嗕竴涓被鍨嬩負 status 鐨?worker錛岃繖鏄敤鏉ョ洃鎺?JK 鏈韓鐨勬ā鍧椼傛湁浜嗚繖涓変釜 worker 榪樹笉澶燂紝鎴戜滑榪橀渶瑕佸憡璇?JK錛屽摢浜?worker 鏄彲鐢ㄧ殑錛屾墍浠ュ氨鏈?worker.list = DLOG4J, status 榪欒閰嶇疆銆?/p>
鎺ヤ笅鏉ヤ究鏄?URI 鐨勬槧灝勯厤緗簡錛屾垜浠渶瑕佹寚瀹氬摢浜涢摼鎺ユ槸鐢?Tomcat 澶勭悊鐨勶紝鍝簺鏄敱 Apache 鐩存帴澶勭悊鐨勶紝鐪嬬湅涓嬮潰榪欎釜鏂囦歡浣犲氨鑳芥槑鐧藉叾涓厤緗殑鎰忎箟
/*=DLOG4J |
鐩鎬俊浣犲凡緇忔槑鐧戒簡涓澶у崐浜嗭細鎵鏈夌殑璇鋒眰閮界敱 DLOG4J 榪欎釜 worker 榪涜澶勭悊錛屼絾鏄湁鍑犱釜渚嬪錛?jkstatus 璇鋒眰鐢?status 榪欎釜 worker 澶勭悊銆傚彟澶栬繖涓厤緗腑姣忎竴琛屾暟鎹墠闈㈢殑鎰熷徆鍙鋒槸浠涔堟剰鎬濆憿錛熸劅鍙瑰彿琛ㄧず鎺ヤ笅鏉ョ殑 URI 涓嶈鐢?JK 榪涜澶勭悊錛屼篃灝辨槸 Apache 鐩存帴澶勭悊鎵鏈夌殑鍥劇墖銆乧ss 鏂囦歡銆乯s 鏂囦歡浠ュ強闈欐?html 鏂囨湰鏂囦歡銆?/p>
閫氳繃瀵?workers.properties 鍜?uriworkermap.properties 鐨勯厤緗紝鍙互鏈夊悇縐嶅悇鏍風(fēng)殑緇勫悎鏉ユ弧瓚蟲垜浠墠闈㈡彁鍑哄涓涓?web 緗戠珯鐨勮姹傘傛?zhèn)ㄤ笉濡ㄥ姩鎵嬭瘯璇曞Q?/p>
![]() ![]() |
![]()
|
榪欐槸鍒╃敤 Apache 鑷甫鐨?mod_proxy 妯″潡浣跨敤浠g悊鎶鏈潵榪炴帴 Tomcat銆傚湪閰嶇疆涔嬪墠璇風(fēng)‘淇濇槸鍚︿嬌鐢ㄧ殑鏄?2.2.x 鐗堟湰鐨?Apache 鏈嶅姟鍣ㄣ傚洜涓?2.2.x 鐗堟湰瀵硅繖涓ā鍧楄繘琛屼簡閲嶅啓錛屽ぇ澶х殑澧炲己浜嗗叾鍔熻兘鍜岀ǔ瀹氭с?/p>
http_proxy 妯″紡鏄熀浜?HTTP 鍗忚鐨勪唬鐞嗭紝鍥犳瀹冭姹?Tomcat 蹇呴』鎻愪緵 HTTP 鏈嶅姟錛屼篃灝辨槸璇村繀欏誨惎鐢?Tomcat 鐨?HTTP Connector銆備竴涓渶綆鍗曠殑閰嶇疆濡備笅
ProxyPass /images ! |
鍦ㄨ繖涓厤緗腑錛屾垜浠妸鎵鏈? http://localhost 鐨勮姹備唬鐞嗗埌 http://localhost:8080/ 錛岃繖涔熷氨鏄?Tomcat 鐨勮闂湴鍧錛岄櫎浜? images銆乧ss銆乯s 鍑犱釜鐩綍闄ゅ銆傛垜浠悓鏍峰彲浠ュ埄鐢?mod_proxy 鏉ュ仛璐熻澆鍧囪 錛屽啀鐪嬬湅涓嬮潰榪欎釜閰嶇疆
ProxyPass /images ! |
閰嶇疆姣?JK 綆鍗曞浜嗭紝鑰屼笖瀹冧篃鍙互閫氳繃涓涓〉闈㈡潵鐩戞帶闆嗙兢榪愯鐨勭姸鎬侊紝騫跺仛涓浜涚畝鍗曠殑緇存姢璁劇疆銆?/p>
鍥?2錛氱洃鎺ч泦緹よ繍琛岀姸鎬?/strong>
![]() ![]() |
![]()
|
ajp_proxy
榪炴帴鏂瑰紡鍏跺疄璺?http_proxy 鏂瑰紡涓鏍鳳紝閮芥槸鐢?mod_proxy 鎵鎻愪緵鐨勫姛鑳姐傞厤緗篃鏄竴鏍鳳紝鍙渶瑕佹妸 http:// 鎹㈡垚
ajp:// 錛屽悓鏃惰繛鎺ョ殑鏄?Tomcat 鐨?AJP Connector 鎵鍦ㄧ殑绔彛銆備笂闈緥瀛愮殑閰嶇疆鍙互鏀逛負錛?/p>
ProxyPass /images ! |
閲囩敤 proxy 鐨勮繛鎺ユ柟寮忥紝闇瑕佸湪 Apache
涓婂姞杞芥墍闇鐨勬ā鍧楋紝mod_proxy 鐩稿叧鐨勬ā鍧楁湁
mod_proxy.so銆乵od_proxy_connect.so銆乵od_proxy_http.so銆乵od_proxy_ftp.so銆?
mod_proxy_ajp.so錛?鍏朵腑 mod_proxy_ajp.so 鍙湪 Apache 2.2.x 涓墠鏈夈傚鏋滄槸閲囩敤
http_proxy 鏂瑰紡鍒欓渶瑕佸姞杞?mod_proxy.so 鍜?mod_proxy_http.so錛涘鏋滄槸 ajp_proxy 鍒欓渶瑕佸姞杞?
mod_proxy.so 鍜?mod_proxy_ajp.so榪欎袱涓ā鍧椼?/p>
![]() ![]() |
![]()
|
鐩?
瀵逛簬 JK 鐨勮繛鎺ユ柟寮忥紝鍚庝袱縐嶅湪閰嶇疆涓婃槸姣旇緝綆鍗曠殑錛岀伒媧繪ф柟闈篃涓鐐歸兘涓嶉婅壊銆備絾灝辯ǔ瀹氭ц岃█灝變笉鍍?JK 榪欐牱涔呯粡鑰冮獙錛屾瘯绔?Apache
2.2.3 鎺ㄥ嚭鐨勬椂闂村茍涓嶉暱錛岄噰鐢ㄨ繖縐嶈繛鎺ユ柟寮忕殑緗戠珯榪樹笉澶氾紝鍥犳錛屽鏋滄槸搴旂敤浜庡叧閿殑浜掕仈緗戠綉绔欙紝榪樻槸寤鴻閲囩敤 JK 鐨勮繛鎺ユ柟寮忋?/p>
![]() |
||
![]() |
鍒樺啲錛屼竴鐩翠嬌鐢?J2EE/J2ME 浠庝簨縐誨姩浜掕仈緗戞柟闈㈢殑寮鍙戙傛?zhèn)ㄥ彲浠ラ氳繃 Java 鑷敱浜虹綉绔欐潵璺熶粬鑱旂郴錛岀綉鍧鏄細http://www.dlog.cn/javayou 錛屽彟澶栦粬鐨勯偖浠跺湴鍧鏄?a href="mailto:javayou@gmail.com?cc=">javayou@gmail.com銆?/p> |
JBoss 4.0.4GA鐜鍙橀噺
JBOSS_HOME JBoss鐨勪綅緗?br />
JAVA Java榪愯紼嬪簭鐨勪綅緗?br />
JAVA_OPTS JVM鍚姩鍙傛暟
MAX_FD JBoss鑳藉浣跨敤鏂囦歡鎻忚堪絎︾殑鏈澶ф暟閲忥紙浠呯敤浜嶶n*x錛?/p>