- 论坛徽章:
- 0
|
也许这个对你有用:
利用mod_jk1.2集成APACHE+JBOSS
1. 下载所需的安装包:
httpd-2.0.46.tar.gz : http://httpd.apache.org/download.cgi
jdk-1_5_0_03-linux-i586-rpm.bin:http://java.sun.com/j2se/1.5.0/download.jsp
jakarta-tomcat-connectors-1.2.10-src.tar.gz: http://jakarta.apache.org/site/downloads/downloads_tomcat.html
2. 安装jdk1.5,由于jboss4.x集成的是tomcat5.5,故需要安装jdk1.5以上的版本。
l 卸载原系统已经安装的jdk1.4: rpm -e j2sdk-1.4.2_07-fcs
l 安装jdk1.5:chmod +x jdk-1_5_0_03-linux-i586-rpm.bin
执行./jdk-1_5_0_03-linux-i586-rpm.bin
Do you agree to the above license terms? [yes or no]
接受许可就可以得到一个rpm包,系统会自动安装rmp包
l 设置jboss和apache需要的环境变量:
vi /etc/profile在path路径前添加JAVA的bin目录:
if [ `id -u` = 0 ]; then
pathmunge /usr/java/jdk1.5.0_03/bin
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
并在该文件的最后添加:export JAVA_HOME=/usr/java/jdk1.5.0_03
退出系统并重新登录,使环境变量生效
3.安装apache:安装apache无需指定配置参数,默认安装就可以,但是最好指定一下apache的主目录:
tar zxvf httpd-2.0.46.tar.gz
cd httpd-2.0.46
./configure C-prefix=/usr/local/apache
make
make install以下用APACHE_HOME=/usr/local/apache
修改APACHE_HOME/conf/httpd.conf中的ServerName为你机器的ip地址。启动apache:$APACHE_HOME/bin/apachectl start
4.安装mod_jk1.2.x(这个文件一定要用自己编译生成的,如果直接从apache的网站上down,启动apache的时候会报如下错误:segement fault:$HTTPD -k $ARGV,无法正常启动apache)
tar zxvf jakarta-tomcat-connectors-1.2.10-src.tar.gz
cd jakarta-tomcat-connectors-1.2.10-src
cd jk/native
./configure -Cwith-apxs=/usr/local/apache/bin/apxs -Cwith-java-home=${JAVA_HOME} --with-java-platform=2 Cenable-jni
make
编译后将在apache-2.0子目录下生成mod_jk.so文件。这就是我们需要的连接apache和jboss的modules文件。将该文件拷贝到apache的modules目录下:
cd apache-2.0
cp mod_jk.so /usr/local/apache/modules/
5.配置apache:
cd /usr/local/apache/conf
cp httpd.conf httpd.conf.bak(备份一下apache的配置文件)
在httpd.conf文件的末尾添加如下内容:
#Include mod_jk Configuration file
Include conf/mod-jk.conf
6.编辑mod-jk模块的配置文件:在APACHE_HOME/conf下创建文件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 /application/* 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
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
mod_jk模块负责将apache的请求发送到jboss的应用中。配置了mod-jk.conf后,通过apache的配置文件apache就可以将请求转发到jboss了。下面配置转发机器的信息:
7.配置workers的属性:
在APACHE_HOME/conf目录下添加:workers.properties,并添加如下内容:
#Define list of workers that will be used for
#mapping requests;
worker.list=loadbalancer,status
#Define nodes.如果有多个节点(如jboss集群,可以在下面继续添加nodex)
worker.node1.port=8009
worker.node1.host=192.168.1.106
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.cachesize=10
#Define loadbalancer behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=192.168.1.106
worker.loadbalancer.sticky_session=1
worker.loadbalancer.local_worker_only=1
worker.list=loadbalancer
#worker for mapping loadbalance status
worker.status.type=status
8.创建URI映射文件:
在APACHE_HOME/conf下创建uriworkermap.properties
这个文件包含apache转发给jboss的URL 映射。格式应该是:
/url=worker_name。worker_name就是上一个文件workers.properties中的
worker.list指明的
作为一个例子在uriworkermap.properties中添加如下内容:
#mount the Servlet context to the ajp13 worker
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
利用这个文件mod_jk将把转发请求到tomcat的jmx-console
9.重新启动APACHE;
10.配置JBOSS中集成的tomcat
根据worker.properties中指定的node名。配置该机器上的jboss配置文件server.xml
cd $JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar
编辑server.xml:
在<Engine…>选项中添加一个属性jvmRoute:
<Engine name="jboss.web" defaultHost="localhost" jvmRoute=”192.168.1.106”>
……………………………………
</Engine>
jvmRoute属性必须与workers.properties中指定的节点名匹配。
最后把tomcat的session cookies 也添加jmvRoute值,这样mod_jk就可以转发客户端的请求了:编辑文件
$JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/META-INF/jboss-server.xml
找到name为UseJK的<attribute>元素,把该元素的值设为true即:
把<attribute name=”UseJK”>false</attribute>改为
<attribute name=”UseJK”>true</attribute>
11.重新启动JBOSS服务器:
cd $JBOSS_HOME/bin
./shutdown.sh CS
./run.sh &
12.通过浏览器访问:http://192.168.1.106/jmx-console/就可以看到jboss的jmx-console了。这说明jboss已经可以通过apache访问了。
注意:修改各个配置文件的时候最好将配置文件做一个备份
注意jboss默认的端口是8080开始测试jboss时要放开防火墙的8080端口
可以利用测试页访问jsp文件:
<%@ page import="java.util.*,java.sql.*,java.text.*" contentType="text/html;charset=gb2312" %>
<%
out.println("test page");
%>
利用mod_jk1.2集成APACHE+JBOSS
1. 下载所需的安装包:
httpd-2.0.46.tar.gz : http://httpd.apache.org/download.cgi
jdk-1_5_0_03-linux-i586-rpm.bin:http://java.sun.com/j2se/1.5.0/download.jsp
jakarta-tomcat-connectors-1.2.10-src.tar.gz: http://jakarta.apache.org/site/downloads/downloads_tomcat.html
2. 安装jdk1.5,由于jboss4.x集成的是tomcat5.5,故需要安装jdk1.5以上的版本。
l 卸载原系统已经安装的jdk1.4: rpm -e j2sdk-1.4.2_07-fcs
l 安装jdk1.5:chmod +x jdk-1_5_0_03-linux-i586-rpm.bin
执行./jdk-1_5_0_03-linux-i586-rpm.bin
Do you agree to the above license terms? [yes or no]
接受许可就可以得到一个rpm包,系统会自动安装rmp包
l 设置jboss和apache需要的环境变量:
vi /etc/profile在path路径前添加JAVA的bin目录:
if [ `id -u` = 0 ]; then
pathmunge /usr/java/jdk1.5.0_03/bin
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
并在该文件的最后添加:export JAVA_HOME=/usr/java/jdk1.5.0_03
退出系统并重新登录,使环境变量生效
3.安装apache:安装apache无需指定配置参数,默认安装就可以,但是最好指定一下apache的主目录:
tar zxvf httpd-2.0.46.tar.gz
cd httpd-2.0.46
./configure C-prefix=/usr/local/apache
make
make install以下用APACHE_HOME=/usr/local/apache
修改APACHE_HOME/conf/httpd.conf中的ServerName为你机器的ip地址。启动apache:$APACHE_HOME/bin/apachectl start
4.安装mod_jk1.2.x(这个文件一定要用自己编译生成的,如果直接从apache的网站上down,启动apache的时候会报如下错误:segement fault:$HTTPD -k $ARGV,无法正常启动apache)
tar zxvf jakarta-tomcat-connectors-1.2.10-src.tar.gz
cd jakarta-tomcat-connectors-1.2.10-src
cd jk/native
./configure -Cwith-apxs=/usr/local/apache/bin/apxs -Cwith-java-home=${JAVA_HOME} --with-java-platform=2 Cenable-jni
make
编译后将在apache-2.0子目录下生成mod_jk.so文件。这就是我们需要的连接apache和jboss的modules文件。将该文件拷贝到apache的modules目录下:
cd apache-2.0
cp mod_jk.so /usr/local/apache/modules/
5.配置apache:
cd /usr/local/apache/conf
cp httpd.conf httpd.conf.bak(备份一下apache的配置文件)
在httpd.conf文件的末尾添加如下内容:
#Include mod_jk Configuration file
Include conf/mod-jk.conf
6.编辑mod-jk模块的配置文件:在APACHE_HOME/conf下创建文件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 /application/* 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
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
mod_jk模块负责将apache的请求发送到jboss的应用中。配置了mod-jk.conf后,通过apache的配置文件apache就可以将请求转发到jboss了。下面配置转发机器的信息:
7.配置workers的属性:
在APACHE_HOME/conf目录下添加:workers.properties,并添加如下内容:
#Define list of workers that will be used for
#mapping requests;
worker.list=loadbalancer,status
#Define nodes.如果有多个节点(如jboss集群,可以在下面继续添加nodex)
worker.node1.port=8009
worker.node1.host=192.168.1.106
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.cachesize=10
#Define loadbalancer behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=192.168.1.106
worker.loadbalancer.sticky_session=1
worker.loadbalancer.local_worker_only=1
worker.list=loadbalancer
#worker for mapping loadbalance status
worker.status.type=status
8.创建URI映射文件:
在APACHE_HOME/conf下创建uriworkermap.properties
这个文件包含apache转发给jboss的URL 映射。格式应该是:
/url=worker_name。worker_name就是上一个文件workers.properties中的
worker.list指明的
作为一个例子在uriworkermap.properties中添加如下内容:
#mount the Servlet context to the ajp13 worker
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
利用这个文件mod_jk将把转发请求到tomcat的jmx-console
9.重新启动APACHE;
10.配置JBOSS中集成的tomcat
根据worker.properties中指定的node名。配置该机器上的jboss配置文件server.xml
cd $JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar
编辑server.xml:
在<Engine…>选项中添加一个属性jvmRoute:
<Engine name="jboss.web" defaultHost="localhost" jvmRoute=”192.168.1.106”>
……………………………………
</Engine>
jvmRoute属性必须与workers.properties中指定的节点名匹配。
最后把tomcat的session cookies 也添加jmvRoute值,这样mod_jk就可以转发客户端的请求了:编辑文件
$JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/META-INF/jboss-server.xml
找到name为UseJK的<attribute>元素,把该元素的值设为true即:
把<attribute name=”UseJK”>false</attribute>改为
<attribute name=”UseJK”>true</attribute>
11.重新启动JBOSS服务器:
cd $JBOSS_HOME/bin
./shutdown.sh CS
./run.sh &
12.通过浏览器访问:http://192.168.1.106/jmx-console/就可以看到jboss的jmx-console了。这说明jboss已经可以通过apache访问了。
注意:修改各个配置文件的时候最好将配置文件做一个备份
注意jboss默认的端口是8080开始测试jboss时要放开防火墙的8080端口
可以利用测试页访问jsp文件:
<%@ page import="java.util.*,java.sql.*,java.text.*" contentType="text/html;charset=gb2312" %>
<%
out.println("test page");
%> |
|