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/conf/broker.conf
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. brokerClusterName = DefaultCluster brokerName = broker-a brokerIP1=192.168.0.130 brokerIP2=192.168.0.130 namesrvAddr = 192.168.0.130:9876 brokerId = 0 deleteWhen = 04 fileReservedTime = 48 brokerRole = ASYNC_MASTER flushDiskType = ASYNC_FLUSH #autoCreateTopicEnable=true
5、配置占用内存大小
修改booker、server、tools里边配置的占用内存大小
6、配置开机自启
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/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/bin/mqbroker -c /usr/local/rocketmq/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
7、验证
ps -ef|grep java jps