1、在服务器上配置Java开发环境。
2、解压rocketmq安装包到 /opt/data目录下
tar xvf alibaba-rocketmq-3.1.8.tar.gz -C /opt/data/
3、配置rocketmq的环境变量,在/etc/profile最后添加
export ROCKETMQ_HOME=/opt/alibaba-rocketmq
export PATH=$JAVA_HOME/bin:$ROCKETMQ_HOME/bin:$PATH
4、使rocketmq的环境变量生效
source /etc/profile
5、给下列命令可执行权限
cd /opt/data/alibaba-rocketmq/bin/;
chmod +x mqadmin mqbroker mqfiltersrv mqshutdown mqnamesrv
6、修改rocketmq配置文件 在alibaba-rocketmq下的runserver.sh和runbroker.sh,默认使用jvm2g。
JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn128m -XX:PermSize=128m -XX:MaxPermSize=128m"
7、新建日志文件夹
cd /opt/data/alibaba-rocketmq
mkdir log
8、启动nameserver
nohup mqnamesrv 1>/opt/data/alibaba-rocketmq/log/ng.log 2>/opt/data/alibaba-rocketmq/log/ng-err.log &
##### 查看启动状态
$ps aux|grep java
##### 验证nameserver是否启动
$tail -f /opt/data/alibaba-rocketmq/log/ng.log
The Name Server boot success.
9、启动broker,在启动borker之前需要指定nameserver地址,其中119.29.192.127为所在服务器IP
export NAMESRV_ADDR=119.29.192.127:9876
nohup mqbroker >/opt/data/alibaba-rocketmq/log/mq.log 2>&1 &
10、验证mqbroker是否启动
tail -f /opt/data/alibaba-rocketmq/log/mq.log
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=320m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
The broker[e010125001186.bja, 19.29.192.127:10911] boot success. and name server is 119.29.192.127:9876
11、关闭nameserver broker执行的命令
mqshutdown namesrv
mqshutdown broker
12、以上只支持内网访问,诺需要外网访问。
vim broker.p
修改里面的IP地址如下
namesrvAddr=公网IP:9876
brokerIP1=公网IP
brokerName=localhost
brokerClusterName=DefaultCluster
13、关掉重启。
nohup mqbroker -c broker.p >/opt/data/alibaba-rocketmq/log/mq.log 2>&1 &