1、下载RocketMQ
编译后的压缩包
wget https://dlcdn.apache.org/rocketmq/4.9.2/rocketmq-all-4.9.2-bin-release.zip
2、解压
unzip rocketmq-all-4.9.2-bin-release.zip
3、进入解压文件夹
cd rocketmq-all-4.9.2/
4、编辑配置文件/usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/conf/broker.conf
如果不指定目录,则默认保存在 启动用户(如root) 则在/root/store 目录下面, 整个文件可删除,不影响
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
##自动创建Topic
autoCreateTopicEnable=true
## # nameServ地址(你的服务器地址)
namesrvAddr=127.0.0.1:9876
brokerIP1=127.0.0.1
## 存储路径
storePathRootDir=/usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/data/
## commitLog路径
storePathCommitLog=/usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/commitlog
## 消息队列存储路径
storePathConsumeQueue=/usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/data/consumequeue
## 消息索引存储路径
storePathIndex=/usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/data/index
## checkpoint文件路径
storeCheckpoint=/usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/data/checkpoint
## abort文件存储路径
abortFile=/usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/data/abort
5、配置占用内存大小
修改booker、server、tools里边配置的占用内存大小
6、配置开机自启
目录:/usr/lib/systemd/system
rocketmqname.service
[Unit]
Description=rocketmq-nameserver
Documentation=http://mirror.bit.edu.cn/apache/rocketmq/
After=network.target
[Service]
Type=sample
User=root
ExecStart=/usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/bin/mqnamesrv
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=0
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
rocketmqbroker.service
[Unit]
Description=rocketmq-broker
Documentation=http://mirror.bit.edu.cn/apache/rocketmq/
After=network.target
[Service]
Type=sample
User=root
#ExecStart=/usr/local/rocketmq/bin/mqbroker -c /usr/local/rocketmq/conf/2m-noslave/broker-b.properties
#/usr/local/rocketmq/conf/2m-2s-async/broker-a.properties
ExecStart=/usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/bin/mqbroker -c /usr/local/rocketmq/rocketmq-all-4.9.4-bin-release/conf/broker.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=0
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
开启开机自启
systemctl daemon-reload
systemctl start rocketmqname.service
systemctl start rocketmqbroker.service
systemctl enable rocketmqname.service
systemctl enable rocketmqbroker.service
注意:需要开放 10911、10909、9876、8888 端口
注意2:Jdk版本限制,目前版本rocketmq限制在jdk15以下