安装zip和maven
yum install -y unzip zip
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum -y install apache-maven
cd /opt/rocketmq
mvn -Prelease-all -DskipTests clean install -U
wget -P /opt/downloads http://mirrors.tuna.tsinghua.edu.cn/apache/rocketmq/4.5.0/rocketmq-all-4.5.0-bin-release.zip
unzip /opt/downloads/rocketmq-all-4.5.0-bin-release.zip -d /opt
mv /opt/rocketmq-all-4.5.0-bin-release /opt/rocketmq
jdk9以上版本,官方脚本报错比较多,参照https://www.cnblogs.com/wintersoft/p/10881601.html
强烈建议jdk版本不要超过8,否则后面容易出现各种奇葩问题。
备份防止意外
cp -r /opt/rocketmq/conf/ /opt/rocketmq/conf.default/
mkdir /opt/rocketmqs/
cp -a /opt/rocketmq/* /opt/rocketmqs
参照
vim /opt/rocketmq/conf/2m-2s-sync/broker-a.properties
修改
vim /opt/rocketmq/conf/broker.properties
配置文件后面加入
listenPort=10911
namesrvAddr=192.168.1.101:9876;192.168.1.102:9876
brokerIP1=192.168.1.102
storePathRootDir=/opt/rocketmq/store
storePathCommitLog=/opt/rocketmq/store/commitlog
storePathConsumeQueue=/opt/rocketmq/store/consumequeue
storePathIndex=/opt/rocketmq/store/index
storeCheckpoint=/opt/rocketmq/store/checkpoint
多网卡需指定brokerIP1否则会报connect to XXXX:10911 failed
另一台服务器a换成b
参照
vim /opt/rocketmqs/conf/2m-2s-sync/broker-a-s.properties
修改
vim /opt/rocketmq/conf/broker.properties
配置文件后面加入
listenPort=10912
namesrvAddr=192.168.1.101:9876;192.168.1.102:9876
brokerIP1=192.168.1.102
storePathRootDir=/opt/rocketmqs/store
storePathCommitLog=/opt/rocketmqs/store/commitlog
storePathConsumeQueue=/opt/rocketmqs/store/consumequeue
storePathIndex=/opt/rocketmqs/store/index
storeCheckpoint=/opt/rocketmqs/store/checkpoint
另一台服务器a换成b
注意坑:默认并不会读取conf目录的broker.conf
安装nameserver守护进程
vim /lib/systemd/system/rocketmq-nameserver.service
[Unit] Description=rocketmq-nameserver After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=simple ExecStart=/bin/sh /opt/rocketmq/bin/mqnamesrv ExecStop=/bin/sh /opt/rocketmq/bin/mqshutdown namesrv Restart=always PrivateTmp=true [Install] WantedBy=multi-user.target
权限
chmod 777 /lib/systemd/system/rocketmq-nameserver.service
systemctl enable rocketmq-nameserver.service
systemctl daemon-reload
运行
systemctl start rocketmq-nameserver.service
默认端口9876
安装broker-master守护进程
vim /lib/systemd/system/rocketmq-broker.service
[Unit] Description=rocketmq-broker-master After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=simple ExecStart=/bin/sh /opt/rocketmq/bin/mqbroker -c /opt/rocketmq/conf/broker.properties ExecStop=/bin/sh /opt/rocketmq/bin/mqshutdown broker Restart=always PrivateTmp=true [Install] WantedBy=multi-user.target
权限
chmod 777 /lib/systemd/system/rocketmq-broker.service
systemctl enable rocketmq-broker.service
systemctl daemon-reload
运行
systemctl start rocketmq-broker.service
安装broker-slave守护进程
vim /lib/systemd/system/rocketmq-broker-s.service
[Unit] Description=rocketmq-broker-slave After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=simple ExecStart=/bin/sh /opt/rocketmqs/bin/mqbroker -c /opt/rocketmqs/conf/broker.properties ExecStop=/bin/sh /opt/rocketmqs/bin/mqshutdown broker Restart=always PrivateTmp=true [Install] WantedBy=multi-user.target
权限
chmod 777 /lib/systemd/system/rocketmq-broker-s.service
systemctl enable rocketmq-broker-s.service
systemctl daemon-reload
运行
systemctl start rocketmq-broker-s.service
安装rocketmq-console
下载源码https://github.com/apache/rocketmq-externals
修改配置rocketmq.config.isVIPChannel=false 否则会报connect to XXXX:10909 failed,Rocket默认开启10909端口为vip通道。
console启用登录参照https://github.com/apache/rocketmq-externals/blob/master/rocketmq-console/doc/1_0_0/UserGuide_CN.md
打包mvn clean package -Dmaven.test.skip=true
得到rocketmq-console-ng-1.0.1.jar,参照https://github.com/apache/rocketmq-externals/tree/master/rocketmq-console
复制到/opt/rocketmq-console
查找java文件软连接路径(略)
ls /usr/bin/java -al 得到/etc/alternatives/java
ls /etc/alternatives/java -al
真实路径为/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java
vim /lib/systemd/system/rocketmq-console.service
[Unit]
Description=rocketmq-console
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
ExecStart=/usr/bin/java -jar /opt/rocketmq-console/rocketmq-console-ng-1.0.1.jar --server.port=9875 --rocketmq.config.namesrvAddr=192.168.1.101:9876;192.168.1.101:9876 --rocketmq.config.isVIPChannel=false
Restart=always
PrivateTmp=true
[Install]
WantedBy=multi-user.target
权限
chmod 777 /lib/systemd/system/rocketmq-console.service
systemctl enable rocketmq-console.service
systemctl daemon-reload
运行
systemctl start rocketmq-console.service