JBoss 系列五十:使用Apache httpd(mod_jk)和JBoss构架高可用集群环境
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
概述
前面JBoss 系列二:使用Apache httpd(mod_cluster)和JBoss構(gòu)架高可用集群環(huán)境中我們介紹了企業(yè)應(yīng)用的目的的目的,負(fù)載均衡,容錯(cuò)等,并通過Apache httpd(mod_cluster)和JBoss構(gòu)架高可用集群環(huán)境,我們這里在原有的環(huán)境中將mod_cluster換成mod_jk,其架構(gòu)如下圖所示:
本方案是在開源Linux操作系統(tǒng)Fedora 15上進(jìn)行,我們列出本方案使用的硬件和軟件,三臺(tái)物理機(jī)器,內(nèi)存4GB或以上,安裝Fedora 15后IP地址分別為10.66.192.48,10.66.192.231,10.66.192.232,我們分別對(duì)這三臺(tái)物理機(jī)器做相應(yīng)的安裝如下:
- 10.66.192.231 – 安裝JDK 1.6,JBoss 7,JBoss節(jié)點(diǎn)名稱為node1
- 10.66.192.232 – 安裝JDK 1.6,JBoss 7,JBoss節(jié)點(diǎn)名稱為node2
- 10.66.192.48 ?– 安裝Apache httpd,mod_jk
下載mod_jk相關(guān)安裝包
從http://tomcat.apache.org/download-connectors.cgi下載mod_jk.so包到本地(注意選擇適合自己操作系統(tǒng)對(duì)應(yīng)httpd的包)。
安裝 Apache httpd
請(qǐng)參照系列一?Apache httpd?安裝(http://blog.csdn.net/kylinsoong/article/details/12291173)
Apache httpd端配置
編輯httpd/conf/httpd.conf,讓httpd監(jiān)聽在10.66.192.48:80上:
Listen 10.66.192.48:80 拷貝mod_jk.so文件到httpd/modules目錄:
cp mod_jk.so /etc/httpd/modules在 httpd/conf.d下創(chuàng)建mod_jk.conf文件,編輯內(nèi)容如下:
# Load mod_jk module # Specify the filename of the mod_jk lib LoadModule jk_module modules/mod_jk.so# Where to find workers.properties JkWorkersFile conf/workers.properties# You can use external file for mount points. # # It will be checked for updates each 60 seconds. # # The format of the file is: /url=worker # # /examples/*=loadbalancer JkMountFile conf/uriworkermap.properties# Where to put jk logs JkLogFile logs/mod_jk.log# Set the jk log level [debug/error/info] JkLogLevel info # Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"# JkOptions indicates to send SSK KEY SIZE JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories# JkRequestLogFormat JkRequestLogFormat "%w %V %T"# Mount your applications JkMount /application/* loadbalancer# Add shared memory. # This directive is present with 1.2.10 and # later versions of mod_jk, and is needed for # for load balancing to work properly JkShmFile logs/jk.shm # Add jkstatus for managing runtime data <Location /jkstatus/>JkMount statusOrder deny,allowDeny from allAllow from 127.0.0.1 </Location>在 httpd/conf下創(chuàng)建workers.properties,并添加如下內(nèi)容:
# Define list of workers that will be used # for mapping requests worker.list=loadbalancer,status# Define Node1 # modify the host as your host IP or DNS name. worker.node1.port=8009 worker.node1.host=10.66.192.231 worker.node1.type=ajp13 worker.node1.ping_mode=A worker.node1.lbfactor=1 # Define Node2 # modify the host as your host IP or DNS name. worker.node2.port=8009 worker.node2.host=10.66.192.232 worker.node2.type=ajp13 worker.node2.ping_mode=A worker.node2.lbfactor=1# Load-balancing behavior worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=node1,node2 worker.loadbalancer.sticky_session=1# Status worker for managing load balancer worker.status.type=status 在 httpd/conf下創(chuàng)建uriworkermap.properties,并添加如下內(nèi)容:
# Simple worker configuration file# Mount the Servlet context to the ajp13 worker /jmx-console=loadbalancer /jmx-console/*=loadbalancer /web-console=loadbalancer /web-console/*=loadbalancer #/printSession=loadbalancer #/printSession/*=loadbalancer 配置完成后重啟 Apache httpd ,如果啟動(dòng)顯示成功表明配置正確。
JBoss端配置
分別啟動(dòng)10.66.192.231,10.66.192.232 JBoss,到管理界面,Profile -> General Configuration -> System Properties,單擊添加按鈕,添加兩組變量jvmRoute=node1,UseJK=true到10.66.192.231,以及jvmRoute=node2,UseJK=true到10.66.192.232.添加完成后,依次重啟兩個(gè)節(jié)點(diǎn):
./standalone.sh -c standalone-ha.xml -b 10.66.192.231 -bmanagement=10.66.192.231 -u 239.255.100.100 -Djboss.node.name=node1
./standalone.sh -c standalone-ha.xml -b 10.66.192.232 -bmanagement=10.66.192.232 -u 239.255.100.100 -Djboss.node.name=node2
結(jié)束
至此,配置結(jié)束,我們可以部署測(cè)試應(yīng)用測(cè)試高可用,負(fù)責(zé)均衡等,類似于JBoss 系列二:使用Apache httpd(mod_cluster)和JBoss構(gòu)架高可用集群環(huán)境
轉(zhuǎn)載于:https://my.oschina.net/iwuyang/blog/197160
總結(jié)
以上是生活随笔為你收集整理的JBoss 系列五十:使用Apache httpd(mod_jk)和JBoss构架高可用集群环境的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CommonLang3中的StringU
- 下一篇: Cassandra Dev 1: Cas