JBoss 系列五十:使用Apache httpd(mod_jk)和JBoss构架高可用集群环境
2019獨角獸企業重金招聘Python工程師標準>>>
概述
前面JBoss 系列二:使用Apache httpd(mod_cluster)和JBoss構架高可用集群環境中我們介紹了企業應用的目的的目的,負載均衡,容錯等,并通過Apache httpd(mod_cluster)和JBoss構架高可用集群環境,我們這里在原有的環境中將mod_cluster換成mod_jk,其架構如下圖所示:
本方案是在開源Linux操作系統Fedora 15上進行,我們列出本方案使用的硬件和軟件,三臺物理機器,內存4GB或以上,安裝Fedora 15后IP地址分別為10.66.192.48,10.66.192.231,10.66.192.232,我們分別對這三臺物理機器做相應的安裝如下:
- 10.66.192.231 – 安裝JDK 1.6,JBoss 7,JBoss節點名稱為node1
- 10.66.192.232 – 安裝JDK 1.6,JBoss 7,JBoss節點名稱為node2
- 10.66.192.48 ?– 安裝Apache httpd,mod_jk
下載mod_jk相關安裝包
從http://tomcat.apache.org/download-connectors.cgi下載mod_jk.so包到本地(注意選擇適合自己操作系統對應httpd的包)。
安裝 Apache httpd
請參照系列一?Apache httpd?安裝(http://blog.csdn.net/kylinsoong/article/details/12291173)
Apache httpd端配置
編輯httpd/conf/httpd.conf,讓httpd監聽在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下創建mod_jk.conf文件,編輯內容如下:
# 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下創建workers.properties,并添加如下內容:
# 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下創建uriworkermap.properties,并添加如下內容:
# 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 ,如果啟動顯示成功表明配置正確。
JBoss端配置
分別啟動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.添加完成后,依次重啟兩個節點:
./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
結束
至此,配置結束,我們可以部署測試應用測試高可用,負責均衡等,類似于JBoss 系列二:使用Apache httpd(mod_cluster)和JBoss構架高可用集群環境
轉載于:https://my.oschina.net/iwuyang/blog/197160
總結
以上是生活随笔為你收集整理的JBoss 系列五十:使用Apache httpd(mod_jk)和JBoss构架高可用集群环境的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CommonLang3中的StringU
- 下一篇: Cassandra Dev 1: Cas