一、 安装rocketmq

1.1解压安装包,检查jdk环境

  1. java -version
  2. unzip rocketmq-4.4.zip

1.2 修改RocketMQ启动参数

将启动所需内存改小
vi runbroker.sh
image.png
vi runserver.sh
image.png

1.3修改broker的config文件

  1. # 默认启动时ip是localhost,如果要支持外网访问,需改为阿里云的外网ip
  2. namesrvAddr=121.41.224.57:9876
  3. messageIndexSafe=true
  4. autoCreateTopicEnable=true
  5. waitTimeMillsInSendQueue=5000
  6. sendMessageThreadPoolNums=64
  7. useReentrantLockWhenPutMessage=true
  8. defaultReadQueueNums = 16
  9. defaultWriteQueueNums = 16
  10. # 需改为阿里云的外网ip
  11. brokerIP1=121.41.224.57
  12. brokerClusterName=DefaultCluster
  13. brokerName=broker-a
  14. brokerId=0
  15. deleteWhen=04
  16. fileReservedTime=48
  17. brokerRole=ASYNC_MASTER
  18. flushDiskType=ASYNC_FLUSH
  19. # 监听端口,默认用10911
  20. listenPort=10911
  21. # 存储路径
  22. # storePathRootDir=/usr/local/rocketmq/store
  23. # storePathCommitLog= /usr/local/rocketmq/store/commitlog
  24. # storePathConsumeQueue=/usr/local/rocketmq/store/consumequeue
  25. # storePathIndex=/usr/local/rocketmq/store/index

1.4 启动RocketMQ

  1. # 1.启动NameServer
  2. nohup sh bin/mqnamesrv &
  3. # 2.查看启动日志
  4. tail -f ~/logs/rocketmqlogs/namesrv.log
  1. # 1.启动Broker
  2. nohup sh bin/mqbroker -n localhost:9876 &
  3. # 2.查看启动日志
  4. tail -f ~/logs/rocketmqlogs/broker.log

1.5 关闭RocketMQ

  1. # 1.关闭NameServer
  2. sh bin/mqshutdown namesrv
  3. # 2.关闭Broker
  4. sh bin/mqshutdown broker

二、 安装rocketmq控制台

2.1下载rocketmq-console项目

2.2修改配置文件

image.png

2.3将jar包上传到服务器上,启动命令 java -jar

image.png

阿里云需要开放端口
image.png