转载自:https://blog.csdn.net/weixin_40533111/article/details/84451219
1.下载安装包并上传(压缩包已经在上级目录中)(两台服务器即两个节点的意思)
将压缩包上传至服务器的指定目录中
2.解压
执行:unzip rocketmq-all-4.3.2-bin-release.zip
解压并更改文件的目录为rocketmq
3.修改配置文件
采用主从异步的模式
3.1修改broker-a.properties主要内容(配置文件在上级目录中)
3.2修改broker-b-s.properties主要内容(配置文件在上级目录中)
4.配置第二台机器
4.1修改broker-b.properties主要内容(配置文件在上级目录中)
4.2修改broker-a-s.properties主要内容(配置文件在上级目录中)
5.启动nameServer(命令中的目录根据自己的需求去修改)
5.1创建文件夹
节点1执行:
mkdir -p /opt/rocketmq/store/broker-a /opt/rocketmq/store/broker-a/nsumequeue /opt/rocketmq/store/broker-a/commitlog /opt/rocketmq/store/broker-a/index /opt/rocketmq/logs/opt/rocketmq/store/broker-b-s/opt/rocketmq/store/broker-b-s/nsumequeue /opt/rocketmq/store/broker-b-s/commitlog /opt/rocketmq/store/broker- b-s/index
节点2执行:
mkdir -p /opt/rocketmq/store/broker-a-s/opt/rocketmq/store/broker-a-s/nsumequeue /opt/rocketmq/store/broker-a-s/commitlog /opt/rocketmq/store/broker-a-s/index /opt/rocketmq/logs /opt/rocketmq/store/broker-b/opt/rocketmq/store/broker-b/nsumequeue /opt/rocketmq/store/broker-b/commitlog /opt/rocketmq/store/broker- b/index
5.2启动两台服务器的nameServer(自己的安装目录以及ip端口)
启动节点1的nameServer
nohup sh /opt/rocketmq/bin/mqnamesrv -n 192.168.0.63:9876>/opt/rocketmq/logs/mqnamesrv.log 2>&1 &
启动节点2的nameServer
nohup sh /opt/rocketmq/bin/mqnamesrv -n 192.168.0.64:9876>/opt/rocketmq/logs/mqnamesrv.log 2>&1 &
6.启动broker
将两台机器rocketmq/bin/runbroker.sh中配置的JAVA_OPT 改成JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn512m"
6.1 启动节点1的broker-a的master,对应的配置文件broker-a.properties
nohup sh /opt/rocketmq/bin/mqbroker -c /opt/rocketmq/conf/2m-2s-async/broker-a.properties > /opt/rocketmq/logs/broker-a.log 2>&1 &
6.2 启动节点2的broker-a-s
nohup sh /opt/rocketmq/bin/mqbroker -c /opt/rocketmq/conf/2m-2s-async/broker-a-s.properties > /opt/rocketmq/logs/logs/broker-a-s.log 2>&1 &
6.3 启动节点2的broker-b
nohup sh /opt/rocketmq/bin/mqbroker -c /opt/rocketmq/conf/2m-2s-async/broker-b.properties > /opt/rocketmq/logs/broker-b.log 2>&1 &
6.4 启动节点1的broker-b-s
nohup sh /opt/rocketmq/bin/mqbroker -c /opt/rocketmq/conf/2m-2s-async/broker-b-s.properties > /opt/rocketmq/logs/broker-b-s.log 2>&1 &
7.启动web管理界面
rocketmq提供多种管理方式,命令行和界面等,
apache提供一个开源的扩展项目: https://github.com/apache/rocketmq-externals 里面包含一个子项目rocketmq-console,配置下,打个包就可以用了
7.1 将配置文件rocketmq.config.namesrvAddr=需改为自己的两台机器的ip+端口 (多个节点 中间用分号隔开)也可以自定义启动的端口
7.2 使用maven打包
mvn clean package -Dmaven.test.skip=true
7.3 上传到服务器启动即可java -jar启动(日志的输出目录自己定义)
java -jar rocketmq-console-ng-1.0.0.jar >/usr/local/rocketmq/logs/mq-console.log 2>&1 &
访问启动的jar包的 ip+端口 就可以看到页面的集群情况
执行命令过程中 如果出现无权限
执行:chmod +x /usr/lib/jvm/java-8-openjdk-arm64/bin/jps
sh bin/mqshutdown broker //停止 broker
sh bin/mqshutdown namesrv //停止 nameserver
暂停jar包运行
netstat -lnp|grep 端口
ps 1777
kill -9 1777
查看防火墙的状态
systemctl status firewalld
关闭防火墙
systemctl stop firewalld.service