虚拟机单机配置
参见官网 http://rocketmq.apache.org/docs/quick-start/
注意,本机配置broker集群有文件冲突问题,建议使用docker配置集群
docker集群
镜像拉取
分别是nameserver、broker和管理后台镜像
docker pull foxiswho/rocketmq:server-4.3.2
docker pull foxiswho/rocketmq:broker-4.3.2
docker pull styletang/rocketmq-console-ng:1.0.0
启动nameserver
nameserver1
docker create -p 9876:9876 --name rmqserver01 -e “JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m” -e “JAVA_OPTS=-Duser.home=/opt” foxiswho/rocketmq:server-4.3.2
nameserver2
docker create -p 9877:9876 --name rmqserver02 -e “JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m” -e “JAVA_OPTS=-Duser.home=/opt” foxiswho/rocketmq:server-4.3.2
启动后台
docker run -e “JAVA_OPTS=-Drocketmq.namesrv.addr=10.0.0.134:9876;10.0.0.134:9877 -Dcom.rocketmq.sendMessageWithVIPChannel=false” -p 8098:8080 -t styletang/rocketmq-console-ng:1.0.0
启动broker
说明:10.0.0.134 为本机IP;配置文件中brokerRole属性可以不指定,默认为master
master broker01
docker create --name rmqbroker01 -e “JAVA_OPTS=-Duser.home=/opt” -e “JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m” -p 10111:10111 foxiswho/rocketmq:broker-4.3.2
配置
docker exec -it rmqbroker01 /bin/bash
vi /etc/rocketmq/broker.conf
namesrvAddr=10.0.0.134:9876;10.0.0.134:9877
brokerClusterName=testCluster
brokerName=broker01
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=10.0.0.134
brokerIp2=10.0.0.134
listenPort=10111
exit
docker restart rmqbroker01
master broker01-slave
docker create --name rmqbroker01s -e “JAVA_OPTS=-Duser.home=/opt” -e “JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m” -p 10121:10121 foxiswho/rocketmq:broker-4.3.2
配置
docker exec -it rmqbroker01s /bin/bash
vi /etc/rocketmq/broker.conf
namesrvAddr=10.0.0.134:9876;10.0.0.134:9877
brokerClusterName=testCluster
brokerName=broker01
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
brokerIP1=10.0.0.134
brokerIp2=10.0.0.134
listenPort=10121
exit
docker restart rmqbroker01s
master broker02
docker create --name rmqbroker02 -e “JAVA_OPTS=-Duser.home=/opt” -e “JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m” -p 10211:10211 foxiswho/rocketmq:broker-4.3.2
配置
docker exec -it rmqbroker02 /bin/bash
vi /etc/rocketmq/broker.conf
namesrvAddr=10.0.0.134:9876;10.0.0.134:9877
brokerClusterName=testCluster
brokerName=broker02
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=10.0.0.134
brokerIp2=10.0.0.134
listenPort=10211
exit
docker restart rmqbroker02
master broker02-slave
docker create --name rmqbroker02s -e “JAVA_OPTS=-Duser.home=/opt” -e “JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m” -p 10221:10221 foxiswho/rocketmq:broker-4.3.2
配置
docker exec -it rmqbroker02s /bin/bash
vi /etc/rocketmq/broker.conf
namesrvAddr=10.0.0.134:9876;10.0.0.134:9877
brokerClusterName=testCluster
brokerName=broker02
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
brokerIP1=10.0.0.134
brokerIp2=10.0.0.134
listenPort=10221
exit
docker restart rmqbroker02s
master broker03
docker create --name rmqbroker03 -e “JAVA_OPTS=-Duser.home=/opt” -e “JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m” -p 10311:10311 foxiswho/rocketmq:broker-4.3.2
配置
docker start rmqbroker03
docker exec -it rmqbroker03 /bin/bash
vi /etc/rocketmq/broker.conf
namesrvAddr=10.0.0.134:9876;10.0.0.134:9877
brokerClusterName=testCluster
brokerName=broker03
brokerId=0
deleteWhen=04
fileReservedTime=48
flushDiskType=ASYNC_FLUSH
brokerIP1=10.0.0.134
brokerIp2=10.0.0.134
listenPort=10311
exit
docker restart rmqbroker03
master broker03-slave
docker create --name rmqbroker03s -e “JAVA_OPTS=-Duser.home=/opt” -e “JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m” -p 10321:10321 foxiswho/rocketmq:broker-4.3.2
配置
docker start rmqbroker03s
docker exec -it rmqbroker03s /bin/bash
vi /etc/rocketmq/broker.conf
namesrvAddr=10.0.0.134:9876;10.0.0.134:9877
brokerClusterName=testCluster
brokerName=broker03
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
brokerIP1=10.0.0.134
brokerIp2=10.0.0.134
listenPort=10321
exit
docker restart rmqbroker03s