日期:2014-05-17  浏览次数:20971 次

Apache+Jobss cluster安装配置

系统环境:
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此端口可以根据实际情况进行修改,此我没有修改我使用的是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 (进行改名)
cp mode_jk /usr/local/apache2/modules (拷贝到这个modules下)
chmod +x /usr/local/apache2/modules/mode_jk
进入到/usr/local/apache2/conf目录下,修改httpd.conf文件
在httpd.conf最末尾增:
Include conf/mod_jk.conf 检查httpd.conf里有没有
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
以上内容添加如下内容
? ?? ? 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文件文件内容:
#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文件内容如下
# 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
说明:
上面的文件中配置