专栏首页散尽浮华Centos6.9下RocketMQ3.4.6高可用集群部署记录(双主双从+Nameserver+Console)

Centos6.9下RocketMQ3.4.6高可用集群部署记录(双主双从+Nameserver+Console)

之前的文章已对RocketMQ做了详细介绍,这里就不再赘述了,下面是本人在测试和生产环境下RocketMQ3.4.6高可用集群的部署手册,在此分享下:

1) 基础环境

ip地址                 主机名                    角色
192.168.10.200         mq-master01               broker-a
192.168.10.201         mq-master02               broker-b
192.168.10.202         mq-slave01                broker-a-s
192.168.10.203         mq-slave02                broker-b-s
192.168.10.205         mq-console-nameserver     nameserver、console

生产环境准备5台虚拟机,如上,其中4台服务器为broker节点,2主2从;1台服务器作为nameserver和console节点.
测试环境的话,可以只用两台,分别为broker的一主一从节点,nameserver和console服务一同部署到master节点上.

关闭5台机器的iptables和selinux(所有节点机器上都要操作)
[root@mq-master01 ~]# /etc/init.d/iptables stop
[root@mq-master01 ~]# vim /etc/sysconfig/selinux
......
SELINUX=disabled
[root@mq-master01 ~]# setenforce 0
[root@mq-master01 ~]# getenforce
Permissive
 
5台机器都要安装统一的java环境(这里安装jdk1.8,参考:http://www.cnblogs.com/kevingrace/p/7607442.html)
将jdk-8u131-linux-x64.rpm下载到/opt目录下
下载地址:https://pan.baidu.com/s/1pLaAjPp
提取密码:x27s
 
[root@mq-master01 ~]# java -version
-bash: java: command not found
 
如果自带了java环境,就卸载掉
yum list installed |grep java
yum -y remove java-1.7.0-openjdk*
yum -y remove tzdata-java.noarch
 
[root@mq-master01 ~]# cd /usr/local/src/
[root@mq-master01 src]# ll jdk-8u131-linux-x64_.rpm
-rw-r--r-- 1 root root 169983496 Nov 19  2017 jdk-8u131-linux-x64_.rpm
[root@mq-master01 src]# rpm -ivh jdk-8u131-linux-x64_.rpm --force
 
[root@mq-master01 src]# vim /etc/profile
......
JAVA_HOME=/usr/java/jdk1.8.0_131
JAVA_BIN=/usr/java/jdk1.8.0_131/bin
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/bin:/sbin/
CLASSPATH=.:/lib/dt.jar:/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
 
[root@mq-master01 src]# source /etc/profile
[root@mq-master01 src]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)


5台机器最好前做hosts绑定,否则后续启动broker的时候,会报错诸如:
java.net.UnknownHostException: mq-master01: mq-master01: Name or service not known
 
[root@mq-master01 ~]# cat /etc/hosts
......
192.168.10.200         mq-master01
192.168.10.201         mq-master02
192.168.10.202         mq-slave01
192.168.10.203         mq-slave02
192.168.10.205         mq-console-nameserver


本案例rocketmq3.4.6的相关软件包下载地址: https://pan.baidu.com/s/1VOYA60vIobtSxo9-9rTI6w
提取密码: bxhr

软件包分别是:rocketmq_admin.zip, rocketmq_namesrv.zip, rocketmq.zip
下载后放到/usr/local/src目录下
服务安装目录都在/data下

2) RocektMQ Broker双主双从环境部署(mq-master01,mq-master02,mq-slave01,mq-slave02四节点上操作)

1)安装rocketmq(四台broker节点机器操作一样)
[root@mq-master01 ~]# cd /usr/local/src/
[root@mq-master01 src]# ll rocketmq.zip 
-rw-rw-r--. 1 1000 1000 16048060 May 22 10:33 rocketmq.zip
[root@mq-master01 src]# unzip rocketmq.zip
[root@mq-master01 src]# mv rocketmq /data/

2) 配置rocektmq broker (四个节点机器都要操作)
其实下载的软件包里的对应配置已经配置好了,内容如下(brokerClusterName可以根据自己的业务名称进行修改):

