rocketmq简介:RocketMQ 是阿里巴巴开源的分布式消息中间件。2017年捐献给apache开源基金会,次年成为apache顶级项目 是一个队列模型的消息中间件,具有高性能、高可靠、高实时、分布式等特点
liunx 下 rocketmq 双主双从集群搭建
IP地址 角色
192.168.180.133 master1
192.168.180.133 master2-slave
192.168.180.245 master2
192.168.180.245 master1-slave
安装部署: 1.下载:https://github.com/apache/rocketmq 2.上传133 和 245 服务器 解压 unzip rocketmq-all-4.9.2-bin-release.zip 3.创建持久化存储目录 a.主节点 目录
mkdir store
cd store/
mkdir commitlog
mkdir consumequeue
mkdir index
b.从节点 目录
4.修改配置文件 133 配置文件修改 ,这里2m-2s-async表示双主双从异步 先修改133主节点 vim ./conf/2m-2s-async/broker-a.properties
brokerClusterName=rocketmq-cluster
brokerName=broker-a
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
namesrvAddr=192.168.180.133:9876;192.168.180.245:9876
listenPort=10911
#存储路径
storePathRootDir=/opt/software/rocketmq/rocketmq-4.9.2/store
#commitLog 存储路径
storePathCommitLog=/opt/software/rocketmq/rocketmq-4.9.2/store/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/opt/software/rocketmq/rocketmq-4.9.2/store/consumequeue
#消息索引存储路径
storePathIndex=/opt/software/rocketmq/rocketmq-4.9.2/store/index
#checkpoint 文件存储路径
storeCheckpoint=/opt/software/rocketmq/rocketmq-4.9.2/store/checkpoint
#abort 文件存储路径
abortFile=/opt/software/rocketmq/rocketmq-4.9.2/store/abort
brokerRole=SYNC_MASTER
修改133从节点
vim ./conf/2m-2s-async/broker-b-s.properties
brokerClusterName=rocketmq-cluster
brokerName=broker-b-s
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
namesrvAddr=192.168.180.133:9876;192.168.180.245:9876
listenPort=10921
#存储路径
storePathRootDir=/opt/software/rocketmq/rocketmq-4.9.2/store-s
#commitLog 存储路径
storePathCommitLog=/opt/software/rocketmq/rocketmq-4.9.2/store-s/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/opt/software/rocketmq/rocketmq-4.9.2/store-s/consumequeue
#消息索引存储路径
storePathIndex=/opt/software/rocketmq/rocketmq-4.9.2/store-s/index
#checkpoint 文件存储路径
storeCheckpoint=/opt/software/rocketmq/rocketmq-4.9.2/store-s/checkpoint
#abort 文件存储路径
abortFile=/opt/software/rocketmq/rocketmq-4.9.2/store-s/abort
同理 245 也需要配置
先修改245主节点 vim ./conf/2m-2s-async/broker-b.properties
brokerClusterName=rocketmq-cluster
brokerName=broker-b
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
namesrvAddr=192.168.180.133:9876;192.168.180.245:9876
listenPort=10911
#存储路径
storePathRootDir=/opt/software/rocketmq/rocketmq-4.9.2/store
#commitLog 存储路径
storePathCommitLog=/opt/software/rocketmq/rocketmq-4.9.2/store/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/opt/software/rocketmq/rocketmq-4.9.2/store/consumequeue
#消息索引存储路径
storePathIndex=/opt/software/rocketmq/rocketmq-4.9.2/store/index
#checkpoint 文件存储路径
storeCheckpoint=/opt/software/rocketmq/rocketmq-4.9.2/store/checkpoint
#abort 文件存储路径
abortFile=/opt/software/rocketmq/rocketmq-4.9.2/store/abort
brokerRole=SYNC_MASTER
修改245从节点
vim ./conf/2m-2s-async/broker-a-s.properties
brokerClusterName=rocketmq-cluster
brokerName=broker-a-s
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
listenPort=10921
namesrvAddr=192.168.180.133:9876;192.168.180.245:9876
#存储路径
storePathRootDir=/opt/software/rocketmq/rocketmq-4.9.2/store-s
#commitLog 存储路径
storePathCommitLog=/opt/software/rocketmq/rocketmq-4.9.2/store-s/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/opt/software/rocketmq/rocketmq-4.9.2/store-s/consumequeue
#消息索引存储路径
storePathIndex=/opt/software/rocketmq/rocketmq-4.9.2/store-s/index
#checkpoint 文件存储路径
storeCheckpoint=/opt/software/rocketmq/rocketmq-4.9.2/store-s/checkpoint
#abort 文件存储路径
abortFile=/opt/software/rocketmq/rocketmq-4.9.2/store-s/abort
5.启动133 和 245 nameserver
nohup sh ./bin/mqnamesrv & 6.启动133 和 245的broker 133环境 broker-a
nohup sh mqbroker -c /opt/software/rocketmq/rocketmq-4.9.2/conf/2m-2s-async/broker-a.properties &
133环境 broker-b-s
nohup sh mqbroker -c /opt/software/rocketmq/rocketmq-4.9.2/conf/2m-2s-async/broker-b-s.properties &
245环境 broker-b
nohup sh mqbroker -c /opt/software/rocketmq/rocketmq-4.9.2/conf/2m-2s-async/broker-b.properties &
245环境 broker-a-s
nohup sh mqbroker -c /opt/software/rocketmq/rocketmq-4.9.2/conf/2m-2s-async/broker-a-s.properties &
7启动后可以在 rocketmq-dashboard上查看
github地址:https://github.com/apache/rocketmq-dashboard
下载后修改配置文件: nameserver地址换成自己的nameserve
rocketmq:
config: # if this value is empty,use env value rocketmq.config.namesrvAddr NAMESRV_ADDR | now, default localhost:9876 # configure multiple namesrv addresses to manage multiple different clusters namesrvAddrs: - 192.168.180.133:9876 - 192.168.180.245:9876
集群部署坑点: 1.java.net.BindException: 地址已在使用 从节点监听端口不能和主节点一样listenPort=10921 ,最好和主节点端口相隔大于2 2.节点启动后,在dashboard 刷新不可见,因为从节点配置文件没有注册到nameserver:namesrvAddr=192.168.180.133:9876;192.168.180.245:9876 3.rocketmq dashboard 始终只有一个broker-a,配置文件中brokerName 每个节点都不能相同
|