Linux和Windows部署RocketMQ集群

Linux和Windows部署RocketMQ集群

    • 1.Linux启动RocketMQ
    • 2.Windows启动RocketMQ
    • 3. Linux部署双master双slave异步复制集群

官网文档

1.Linux启动RocketMQ

  1. 进入rocketmq环境变量的路径
cd /usr/local/rocketmq-all-4.3.2/distribution/target/apache-rocketmq/bin
  1. 启动Name Server
nohup sh mqnamesrv
tail -f ~/logs/rocketmqlogs/namesrv.log

提示:The Name Server boot success…

  1. 启动Broker
nohup sh mqbroker
tail -f ~/logs/rocketmqlogs/broker.log

提示:The broker[%s, 172.30.30.233:10911] boot success…

注:若无法启动,改runbroker.sh和runserver.sh中的启动内存要小于虚拟机内存,两者启动内存大小一致

  1. 查看两个进程是否启动
jps

3601 Jps
3494 NamesrvStartup
3530 BrokerStartup

  1. 关掉服务器:先关broker,再关nameserver
sh mqshutdown broker

提示:The mqbroker(36695) is running…
Send shutdown request to mqbroker(36695) OK

sh mqshutdown namesrv

提示:The mqnamesrv(36664) is running…
Send shutdown request to mqnamesrv(36664) OK

2.Windows启动RocketMQ

  1. 启动nameserver:Cmd命令框执行进入至‘MQ文件夹\bin’下,成功后会弹出提示框,此框勿关闭。
start mqnamesrv.cmd
  1. 启动broker: Cmd命令框执行进入至‘MQ文件夹\bin’下,成功后会弹出提示框,此框勿关闭。
start mqbroker.cmd -n 127.0.0.1:9876 autoCreateTopicEnable=true
  1. 启动管控平台,先进入E:\rocketmq-externals-master\rocketmq-console\src\main\resources,修改application.properties中的namesrvAddr,例如:
rocketmq.config.namesrvAddr=192.168.0.220:9876;192.168.0.221:9876
  1. Cmd命令框执行进入E:\rocketmq-externals-master\rocketmq-console
mvn clean package -Dmaven.test.skip=true
  1. Cmd命令框执行进入E:\rocketmq-externals-master\rocketmq-console\target
java -jar rocketmq-console-ng-1.0.0.jar
  1. 浏览器中输入‘127.0.0.1:配置端口’,成功后即可查看。
    端口在E:\rocketmq-externals-master\rocketmq-console\src\main\resources中的‘application.properties’文件可看,如server.port=8082

3. Linux部署双master双slave异步复制集群

  1. 修改四台机子的hosts文件:vi /ect/hosts
192.168.9.157 rocketmq-nameserver1 
192.168.9.157 rocketmq-master1 
192.168.9.150 rocketmq-nameserver2 
192.168.9.150 rocketmq-master2 
192.168.9.154 rocketmq-nameserver3 
192.168.9.154 rocketmq-master1-slave 
192.168.9.155 rocketmq-nameserver4 
192.168.9.155 rocketmq-master2-slave
  1. 重启网卡
service network restart
  1. 互相ping一下,例:
ping 10.43.98.38 
ping rocketmq-nameserver2 
ping rocketmq-master2
  1. 四台机进入/usr/local/rocketmq-all-4.3.2/distribution/target/apache-rocketmq/conf/2m-2s-async目录,增加一行代码
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876;rocketmq-nameserver3:9876;rocketmq-nameserver4:9876

主机1修改broker-a.properties文件
主机2修改broker-b.properties文件
从机1修改broker-a-s.properties文件
从机2修改broker-b-s.properties文件

  1. 在bin目录分别启动四台机子的nameserver
nohup sh mqnamesrv &
  1. 在bin目录分别启动四台机子broker:

主机1:

nohup sh mqbroker -c /usr/local/rocketmq-all-4.3.2/distribution/target/apache-rocketmq/conf/2m-2s-async/broker-a.properties >/dev/null 2>&1 &

主机2:

nohup sh mqbroker -c /usr/local/rocketmq-all-4.3.2/distribution/target/apache-rocketmq/conf/2m-2s-async/broker-b.properties >/dev/null 2>&1 &

从机1:

nohup sh mqbroker -c /usr/local/rocketmq-all-4.3.2/distribution/target/apache-rocketmq/conf/2m-2s-async/broker-a-s.properties >/dev/null 2>&1 &

从机2:

nohup sh mqbroker -c /usr/local/rocketmq-all-4.3.2/distribution/target/apache-rocketmq/conf/2m-2s-async/broker-b-s.properties >/dev/null 2>&1 &
  1. 在rocketmq的bin目录下查看集群情况:
sh mqadmin clusterList -n "192.168.9.157:9876;192.168.9.150:9876;192.168.9.154:9876;192.168.9.155:987

注:可在Windows端开启管控台,步骤以上有,需改application.properties中的namesrvAddr

你可能感兴趣的:(RocketMQ,RocketMQ)