[root@mq-master01 src]# cd /data/rocketmq/conf/2m-2s-sync/
[root@mq-master01 2m-2s-sync]# vim broker-a.properties
brokerClusterName=QCZLCluster
brokerName=broker-a
brokerId=0
autoCreateTopicEnable=false
clusterTopicEnable=false
brokerTopicEnable=false
autoCreateSubscriptionGroup=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
fetchNamesrvAddrByAddressServer=true
filterServerNums=1
serverWorkerThreads=32
deleteWhen=04
fileReservedTime=168
brokerRole=SYNC_MASTER
flushDiskType=SYNC_FLUSH
#netty监听端口
listenPort=20911

====================================================================
mq-master02节点配置
[root@mq-master02 src]# cat /data/rocketmq/conf/2m-2s-sync/broker-a-s.properties
brokerClusterName=QCZLCluster
brokerName=broker-a
brokerId=1
autoCreateTopicEnable=false
clusterTopicEnable=false
brokerTopicEnable=false
autoCreateSubscriptionGroup=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
fetchNamesrvAddrByAddressServer=true
filterServerNums=1
serverWorkerThreads=32
deleteWhen=04
fileReservedTime=168
brokerRole=SLAVE
flushDiskType=SYNC_FLUSH
listenPort=20911

====================================================================
mq-slave01节点配置
[root@mq-slave01 ~]# cat /data/rocketmq/conf/2m-2s-sync/broker-b.properties 
brokerClusterName=QCZLCluster
brokerName=broker-b
brokerId=0
autoCreateTopicEnable=false
clusterTopicEnable=false
brokerTopicEnable=false
autoCreateSubscriptionGroup=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
fetchNamesrvAddrByAddressServer=true
filterServerNums=1
serverWorkerThreads=32
deleteWhen=04
fileReservedTime=168
brokerRole=SYNC_MASTER
flushDiskType=SYNC_FLUSH
#netty监听端口
listenPort=20911

====================================================================
mq-slave02节点配置
[root@mq-slave02 ~]# cat /data/rocketmq/conf/2m-2s-sync/broker-b-s.properties
brokerClusterName=QCZLCluster
brokerName=broker-b
brokerId=1
autoCreateTopicEnable=false
clusterTopicEnable=false
brokerTopicEnable=false
autoCreateSubscriptionGroup=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
fetchNamesrvAddrByAddressServer=true
filterServerNums=1
serverWorkerThreads=32
deleteWhen=04
fileReservedTime=168
brokerRole=SLAVE
flushDiskType=SYNC_FLUSH
listenPort=20911

3) 启动NameServer (四台broker节点机器操作一样)
只需要将/data/rocketmq/startBrokerAM.sh中的JAVA_HOME改成自己服务的java路径就行了.
本案例的java家目录路径是/usr/java/jdk1.8.0_131

[root@mq-master01 ~]# cat /data/rocketmq/startBrokerAM.sh |grep JAVA_HOME
export JAVA_HOME=/data/software/jdk1.7.0_80
[root@mq-master01 ~]# sed -i 's#/data/software/jdk1.7.0_80#/usr/java/jdk1.8.0_131#g' /data/rocketmq/startBrokerAM.sh   
[root@mq-master01 ~]# cat /data/rocketmq/startBrokerAM.sh |grep JAVA_HOME                                           
export JAVA_HOME=/usr/java/jdk1.8.0_131

四台节点的启动脚本分别为:
[root@mq-master01 ~]# cat /data/rocketmq/startBrokerAM.sh
export JAVA_HOME=/usr/java/jdk1.8.0_131
nohup sh ./alibaba-rocketmq/bin/mqbroker -c ./conf/2m-2s-sync/broker-a.properties > ./nohup.out 2>&1 &

[root@mq-master02 ~]# cat /data/rocketmq/startBrokerAM.sh
export JAVA_HOME=/usr/java/jdk1.8.0_131
nohup sh ./alibaba-rocketmq/bin/mqbroker -c ./conf/2m-2s-sync/broker-a-s.properties > ./nohup.out 2>&1 &

