RocketMQ 部署
1、安装依赖(Java)
[root@Microservices ~]# mkdir -p /data/businessServer/
[root@Microservices ~]# cd /data/businessServer/
# 获取安装包(下载较慢)
[root@Microservices businessServer]# wget https://github.com/frekele/oracle-java/releases/download/8u181-b13/jdk-8u181-linux-x64.tar.gz
# 解压安装包
[root@Microservices businessServer]#
[root@Microservices businessServer]# ll
total 181296
-rw-r--r-- 1 root root 185646832 Apr 27 09:01 jdk-8u181-linux-x64.tar.gz
[root@Microservices businessServer]# tar xf jdk-8u181-linux-x64.tar.gz
[root@Microservices businessServer]# ll
total 181296
drwxr-xr-x 7 10 143 245 Jul 7 2018 jdk1.8.0_181
-rw-r--r-- 1 root root 185646832 Apr 27 09:01 jdk-8u181-linux-x64.tar.gz
# 设置环境变量
cat >>/etc/profile <<EOF
JAVA_HOME=/data/businessServer/jdk1.8.0_181
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
EOF
# 环境变量生效
source /etc/profile
# 检查安装结果
java -version
jps
2、下载二进制包
https://archive.apache.org/dist/rocketmq/5.2.0/
cd /data/businessServer/
# 获取二进制安装包
wget https://archive.apache.org/dist/rocketmq/5.2.0/rocketmq-all-5.2.0-bin-release.zip
# 解压安装包
unzip rocketmq-all-5.2.0-bin-release.zip
mv rocketmq-all-5.2.0-bin-release rocketmq
3、修改配置文件
# 添加配置内容
cat >> /data/businessServer/rocketmq/conf/broker.conf <<EOF
# broker 地址 (本机地址)
brokerIP1 = 192.168.100.171
# nameServer 地址
namesrvAddr = 192.168.100.171:9876
EOF
4、启动 namesrv、broker 服务
cd /data/businessServer/ && mkdir /data/businessServer/rocketmq/logs
# 创建启动脚本
cat >> start-namesrv.sh <<EOF
nohup bash /data/businessServer/rocketmq/bin/mqnamesrv >/data/businessServer/rocketmq/logs/mqnamesrv.log 2>&1 &
EOF
cat >> start-broker.sh <<EOF
nohup bash /data/businessServer/rocketmq/bin/mqbroker >/data/businessServer/rocketmq/logs/mqbroker.log 2>&1 &
EOF
chmod +x start-namesrv.sh start-broker.sh
# 运行启动脚本
sh start-namesrv.sh
sh start-broker.sh
# 查看日志
tail /data/businessServer/rocketmq/logs/mqnamesrv.log
tail /data/businessServer/rocketmq/logs/mqbroker.log
# 检查服务
jps
# 若需要停止服务,执行
bash /data/businessServer/rocketmq/bin/mqshutdown namesrv
bash /data/businessServer/rocketmq/bin/mqshutdown broker