win7 系统apache+jboss的集群

   1.下载Apache服务器:( http://www.apache.org),我下载的是apache_2.2.14-win32-x86-openssl-0.9.8k.msi,双击安装即可(若提示先删除的话说明电脑已安装http服务)。
    2.启动http服务,找到${http_home}/bin,点击ApacheMonitor.exe,在电脑右下角有一个apache的标志,右击->start,然后访问: 127.0.0.1:80,出现It works! 说明成功。还有就是修改http的服务端口,默认是80端口,要修改的话在${http_home}/conf/http.conf下修改。
    3.下载mod_jok.so, http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/,访问该网址,根据需要下载对应的mod_jok.so。我下载的是win32/jk-1.2.14/mod_jk-1.2.14-apache-2.0.54.so ,重命名为mod_jok.so。将该文件放在${http_home}/moudles下。
    4.修改httpd.conf,导入mode_jk.conf :Include conf/mod_jk.conf
    5.在${http_home}/conf下新建mod_jk.conf
    
# Load mod_jk module. Specify the filename
# of the mod_jk lib you’ve downloaded and
# installed in the previous section
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
JkWorkersFile conf/workers.properties

# Where to put jk logs
JkLogFile conf/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel error

# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

JkMountFile conf/uriworkermap.properties

     6.在${http_home}/conf下新建uriworkermap.properties

/memcached/*=LoadBalancer
#
# Mount jkstatus to /jkmanager
# For production servers you will need to
# secure the access to the /jkmanager url
#
/jkmanager=jkstatus


     7.在${http_home}/conf下新建workers.properties
worker.list=LoadBalancer,jkstatus
worker.jkstatus.type=status

# Now we define the load-balancing behaviour
worker.LoadBalancer.type=lb
worker.LoadBalancer.balance_workers=node1,node2
worker.LoadBalancer.sticky_session=false
worker.LoadBalancer.method=R
worker.LoadBalancer.retries=2

#该port为jboss实例啊ajp端口
worker.node1.port=8109
worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.fail_on_status=500
worker.node1.cachesize=100
worker.node1.connection_pool_size=50
worker.node1.connection_pool_minsize=25
worker.node1.connection_pool_timeout=600

worker.node2.port=8209
worker.node2.host=localhost
worker.node2.type=ajp13
worker.node2.fail_on_status=500
worker.node2.cachesize=100
worker.node2.connection_pool_size=50
worker.node2.connection_pool_minsize=25
worker.node2.connection_pool_timeout=600


ps:解释一下workers.properties文件
当访问路径为 ip:80/memcached/*,apache将该请求分发到两个服务器node1、node2,node1、node2根据port、host等配置好
       8.修改jboss的配置文件:修改[server root]/deploy/jboss-web.deployer/ META-INF/jboss-service.xml文件中以下配置为true:
<attribute name="UseJK">true</attribute>

       修改[server root]/deploy/jboss-web.deployer/ server.xml中Engine的节点,增加jvmRoute属性:
<Engine name=“jboss.web” defaultHost=“localhost” jvmRoute=“[apache中的节点名字]” >
        9.修改项目的web.xml文件:在末尾添加<distributable/>即可
   启动在两个配置好的jboss,若访问路径为 127.0.0.1:9000/memcached/index.action127.0.0.1:9001/memcached/index.action,通过访问 127.0.0.1/memcached/index.action也能访问成功,则说明成功

猜你喜欢

转载自worina8080.iteye.com/blog/1685062