- 論壇徽章:
- 0
|
如要轉(zhuǎn)發(fā)請(qǐng)注明lzj65166.cublog.cn
最近一直工作很忙,沒(méi)有時(shí)間來(lái)寫(xiě)這些東東,今天有點(diǎn)時(shí)間就把這個(gè)整理了一點(diǎn)文章,其實(shí)網(wǎng)上有很多了,為什么還要寫(xiě)呢,一個(gè)是為了方便自己查閱,一個(gè)方便初級(jí)者們的安裝吧,看到網(wǎng)上的都是講了一些大體的地方,不是很細(xì),希望我的文章能幫助大家吧。
去哪里下載程序,我就不說(shuō)了,大家自己去官方找吧。
系統(tǒng)環(huán)境:
OS:linux AS4 2.6.9-78.EL
APP: apache httpd-2.2.11.tar.gz
Jboss 4.2.3
需要mod_jk-1.2.28-httpd-2.2.X.so文件
一、Apache的安裝配置
1、解壓apache包
tar zxvf httpd-2.2.11.tar.gz
2、編譯apache
./configure –prefix=/usr/local/apache2 –enable-module=so –enable-module=setenvif –enable-module=rewrite –enable-rewrite=shared –enable-proxy=shared –with-mpm=prefork –enable-so –enable-auth-anon –enable-file-cache=shared –enable-cache=shared –enable-disk-cache=shared –enable-mem-cache=shared
make clean
make make
install
3、修改httpd.conf文件
vi /usr/local/apache2/conf/httpd.confListen80此端口可以根據(jù)實(shí)際情況進(jìn)行修改,此我沒(méi)有修改我使用的是80
User daemon和Group daemon改為
User apache
Group apache
刪除ServerName的#(注釋)此處注意你如何修改了端口,最好加上端口。
4、在linux下建立apache組和用戶
groupadd apache
useradd apache –g apache5、將下載的mod_jk-1.2.28-httpd-2.2.X.so文件修改并拷貝
mv mod_jk-1.2.28-httpd-2.2.X.so mode_jk (進(jìn)行改名)
cp mode_jk /usr/local/apache2/modules (拷貝到這個(gè)modules下)
chmod +x /usr/local/apache2/modules/mode_jk
進(jìn)入到/usr/local/apache2/conf目錄下,修改httpd.conf文件
在httpd.conf最末尾增:
Include conf/mod_jk.conf 檢查httpd.conf里有沒(méi)有
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule status_module modules/mod_status.so
以上內(nèi)容添加如下內(nèi)容
Order deny,allow
allow from all
ProxyPass / balancer://proxy/ stickysession=JSESSIONID nofailover=On lbmethod=byrequests
ProxyPassReverse / balancer://proxy/
BalancerMember ajp://192.168.133.133:8009/ loadfactor=50 route=note1
BalancerMember ajp://192.168.133.233:8009/ loadfactor=50 route=note2
6、新建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
# 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 /*.* loadbalancer
# 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
# 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
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
7、新建workers.properties文件內(nèi)容如下
# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status
# worker.list=loadbalancer,node1,node2
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=192.168.133.133
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.cachesize=100
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host= 192.168.133.233
worker.node2.type=ajp13
worker.node2.lbfactor=1
worker.node2.cachesize=100
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
#1表示使用粘著0表示非粘著
worker.loadbalancer.sticky_session=0
#worker.list=loadbalancer
# Status worker for managing load balancer
worker.status.type=status
說(shuō)明:
上面的文件中配置了兩個(gè)節(jié)點(diǎn),name分別為node1,node2,指定兩個(gè)節(jié)點(diǎn)的IP,并在worker.loadbalancer.balance_workers中指定所有的node列表;worker.loadbalancer.sticky_session設(shè)置是否啟用“粘著的”Session,sticky session是指來(lái)自同一IP的請(qǐng)求將被發(fā)送到同一個(gè)Jboss節(jié)點(diǎn),sticky session設(shè)為0的話同一session的不同請(qǐng)求會(huì)被負(fù)載均衡分發(fā)到不同的jboss節(jié)點(diǎn)上。worker.node1.host、worker.node2.host要改成jboss集群各機(jī)器的實(shí)際IP.
8、新建uriworkermap.properties文件內(nèi)容如下
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer
二、Jboss的安裝配置
1、JDK安裝和環(huán)境變量配置我在這里就不再敘述了,大家可以上網(wǎng)查查,很簡(jiǎn)單。
2、解壓JBOSS包我也不在敘述
3、有關(guān)JBOSS安裝我也不敘述了,我這里直接說(shuō)明有關(guān)JBOSS的配置
4、我在這里jobss以/usr/local/jboss目錄為例
5、修改JBOSS端口和配置文件
進(jìn)入到/usr/local/jboss/server/all/deploy/jboss-web.deployer/目錄下
l 打開(kāi)server.xml文件,修改如下
JBOSS_HOME/server/all/deploy/jboss-web.deployer/server.xml
->
…
以上說(shuō)明,有關(guān)端口使用自己想定義的,此處我用的8080,把a(bǔ)ddress修改同以上一樣,不然啟動(dòng)jboss得到的地址將是127.0.0.1造成無(wú)法訪問(wèn),增加jvmRoute=”node1”此處根據(jù)你的實(shí)際情況修改,每臺(tái)機(jī)器都要修改。
進(jìn)入/usr/local/jboss/server/all/deploy/jboss-web.deployer/META-INF目錄
l 打開(kāi)jboss-service.xml,
找到UseJK,改為true
進(jìn)入到/usr/local/jboss/server/all/deploy/jboss-web-cluster.sar/META-INF/目錄下
l 打開(kāi)jboss-service.xml文件,做如下修改
找到將到全部注釋掉.
找到 將到生效.并對(duì)該部分進(jìn)行修改
(1)將全部down_thread和up_thread的false都改為true.
(2)在后填入本機(jī)的IP,比如
(3)在”后填入本機(jī)和集群其他全部Jboss節(jié)點(diǎn)的IP[7810],比如”192.168.133.133[7810],192.168.133.233[7810]”>
代碼如下:
tcp_nodelay="true"
recv_buf_size="20000000"
send_buf_size="640000"
discard_incompatible_packets="true"
enable_bundling="true"
max_bundle_size="64000"
max_bundle_timeout="30"
use_incoming_packet_handler="true"
use_outgoing_packet_handler="false"
down_thread="true" up_thread="true"
use_send_queues="false"
sock_conn_timeout="300"
skip_suspected_members="true"/>
timeout="3000"
down_thread="true" up_thread="true"
num_initial_members="3"/>
down_thread="true" up_thread="true" min_interval="20000"/>
use_mcast_xmit="false" gc_lag="0"
retransmit_timeout="300,600,1200,2400,4800"
down_thread="true" up_thread="true"
discard_delivered_msgs="true"/>
down_thread="true" up_thread="true"
max_bytes="400000"/>
down_thread="true" up_thread="true"
join_retry_timeout="2000" shun="true"
view_bundling="true"/>
min_threshold="0.10"/>
三、啟動(dòng)測(cè)試
啟動(dòng)時(shí),要先啟動(dòng)apache,再啟動(dòng)jboss節(jié)點(diǎn)1,啟動(dòng)節(jié)點(diǎn)1完成后,再啟動(dòng)節(jié)點(diǎn)2;
jboss啟動(dòng)方式使用./run –c all方式,只有此才是集群,有關(guān)后臺(tái)啟動(dòng)就不有我說(shuō)了吧。呵呵
測(cè)試時(shí),最好先看看apache能不能訪問(wèn),可以了再試試jboss的各個(gè)節(jié)點(diǎn)可不可以訪問(wèn),這樣確保你的jboss都啟動(dòng)正常
好了,多謝大家了,這樣就配置完成了,也多謝網(wǎng)上那些貢獻(xiàn)的朋友們,沒(méi)有他們的幫助我也可能做不出來(lái)。
本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u3/102805/showart_2018809.html |
|