安装RocketMQ相关软件
Centos安装RocketMQ相关软件(推荐):
https://www.jianshu.com/p/8444cbf16bc5
Docket安装RocketMQ相关软件:
https://www.jianshu.com/p/1af9208d56ca
rocketmq-console mqnamesrv mqbroker 的关系
名称 | 端口 | 作用 |
---|---|---|
rocketmq-console | 8180 | rokcet_mq 可视化界面 需要监听mqnamesrv |
mqnamesrv | 8180 | rokcet_mq 服务器 |
mqbroker | 10911 | rokcet_mq 集群 需要启动到mqnamesrv下面 |
安装方式1(根据apache官方文档进行安装)
http://rocketmq.apache.org/docs/quick-start/
安装方式2(按照我下面的步骤进行安装)
1:下载安装编译 (mqnamesrv mqbroker )
1:下载安装包
到GitHub网站上:https://github.com/apache/rocketmq/releases
或者右键获取连接地址 ,然后在Linux系统下执行
wget https://github.com/apache/rocketmq/archive/rocketmq-all-4.7.1.tar.gz
2:复制安装包到Linux系统下
3:解压安装包
tar -zxvf rocketmq-all-4.7.1.tar.gz
4:安装maven(因为RocketMq安装包是源代码 需要编译)
自己查询安装maven的步骤
5:进行编译
在Rocketmq的安装目录下执行
mvn -Prelease-all -DskipTests clean install -U
2:全局环境配置 启动环境配置 broker文件配置
1:进行环境变量配置
进入配置全局变量
/etc/profile
环境变量配置rocketmq全局变量
export rocketmq=/opt/rocketmq-rocketmq-all-4.7.1/distribution/target/apache-rocketmq
export PATH=$PATH:$rocketmq/bin
刷新配置
source /etc/profile
2:修改启动文件 设置启动参数 (否则可能会启动报错)
cd /opt/rocketmq-rocketmq-all-4.7.1/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/bin
vim runbroker.sh
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn256m"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=256m"
vim runserver.sh
JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m"
3:修改 broker的配置文件
cd /opt/rocketmq-rocketmq-all-4.7.1/distribution/conf
vim broker.conf
#nameServer地址,分号分割
namesrvAddr=47.113.101.241:9876
#broker的地址
brokerIP1=47.113.101.241
#broker 对外服务的监听端口(失效)
listenPort=10911
4:启动或关闭 mqnamesrv 与 启动mqbroker
1:进入相应路径
cd /opt/rocketmq-rocketmq-all-4.7.1/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/bin
2:启动mqnamesrv mqnamesrv默认端口号为9876
nohup sh mqnamesrv >/mnt/logs/rocketmqlogs/mqnamesrv.log 2>&1 &
3:启动mqbroker
正确方法:
//如果在上面步骤中 namesrvAddr以及配置 则直接这样执行即可
nohup sh mqbroker -c /opt/rocketmq-rocketmq-all-4.7.1/distribution/conf/broker.conf >/mnt/logs/rocketmqlogs/broker.log 2>&1 &
另外一种启动方法会有问题
//启动broker 到nameserver下 47.113.101.241:9876 但mqbroker本身的IP地址会变成内网的
nohup sh mqbroker -n 47.113.101.241:9876 >/mnt/logs/rocketmqlogs/broker.log 2>&1 &
4:关闭
cd /opt/rocketmq-rocketmq-all-4.7.1/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/bin
关闭namesrv服务:sh mqshutdown namesrv
关闭broker服务 :sh mqshutdown broker
5:RocketMQ可视化客户端安装 与 启动
1:下载文件(/opt目录下)
https://github.com/apache/rocketmq-externals 地址下载并从本地上传到服务器
2:解压(/opt目录下)
前提是:unzip解压文件无法使用
yum install -y unzip zip
解压文件
unzip rocketmq-externals-master.zip
3:查找rocketmq-externals 的 application.properties
cd /opt/rocketmq-externals-master/rocketmq-console/src/main/resources
4:修改application.properties
该主机的地址
rocketmq.config.namesrvAddr=XXX.XXX.XXX.XXX:9876
rocketmq.config.namesrvAddr=47.113.101.241:9876
修改端口号为8180
5:对rocketmq-console进行编译打包
cd /opt/rocketmq-externals-master/rocketmq-console
mvn clean package -Dmaven.test.skip=true
注意:如果发现打包的版号有问题,可以进入相应的pom.xml进行修改
6:启动可视化客户端
cd /opt/rocketmq-externals-master/rocketmq-console/target
//需要一直开着
java -jar rocketmq-console-ng-2.0.0.jar
//后台启动
nohup java -jar rocketmq-console-ng-2.0.0.jar >/mnt/logs/rocketmqlogs/consolelog.out 2>&1 &
6:使用软连接或者硬链接 配置常用启动文件目录
1:创建一个文件夹
mkdir /opt/rocketmq-start
2:在文件下指向该命名
cd /opt/rocketmq-start
硬链接:
ln /opt/rocketmq-rocketmq-all-4.7.1/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/bin/mqshutdown mqshutdown
软链接:mqnamesrv broker 都需要软连接
ln -s /opt/rocketmq-rocketmq-all-4.7.1/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/bin/mqnamesrv mqnamesrv
ln -s /opt/rocketmq-externals-master/rocketmq-console/target/rocketmq-console-ng-2.0.0.jar rocketmq-console.jar
3:启动命令:
nohup sh mqnamesrv >/mnt/logs/rocketmqlogs/mqnamesrv.log 2>&1 &
nohup sh mqbroker -c broker.conf >/mnt/logs/rocketmqlogs/broker.log 2>&1 &
nohup java -jar rocketmq-console.jar >/mnt/logs/rocketmqlogs/consolelog.out 2>&1 &
4:关闭命令:
关闭namesrv服务:sh mqshutdown namesrv
关闭broker服务 :sh mqshutdown broker