1.修改配置文件
修改bin/runserver.sh,rocketmq的默认配置消耗2G、4G内存
修改后:
JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
修改bin/runbroker.sh,broker默认配置消耗4G、8G内存、15G内存
修改第一项后:
JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn128m" #这里是4G、8G
修改第二项后:
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=256m"#这里是15G
2.启动RocketMQ
启动mqnamesrv:
nohup sh bin/mqnamesrv &
启动broker:
nohup sh bin/mqbroker -n 192.168.67.130:9876 -c conf/broker.conf &
可选:查看日志:tail -f ~/logs/rocketmqlogs/namesrv.log
3.关闭RocketMQ
关闭broker:
sh bin/mqshutdown broker
关闭mqnamesrv:
sh bin/mqshutdown namesrv
4.开机自启动
1.进入init.d目录
cd /etc/init.d
2.创建服务文件
vim nginx
3.编写脚本
#!/bin/bash
#chkconfig: 2345 63 37
#description: rocketmq service
#processname: rocketmq-4.6.0
export ROCKETMQ_HOME=/opt/rocketmq/rocketmq-all-4.6.0-bin-release
case $1 in
start)
nohup sh $ROCKETMQ_HOME/bin/mqnamesrv &
sleep 5
nohup sh $ROCKETMQ_HOME/bin/mqbroker -n 192.168.67.155:9876 -c $ROCKETMQ_HOME/conf/broker.conf &
echo "rocketmq is started"
;;
stop)
sh $ROCKETMQ_HOME/bin/mqshutdown namesrv
sleep 5
sh $ROCKETMQ_HOME/bin/mqshutdown broker
echo "rocketmq is stopped"
;;
restart)
sh $ROCKETMQ_HOME/bin/mqshutdown namesrv
sleep 5
sh $ROCKETMQ_HOME/bin/mqshutdown broker
echo "rocketmq is stopped"
sleep 5
nohup sh $ROCKETMQ_HOME/bin/mqnamesrv &
sleep 5
nohup sh $ROCKETMQ_HOME/bin/mqbroker -n 192.168.67.155:9876 -c $ROCKETMQ_HOME/conf/broker.conf &
echo "rocketmq is started"
;;
*)
echo "start|stop|restart"
;;
esac
exit 0
4.修改文件权限:
chmod 777 rocketmq
5.添加或删除服务
添加:
chkconfig --add rocketmq
删除:
chkconfig --del rocketmq
6.启动、停止或重启服务
启动:
service rocketmq start
停止:
service rocketmq stop
重启:
service rocketmq restart
7.设置开启或关闭开机启动
开启:
chkconfig rocketmq on
关闭:
chkconfig rabbitmq off
8.查看es进程,验证是否已启动
ps -ef | grep rocketmq
sh /opt/rocketmq/rocketmq-all-4.6.0-bin-release/bin/mqadmin consumerProgress -n 192.168.67.155:9876 #查看所有消费组group
sh /opt/rocketmq/rocketmq-all-4.6.0-bin-release/bin/mqadmin consumerProgress -n 192.168.67.155:9876 -g warning-group #查看指定消费组下的所有topic数据堆积情况
5.启动RocketMQ控制台
1.安装仪表盘
2.修改配置文件
cd /opt/rocketmq-console/src/main/resources/application.properties
server.port=9006
rocketmq.config.namesrvAddr=192.168.67.155:9876
3.打包jar
mvn clean package -Dmaven.test.skip=true
4.启动控制台
java -jar target/rocketmq-dashboard-1.0.0.jar
文章评论