将需要用到的资源上传到云服务器,主要包括RocketMQ软件包和JDK运行环境
链接: https://pan.baidu.com/s/1kb3hUfTU89Xc3noiMwNkDA?pwd=uvuh
1.基础配置
将文件上传到/opt目录下
# 解压rocketmq
mkdir rocketmq
mv rocketmq.zip ./rocketmq
cd rocketmq
unzip rocketmq.zip
# 解压jdk
tar -zxvf jdk-8u202-linux-x64.tar.gz
mv jdk-8u202-linux-x64 jdk8
进入rocketmq文件夹,修改conf目录下的broker.conf文件:
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
aclEnable=true
brokerIP1=IP地址
namesrvAddr=IP地址:9876
主要增加了以下几项:
- aclEnable=true :开启权限控制
- brokerIP1=IP地址:brokerIP
- namesrvAddr=IP地址:9876:nameserver的IP
如果只是内网访问也可以不开启权限控制
如果开启了acl,文件配置:修改plain_acl.yml
globalWhiteRemoteAddresses:
- 192.168.2.131
- 192.168.2.132
accounts:
- accessKey: RocketMQ
secretKey: 12345678
whiteRemoteAddress:
admin: false
defaultTopicPerm: DENY
defaultGroupPerm: SUB
topicPerms:
- topicA=DENY
- topicB=PUB|SUB
- topicC=SUB
groupPerms:
# the group should convert to retry topic
- groupA=DENY
- groupB=PUB|SUB
- groupC=SUB
- accessKey: 12345678
secretKey: 12345678
admin: true
注意accessKey和secretKey要大于6位
2.启动
需要启动nameserver和broker,进入rocketmq文件夹:
cd /opt/rocketmq
分别执行以下命令:
nohup sh bin/mqnamesrv &
nohup sh bin/mqbroker -c conf/broker.conf &
3.其他配置
上面rocketmq.zip是已经修改好内存配置信息的,也可以自定义broker 和nameserver的内存信息: 进入bin目录:
vim runserver.sh
修改jdk信息: 修改nameserver内存信息:
同样执行下面命令修改broker内存信息:
vim runbroker.sh
4.开机启动
cd /lib/systemd/system/
vim nameserver.service
[Unit]
Description=nameserver
After=network.target
[Service]
Environment="JAVA_HOME=/opt/jdk8"
Type=simple
#alone
ExecStart=sh /opt/rocketmq/bin/mqnamesrv &
ExecReload=sh /opt/rocketmq/bin/mqshutdown namesrv
ExecStop=sh /opt/rocketmq/bin/mqshutdown namesrv
[Install]
WantedBy=multi-user.target
vim broker.service
[Unit]
Description=broker
After=network.target
[Service]
Environment="JAVA_HOME=/opt/jdk8"
Type=simple
#alone
ExecStart=sh /opt/rocketmq//bin/mqbroker -c /opt/rocketmq/conf/broker.conf &
ExecReload=sh /opt/rocketmq/bin/mqshutdown broker
ExecStop=sh /opt/rocketmq/bin/mqshutdown broker
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl enable nameserver
systemctl enable broker
回复