[root@mq-slave01 ~]# cat /data/rocketmq/startBrokerAM.sh
export JAVA_HOME=/usr/java/jdk1.8.0_131
nohup sh ./alibaba-rocketmq/bin/mqbroker -c ./conf/2m-2s-sync/broker-b.properties > ./nohup.out 2>&1 &

[root@mq-slave02 ~]# cat /data/rocketmq/startBrokerAM.sh
export JAVA_HOME=/usr/java/jdk1.8.0_131
nohup sh ./alibaba-rocketmq/bin/mqbroker -c ./conf/2m-2s-sync/broker-b-s.properties > ./nohup.out 2>&1 &

启动NameServer(四台broker节点机器操作一样)
[root@mq-master01 ~]# cd /data/rocketmq/         #一定要先切换到该路径下
[root@mq-master01 rocketmq]# /bin/bash /data/rocketmq/startBrokerAM.sh
[root@mq-master01 rocketmq]# ps -ef|grep rocketmq                     
root     16783     1  0 09:13 pts/1    00:00:00 sh ./alibaba-rocketmq/bin/mqbroker -c ./conf/2m-2s-sync/broker-a.properties
root     16787 16783  0 09:13 pts/1    00:00:00 sh /data/rocketmq/alibaba-rocketmq/bin/runbroker.sh com.alibaba.rocketmq.broker.BrokerStartup -c ./conf/2m-2s-sync/broker-a.properties
root     16790 16787 48 09:13 pts/1    00:00:01 /usr/java/jdk1.8.0_131/bin/java -Drocketmq.home.dir=/data/rocketmq/alibaba-rocketmq -Duser.home=/data/rocketmq -Xms2048M -Xmx2048M -XX:PermSize=512M -XX:MaxPermSize=512M -XX:NewSize=768M -XX:MaxNewSize=768M -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:+DisableExplicitGC -verbose:gc -Xloggc:/data/rocketmq/logs/gclog/rmq_bk_gc.16787.log -XX:+PrintGCDetails -XX:-OmitStackTraceInFastThrow -Djava.ext.dirs=/data/rocketmq/alibaba-rocketmq/bin/../lib -cp .:/data/rocketmq/alibaba-rocketmq/bin/../conf: -Drocketmq.namesrv.domain=172.16.50.144 -Drocketmq.namesrv.domain.port=48080 -Drocketmq.namesrv.domain.subgroup=namesrv/getNSAddr.do com.alibaba.rocketmq.broker.BrokerStartup -c ./conf/2m-2s-sync/broker-a.properties
root     16835 16088  0 09:13 pts/1    00:00:00 grep rocketmq
[root@mq-master01 ~]# lsof -i:20911
COMMAND   PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    16790 root   79u  IPv6 19963764      0t0  TCP *:20911 (LISTEN)
java    16790 root   89u  IPv6 19965178      0t0  TCP mq-master01:20911->172.16.50.141:41400 (ESTABLISHED)

3) NameServer和Console部署(mq-console-nameserver节点上操作)

安装配置NameServer

[root@mq-console-nameserver src]# cd 
[root@mq-console-nameserver ~]# cd /usr/local/src/
[root@mq-console-nameserver src]# ll rocketmq_namesrv.zip 
-rw-rw-r-- 1 1000 1000 11802959 May 22 11:03 rocketmq_namesrv.zip
[root@mq-console-nameserver src]# unzip rocketmq_namesrv.zip
[root@mq-console-nameserver src]# mv rocketmq_namesrv /data/
[root@mq-console-nameserver src]# vim /data/rocketmq_namesrv/conf/namesrv.properties 
listenPort=20901

修改JAVA_HOME
[root@mq-console-nameserver src]# sed -i 's#/data/software/jdk1.7.0_80#/usr/java/jdk1.8.0_131#g' /data/rocketmq_namesrv/startNameServer.sh 
[root@mq-console-nameserver src]# cat /data/rocketmq_namesrv/startNameServer.sh
export JAVA_HOME=/usr/java/jdk1.8.0_131
nohup sh ./alibaba-rocketmq/bin/mqnamesrv -c ./conf/namesrv.properties > ./nohup.out 2>&1 &

