首页 > 其他分享 >Jboss4集群配置之二:Jboss集群配置实例与负载均衡器配置

Jboss4集群配置之二:Jboss集群配置实例与负载均衡器配置

时间:2023-05-05 22:32:22浏览次数:53  
标签:etc 配置 worker 均衡器 host 集群 jk apache mod


1.前言 
2.集群准备知识 
3.Jboss集群配置实例概述
4.Jboss集群负载均衡器mod_jk配置

3.Jboss集群配置实例概述

下文中,Ruby Sun 将以实例来叙述Jboss集群配置。

该实例包含3个Jboss节点。各节点被动接收负载均衡器转发的请求。各节点间没有横向的联系。

4. Jboss集群负载均衡器配置

步骤

先安装apache,然后配置mod_jk 模块。

安装apache

下载apache代码包 ,上传到服务器。

解开代码包

tar xfvz httpd-2.2.4.tar.gz

编译

./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

修改配置。本例中,Ruby Sun 使用的监听端口是8080,请根据实际情况修改。
vi /usr/local/apache2/conf/httpd.conf
将Listen 80改成Listen 8080
将User daemon和Group daemon改为User apache和Group apache
删除ServerName前的#,将该行改为ServerName 127.0.0.1:8888

添加用户和用户组
groupadd apache
useradd apache –g apache

apache mod_jk配置

下载mod_jk ,将其改名为mod_jk.so ,拷贝到/usr/local/apache2/modules下。

顺便说一句,找mod_jk 模块费了Ruby Sun 很大精力,最后才在http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/ 目录下找到。我用的是mod_jk 1.2.23,看到本文的时候,mod_jk应该有新版了。但mod_jk的向下兼容做得不太好,最好先用mod_jk 1.2.23调试,成功后再尝试换用新版mod_jk。

chmod +x /usr/local/apache2/modules/mod_jk.so

在/usr/local/apache2/conf/httpd.conf的末尾增加:

Include conf/mod_jk.conf
建立空文件/usr/local/apache2/conf/uriworkermap.properties
vi /usr/local/apache2/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

JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1vi /usr/local/apache2/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=192.168.130.95
worker.node1.type=ajp13
worker.node1.lbfactor=1
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host= 192.168.130.99
worker.node2.type=ajp13
worker.node2.lbfactor=0
# Define Node3
# modify the host as your host IP or DNS name.
worker.node3.port=8009
worker.node3.host= 192.168.130.112
worker.node3.type=ajp13
worker.node3.lbfactor=1
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2,node3
worker.loadbalancer.sticky_session=1
#worker.list=loadbalancer
# Status worker for managing load balancer
worker.status.type=status

说明:
worker.node1.host、worker.node2.host和worker.node3.host要改成jboss集群各机器的实际IP.
如果有更多的节点,顺序定义更多的node段,并在worker.loadbalancer.balance_workers后全部列出.
lbfactor是负载分配权重,值越大分配的负载越多.
更多配置参数详见tomcat配置说明

配置apache自动启动

ln –s /usr/local/apache2/apachectl /etc/init.d/apache
chmod 777 /etc/init.d/apache
ln –s /etc/init.d/apache /etc/rc3.d/S80apache
ln –s /etc/init.d/apache /etc/rc3.d/K20apache
ln –s /etc/init.d/apache /etc/rc4.d/S80apache
ln –s /etc/init.d/apache /etc/rc4.d/K20apache
ln –s /etc/init.d/apache /etc/rc5.d/S80apache
ln –s /etc/init.d/apache /etc/rc5.d/K20apache

标签:etc,配置,worker,均衡器,host,集群,jk,apache,mod
From: https://blog.51cto.com/iwtxokhtd/6247971

相关文章

  • SpringBoot配置mongodb打印日志
    在application.yml添加配置:logging:level:org.springframework.data.mongodb.core.MongoTemplate:DEBUG如果使用的是application.properties,则是:logging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG......
  • MyBatis 配置详解
    目录mybatis-config.xml核心配置文件1.environments元素1.1子元素environment1.2transactionManager事务管理器(共两种)2.mappers元素(定义映射SQL语句文件)3.properties4.typeAliases(定义别名)其他配置【设置】mybatis-config.xml核心配置文件mybatis-config.xml包含的......
  • 配置wordpress:添加分享到QQ空间功能(wordpress 6.2)
    一,添加代码:1,代码:<atarget="_blank"href='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title=<?phpthe_title();?>&desc=&summary=&site=&pics=&url=<?phpechourlencode(get_permalink());?>�......
  • yaml配置注入
    配置文件SpringBoot使用一个全局的配置文件,配置文件名称是固定的application.properties语法结构:key=valueapplication.yml语法结构:key:空格value配置文件的作用:修改SpringBoot自动配置的默认值,因为SpringBoot在底层都给我们自动配置好了yaml注入配置文件yaml可......
  • 使用kubeadm快速部署k8s集群
    目录使用kubeadm快速部署k8s集群一、环境准备二、kubeadm工具介绍三、实操1、所有节点(基础环境)2、master节点3、node节点(加入)4、查看集群使用kubeadm快速部署k8s集群一、环境准备操作系统CentOS7.x-86_x64硬盘:40G+角色IPmaster192.168.130.10node192.168.130.......
  • Kafka基础阶段与集群搭建详细教程
    Kafka第一天课堂笔记一.Kafka简介1.1消息队列消息队列——用于存放消息的组件程序员可以将消息放入到队列中,也可以从消息队列中获取消息很多时候消息队列不是一个永久性的存储,是作为临时存储存在的(设定一个期限:设置消息在MQ中保存10天)消息队列中间件:消息队列的组件,例如:Kafk......
  • 配置wordpress:添加分享到豆瓣功能(wordpress 6.2)
    一,代码:1,代码:<atarget="_blank"href='https://www.douban.com/share/service?href=<?phpthe_permalink();?>&name=<?phpthe_title();?>&text=&image=&starid=0&aid=0&style=11'><imgid=&qu......
  • C++ - VS2019配置pthread线程库
    说明在VS里用MS编译器不能直接调用pthread库,需要先自行下载该库:http://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip解压后用的到的只有Pre-built.2文件夹下的文件。 配置如下图分别配置三大项:包含目录-->...pthreads-w32-2-9-1-release\Pre-built.......
  • elasticsearch集群及kibana安装
    系统配置创建一个用户elastic,不能使用root用户启动配置该用户环境变量,用户home目录.bash_profile文件#配置ES_JAVA_HOME使用es自带jdkexportES_JAVA_HOME=/data/es/elasticsearch/jdk#修改最大文件句柄数ulimit-n65535#修改最大线程数ulimit-u4096执行..bash_p......
  • k8s集群部署搭建
    一.搭建环境win11 16G+1t   VMware虚机 4G+2G+2G二.拓扑图 master+2node三.ip划分四.前置条件配置完成,按照文档进行搭建即可,最终实现效果如下图 ......