activitymq+keepalived+nfs 非zk的高可用叢集構建
阿新 • • 發佈:2018-12-06
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的檔案
備節點的配置
[[email protected] conf]# cd /etc/keepalived/ [[email protected] keepalived]# cat keepalived.conf global_defs { notification_email { [email protected] } notification_email_from [email protected] 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 { [email protected] } notification_email_from [email protected] 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 } }