启动NameServer
[root@mq-console-nameserver src]# cd /data/rocketmq_namesrv/
[root@mq-console-nameserver rocketmq_namesrv]# sh startNameServer.sh 

[root@mq-console-nameserver rocketmq_namesrv]# ps -ef|grep mqnamesrv
root     17455     1  0 09:23 pts/1    00:00:00 sh ./alibaba-rocketmq/bin/mqnamesrv -c ./conf/namesrv.properties
root     17555 24306  0 09:23 pts/1    00:00:00 grep mqnamesrv
[root@mq-console-nameserver rocketmq_namesrv]# lsof -i:20901
COMMAND   PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    17461 root   47u  IPv6 40870224      0t0  TCP *:20901 (LISTEN)

查看版本
[root@mq-console-nameserver rocketmq_namesrv]# ll /data/rocketmq_namesrv/alibaba-rocketmq/lib/
total 11836
-rw-rw-r-- 1 root root   16088 Nov 28  2016 annotation-indexer-1.4.jar
-rw-rw-r-- 1 root root    3159 Nov 28  2016 bridge-method-annotation-1.12.jar
-rw-rw-r-- 1 root root   41123 Nov 28  2016 commons-cli-1.2.jar
-rw-rw-r-- 1 root root  259600 Nov 28  2016 commons-codec-1.7.jar
-rw-rw-r-- 1 root root  185140 Nov 28  2016 commons-io-2.4.jar
-rw-rw-r-- 1 root root  284220 Nov 28  2016 commons-lang-2.6.jar
-rw-rw-r-- 1 root root 2838580 Nov 28  2016 derby-10.10.2.0.jar
-rw-rw-r-- 1 root root  409203 Nov 28  2016 fastjson-1.2.3.jar
-rw-rw-r-- 1 root root  154710 Nov 28  2016 github-api-1.59.jar
-rw-rw-r-- 1 root root   33483 Nov 28  2016 jackson-annotations-2.2.3.jar
-rw-rw-r-- 1 root root  192699 Nov 28  2016 jackson-core-2.2.3.jar
-rw-rw-r-- 1 root root  865838 Nov 28  2016 jackson-databind-2.2.3.jar
-rw-rw-r-- 1 root root  544021 Nov 28  2016 javassist-3.7.ga.jar
-rw-rw-r-- 1 root root  264600 Nov 28  2016 logback-classic-1.0.13.jar
-rw-rw-r-- 1 root root  418870 Nov 28  2016 logback-core-1.0.13.jar
-rw-rw-r-- 1 root root 1581066 Nov 28  2016 mockito-all-1.9.5.jar
-rw-rw-r-- 1 root root  964879 Nov 28  2016 mysql-connector-java-5.1.31.jar
-rw-rw-r-- 1 root root 1887979 Nov 28  2016 netty-all-4.0.25.Final.jar
-rw-rw-r-- 1 root root  160098 Nov 28  2016 rocketmq-broker-3.4.6-lo-20161026.115524-467.jar
-rw-rw-r-- 1 root root  241439 Nov 28  2016 rocketmq-client-3.4.6-lo-20160927.070341-319.jar
-rw-rw-r-- 1 root root  213219 Nov 28  2016 rocketmq-common-3.4.6-lo-20160927.070334-319.jar
-rw-rw-r-- 1 root root   38123 Nov 28  2016 rocketmq-filtersrv-3.4.6-lo-20160927.070417-318.jar
-rw-rw-r-- 1 root root   33525 Nov 28  2016 rocketmq-namesrv-3.4.6-lo-20160927.070407-319.jar
-rw-rw-r-- 1 root root   93612 Nov 28  2016 rocketmq-remoting-3.4.6-lo-20160927.070325-319.jar
-rw-rw-r-- 1 root root    4088 Nov 28  2016 rocketmq-srvutil-3.4.6-lo-20160927.070351-319.jar
-rw-rw-r-- 1 root root  157893 Nov 28  2016 rocketmq-store-3.4.6-lo-20160927.070348-319.jar
-rw-rw-r-- 1 root root  147117 Nov 28  2016 rocketmq-tools-3.4.6-lo-20160927.070403-319.jar
-rw-rw-r-- 1 root root   26084 Nov 28  2016 slf4j-api-1.7.5.jar

