activitymq+keepalived+nfs 非zk的高可用集群构建

nfs 192.168.10.32
maast 192.168.10.31
savel 192.168.10.4

应对变态需求既要高可用又要消息延迟,只能使用变态方式实现

nfs部署

#yum install nfs-utils rpcbind
#vim /etc/exports
/data/activemq  192.168.10.31(rw,sync,no_root_squash,no_all_squash)
/data/activemq  192.168.10.4(rw,sync,no_root_squash,no_all_squash)
#systemctl stop firewalld.service
#setenforce 0
#mkdir /data/activemq -p
#systemctl start nfs

客户端挂载

#yum -y install nfs-utils.x86_64
# systemctl start rpcbind
# showmount -e 192.168.10.32
Export list for 192.168.10.32:
/data/activemq 192.168.10.4,192.168.10.31
# mkdir /data
# mount -t nfs 192.168.10.32:/data/activemq /data
# df -h
文件系统                      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root        17G  4.8G   13G   28% /
devtmpfs                      476M     0  476M    0% /dev
tmpfs                         488M     0  488M    0% /dev/shm
tmpfs                         488M  1.6M  486M    1% /run
tmpfs                         488M     0  488M    0% /sys/fs/cgroup
/dev/sda1                    1014M  130M  885M   13% /boot
tmpfs                          98M     0   98M    0% /run/user/0
192.168.10.32:/data/activemq   17G  2.0G   16G   12% /data

使用yum安装keepalived

# yum -y install epel-release-7-11.noarch
# yum -y install keepalived

安装activemq部署

# tar xf apache-activemq-5.15.8-bin.tar.gz -C /usr/local/
# cd /usr/local/apache-activemq-5.15.8/conf
# vim activemq.xml     改成这样的两个节点都一样
 40     <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="/data" schedulerSupport="true">
 81         <persistenceAdapter>
 82             <kahaDB directory="/data/kahadb"/>
 83         </persistenceAdapter>
# ./activemq start  启动
# ss -lntp | grep 61616
LISTEN     0      128         :::61616                   :::*                   users:(("java",pid=21705,fd=137))
查另一个节点的端口
# ss -lntp | grep 61616
 

注意

1、共享文件的主从配置,是通过文件共享锁来实现的。先拿到文件锁的服务就是master,其它为slave服务,slave服务默认每10秒试图拿一次文件锁,可以查看activeMq的控制台。

2、只有master的控制台(如http://192.168.102.91:8161/admin)能够访问,slave的控制台不能访问,原因就是slave没有拿到文件锁,不能访问文件。

配置keepalived的文件

 备节点的配置

[root@localhost conf]# cd /etc/keepalived/
[root@localhost keepalived]# cat keepalived.conf 
global_defs {
   notification_email {
     root@localhost
   }
   notification_email_from ka2@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   vrrp_mcast_group4 224.111.111.111
}

vrrp_script chk_mq {
    script "ss -lntp | grep 61616"  #检查端口是否存在,这里不能查进程
    interval 2
    weight -10
    fall 2
    rise 2
}

vrrp_instance External_1 {
    state BACKUP
    interface ens33
    virtual_router_id 171
    priority 95
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1402b1b5
    }
    virtual_ipaddress {
        192.168.10.5/24
    }
    track_script {
        chk_mq
    }
}

  

 主节点的配置

# cat /etc/keepalived/keepalived.conf
global_defs {
   notification_email {
     root@localhost
   }
   notification_email_from ka1@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   vrrp_mcast_group4 224.111.111.111
}

vrrp_script chk_mq {
    script "ss -lntp | grep 61616"
    interval 2
    weight -10
    fall 2
    rise 2
}

vrrp_instance External_1 {
    state MASTER
    interface ens33
    virtual_router_id 171
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1402b1b5
    }
    virtual_ipaddress {
        192.168.10.5/24
    }
    track_script {
        chk_mq
    }
}

  

猜你喜欢

转载自www.cnblogs.com/rdchenxi/p/10078153.html