安裝zip和maven
yum install -y unzip ziphtml
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-mavenjava
cd /opt/rocketmq
mvn -Prelease-all -DskipTests clean install -Ugit
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/rocketmqgithub
jdk9以上版本,官方腳本報錯比較多,參照https://www.cnblogs.com/wintersoft/p/10881601.htmlapache
強烈建議jdk版本不要超過8,不然後面容易出現各類奇葩問題。vim
備份防止意外
cp -r /opt/rocketmq/conf/ /opt/rocketmq/conf.default/服務器
mkdir /opt/rocketmqs/
cp -a /opt/rocketmq/* /opt/rocketmqsjvm
參照
vim /opt/rocketmq/conf/2m-2s-sync/broker-a.properties
修改
vim /opt/rocketmq/conf/broker.propertiesmaven
配置文件後面加入
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換成bide
參照
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