安装部署Console监控平台

[root@mq-console-nameserver ~]# cd /usr/local/src/
[root@mq-console-nameserver src]# ll rocketmq_admin.zip 
-rw-rw-r-- 1 1000 1000 41574127 May 22 11:03 rocketmq_admin.zip
[root@mq-console-nameserver src]# unzip rocketmq_admin.zip

服务端口(如下改成48080)
[root@mq-console-nameserver src]# vim /data/rocketmq_admin/apache-tomcat-8.0.32-rocketmq-console/conf/server.xml
......
    <Connector port="48080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="28443" />

[root@mq-console-nameserver src]# mv rocketmq_admin /data/
[root@mq-console-nameserver src]# cd /data/rocketmq_admin/
[root@mq-console-nameserver rocketmq_admin]# cd apache-tomcat-8.0.32-rocketmq-console/webapps/rocketmq/WEB-INF/classes/
[root@mq-console-nameserver classes]# vim config.properties 
rocketmq.namesrv.addr=192.168.10.205:20901
throwDone=true

启动console服务
[root@mq-console-nameserver classes]# /data/rocketmq_admin/apache-tomcat-8.0.32-rocketmq-console/bin/startup.sh 
[root@mq-console-nameserver classes]# lsof -i:48080
COMMAND   PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    19338 root   46u  IPv6 40883769      0t0  TCP *:48080 (LISTEN)

最后再重启四个Broker节点服务

http://192.168.10.205:48080/rocketmq/topic/list.do

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • Linux下间隔多少秒 (即以秒为单位) 去执行某条命令或某个shell脚本的操作方法

    在日常运维工作中, 经常会碰到以秒为单位去定时执行某些命令或监控脚本的需求。 说到定时任务就要用到crontab,通常来说,crontab的最小单位是分钟级别,...

    洗尽了浮华
  • Linux操作系统启动流程梳理

    接触linux系统运维已经好几年了,常常被问到linux系统启动流程问题,刚好今天有空来梳理下这个过程: 一般来说,所有的操作系统的启动流程基本就是: ? 总的...

    洗尽了浮华
  • Centos7下部署两套python版本并存环境的操作记录

    需求说明: centos7.2系统的开发机器上已经自带了python2.7版本,但是开发的项目中用的是python3.5版本,为了保证Centos系统的正常运行...

    洗尽了浮华
  • 【leetcode刷题】T129-翻转二叉树

    https://leetcode-cn.com/problems/invert-binary-tree/

    木又AI帮
  • JS数据结构第六篇 --- 二叉树力扣练习题

    比如输入:[3, 9, 20, 15, 7, 88, 16,  2, 19, 13, 26, 11]

    tandaxia
  • linux基础学习整理

    未来sky
  • leecode刷题(24)-- 翻转二叉树

    二叉树问题,我们首先要想到的使用递归的方式来解决,有了这个思路,处理这道问题就很简单了:先互换根节点的左右节点,然后递归地处理左子树,再递归地处理右子树,直到所...

    希希里之海
  • 【LeetCode】一文详解二叉树的三大遍历:前序、中序和后序(python和C++实现)

    深度学习技术前沿公众号博主
  • cron 的配置和说明

    作者:北南南北 来自:LinuxSir.Org 摘要:Linux操作系统中,计划任务通常由cron来承担,了解或掌握cron,能为我们管理服务器带来更多的便利,...

    一见
  • LeetCode 1339. 分裂二叉树的最大乘积(DP)

    给你一棵二叉树,它的根为 root 。请你删除 1 条边,使二叉树分裂成两棵子树,且它们子树和的乘积尽可能大。

    Michael阿明

扫码关注云+社区

领取腾讯云代金券