一.环境说明
需要具备以下环境
- 实际使用的 Java JDK 是 1.8.0_172 版本
[root@iZuf67tbbdheqz50qucytoZ maven]# java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
- 实际操作安装的是 Maven 3.6.3
[root@iZuf67tbbdheqz50qucytoZ maven]# mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/maven/apache-maven-3.6.3
Java version: 1.8.0_231, vendor: Oracle Corporation, runtime: /usr/local/java/jdk1.8.0_231/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.14.4.el7.x86_64", arch: "amd64", family: "unix"
二.RocketMQ下载
1.从Apcehe下载
-
Apcehe官方下载地址:https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.6.0/rocketmq-all-4.6.0-source-release.zip
- 《快速搭建文档》https://rocketmq.apache.org/docs/quick-start/
2.从GitHup上下载
-
gitHub下载地址https://github.com/apache/rocketmq
-
rocketMQ管理页面下载地址:https://github.com/apache/rocketmq-externals
三.安装步骤
1.将下载好的文件上传到linux服务器并解压
[root@iZuf67tbbdheqz50qucytoZ rocketMQ]# ll
total 8
drwxr-xr-x 19 root root 4096 Dec 13 2017 rocketmq-all-4.2.0 //rocketMQ
drwxr-xr-x 28 root root 4096 Dec 19 09:27 rocketmq-externals-master //rocketMQ管理系统
2.编译RocketMQ
运行命令:
# 进入rocketmq-all-4.2.0目录
$ cd rocketmq-all-4.2.0/
# 编译rocketmq
$ mvn -Prelease-all -DskipTests clean install -U
编译结果如下,表示编译成功:
......
[INFO] Apache RocketMQ 4.2.0 .............................. SUCCESS [04:00 min]
[INFO] rocketmq-remoting 4.2.0 ............................ SUCCESS [ 24.415 s]
[INFO] rocketmq-common 4.2.0 .............................. SUCCESS [ 6.218 s]
[INFO] rocketmq-client 4.2.0 .............................. SUCCESS [ 8.689 s]
[INFO] rocketmq-store 4.2.0 ............................... SUCCESS [ 6.680 s]
[INFO] rocketmq-srvutil 4.2.0 ............................. SUCCESS [ 2.870 s]
[INFO] rocketmq-filter 4.2.0 .............................. SUCCESS [ 1.987 s]
[INFO] rocketmq-broker 4.2.0 .............................. SUCCESS [ 5.158 s]
[INFO] rocketmq-tools 4.2.0 ............................... SUCCESS [ 3.273 s]
[INFO] rocketmq-namesrv 4.2.0 ............................. SUCCESS [ 1.424 s]
[INFO] rocketmq-logappender 4.2.0 ......................... SUCCESS [ 3.791 s]
[INFO] rocketmq-openmessaging 4.2.0 ....................... SUCCESS [ 2.550 s]
[INFO] rocketmq-example 4.2.0 ............................. SUCCESS [ 1.501 s]
[INFO] rocketmq-filtersrv 4.2.0 ........................... SUCCESS [ 1.322 s]
[INFO] rocketmq-test 4.2.0 ................................ SUCCESS [ 6.281 s]
[INFO] rocketmq-distribution 4.2.0 ........................ SUCCESS [ 50.934 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:28 min
[INFO] Finished at: 2020-01-11T14:46:17+08:00
[INFO] ------------------------------------------------------------------------
3.修改相关配置文件:
- 从当前目录进入到apache-rocketmq
$ cd distribution/target/apache-rocketmq
- 修改conf目录下的broker.conf
$ vim conf/broker.conf
-
添加以下内容:
#InetAddress用于网络接口,如果是虚拟机则配置的是虚拟机的外网ip
brokerIP1=47.101.200.192
namesrvAddr=47.101.200.192:9876
##监听端口 ,也是外网映射端口(这里需要注意的是,外网端口和内网的10911端口需要一直,否则会出现 timeout问题)
listenPort=10911
注意:如果是服务器一定要对外开放这写端口9876、10911
- 修改bin/目录下的runserver.sh、mqnamesrv这两个文件
-
文件runserver.sh
-
文件runbroker.sh
- 添加环境变量
$ vim /etc/profile
export NAMESRV_ADDR=服务器IP:9876
重新加载环境变量
source /etc/profile
三.启动RockerMQ
在apache-rocketmq目录下创建log文件夹用来存放日志,然后运行mqnamesrv ,再运行mqbroker
$ mkdir log
$ nohup bin/mqnamesrv > log/mqname.log 2>&1 &
$ nohup bin/mqbroker -n 服务器地址:9876 -c conf/broker.conf autoCreateTopicEnable=true > log/borker.log 2>&1 &
查看是否启动成功:有如下两个进程表示成功
四.安装RockeMQ监控系统
- 进入解压好的rocketmq-externals-master目录下
$ cd rocketmq-externals-master/
2.修改/rocketmq-console/src/main/resources下的application.properties配置文件
$ vim rocketmq-console/src/main/resources/application.properties
修改为你想要的端口,和你自己服务器地址
- 进入rocketmq-console/目录下编译
$ cd rocketmq-console/
$ mvn clean package -Dmaven.test.skip=true
-
启动管理页面
运行target/目录下的rocketmq-console-ng-1.0.1.jar
访问[自己服务地址]:[之前设置好的端口]
例如:127.0.0.1:8081即可