RocketMQ搭建

1.安装RocketMQ

unzip rocketmq-all-4.9.4-bin-release.zip
mv rocketmq-all-4.9.4-bin-release /usr/local/rocketmq

2.安装jdk8

yum -y install java-1.8.0-openjdk-devel

3.修改RocketMQ配置

cd /usr/local/rocketmq
vim conf/broker.conf
# 内容如下
namesrvAddr=0.0.0.0:9876
brokerIP1=192.168.4.62 
brokerIP2=127.0.0.1

4.配置JVM虚拟机参数,根据服务器配置调整

vim bin/runserver.sh
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
vim bin/runbroker.sh 
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m"

5.启动RocketMQ

nohup /usr/local/rocketmq/bin/mqnamesrv -n 0.0.0.0:9876 &> /usr/local/rocketmq/bin/namesrv.log &
nohup /usr/local/rocketmq/bin/mqbroker -n 192.168.4.62:9876 autoCreateTopicEnable=true -c /usr/local/rocketmq/conf/broker.conf &> /usr/local/rocketmq/bin/mqbroker.log  & #autoCreateTopicEnable=true 是否启用自动创建Topic的功能,地址改成自己本机eth0的ip
# 查看结果
ss -antplu | grep java

6.安装RocketMQ控制台

包:rocketmq-console-ng-1.0.0.jar
# 启动
nohup java -jar /root/rocketmq-console-ng-1.0.0.jar --rocketmq.config.namesrvAddr=192.168.4.62:9876 &> /usr/local/rocketmq/bin/rocketmq-console.log &
# 查看结果
ss -antpul | grep 8080
ip:8080 查看

7.设置开机自启

vim /etc/rc.d/rc.local 
# 内容如下
nohup /usr/local/rocketmq/bin/mqnamesrv -n 0.0.0.0:9876 &> /usr/local/rocketmq/bin/namesrv.log &
nohup /usr/local/rocketmq/bin/mqbroker -n 192.168.4.62:9876 autoCreateTopicEnable=true -c /usr/local/rocketmq/conf/broker.conf &> /usr/local/rocketmq/bin/mqbroker.log &
nohup java -jar /root/rocketmq-console-ng-1.0.0.jar --rocketmq.config.namesrvAddr=192.168.4.62:9876 &> /usr/local/rocketmq/bin/rocketmq-console.log &
chmod +x /etc/rc.d/rc.local

 

posted @ 2024-01-27 16:14  卷叶小树  阅读(28)  评论(0编辑  收藏  举报