1、整体规划
IP | HOSTNAME | 用户 | 角色 | 模式 |
---|---|---|---|---|
137.32.117.11 | rocketmq-master1 | root | nameServer1,brokerServer1 | Master1 |
137.32.117.12 | rocketmq-master2 | root | nameServer1,brokerServer2 | Master2 |
/etc/hosts主机映射 | |
---|---|
137.32.117.11 | rocketmq-nameserver1 |
137.32.117.11 | rocketmq-master1 |
137.32.117.12 | rocketmq-nameserver2 |
137.32.117.12 | rocketmq-master2 |
2、环境准备
-
修改hosts文件添加主机映射
root@localhost ~]# vi /etc/hosts 137.32.117.11 rocketmq-nameserver1 137.32.117.11 rocketmq-master1 137.32.117.12 rocketmq-nameserver2 137.32.117.12 rocketmq-master2
-
ping映射名称验证是否更改成功
[root@localhost ~]# ping rocketmq-master2 PING rocketmq-master2 (137.32.117.12) 56(84) bytes of data. 64 bytes from rocketmq-nameserver2 (137.32.117.12): icmp_seq=1 ttl=64 time=0.011 ms 64 bytes from rocketmq-nameserver2 (137.32.117.12): icmp_seq=2 ttl=64 time=0.020 ms
-
安装jdk
-
上传安装包,解压
[root@localhost usr]# mkdir java [root@localhost java]# tar -zxvf jdk-8u181-linux-x64.tar.gz -C /usr/java [root@localhost java]# pwd /usr/java [root@localhost java]# ls jdk1.8.0_181 jdk-8u181-linux-x64.tar.gz
-
修改/etc/profile文件
[root@localhost java]# vim /etc/profile # 添加下面三行 export JAVA_HOME=/usr/java/jdk1.8.0_181 export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar export PATH=$PATH:${JAVA_HOME}/bin
-
重新加载配置文件,并验证
[root@localhost java]# source /etc/profile [root@localhost java]# java -version java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
-
3、修改配置文件
-
解压重命名
[root@localhost local]# tar -zxvf alibaba-rocketmq-3.2.6.tar.gz [root@localhost local]# ls alibaba-rocketmq alibaba-rocketmq-3.2.6.tar.gz bin etc games include lib lib64 libexec sbin share src [root@localhost local]# mv alibaba-rocketmq rocketmq [root@localhost local]# ls alibaba-rocketmq-3.2.6.tar.gz bin etc games include lib lib64 libexec rocketmq sbin share src
-
创建存储路径
[root@localhost local]# mkdir /usr/local/rocketmq/store [root@localhost local]# mkdir /usr/local/rocketmq/store/commitlog [root@localhost local]# mkdir /usr/local/rocketmq/store/consumequeue [root@localhost local]# mkdir /usr/local/rocketmq/store/index
-
修改日志配置文件
[root@localhost conf]# mkdir -p /usr/local/rocketmq/logs [root@localhost conf]# cd /usr/local/rocketmq/conf && sed -i 's#${user.home}#/usr/local/rocketmq#g' *.xml
-
修改启动脚本参数
[root@localhost bin]# vi /usr/local/rocketmq/bin/runbroker.sh JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:PermSize=128m -XX:MaxPermSize=320m" [root@localhost bin]# vi /usr/local/rocketmq/bin/runserver.sh JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:PermSize=128m -XX:MaxPermSize=320m"
4、启动
-
启动nameserver
[root@localhost java]# cd /usr/local/rocketmq/bin [root@localhost bin]# nohup sh mqnamesrv & [1] 1837 [root@localhost bin]# nohup: ignoring input and appending output to ‘nohup.out’ [root@localhost bin]#
-
启动brokerServer A,在11主机
[root@localhost bin]# cd /usr/local/rocketmq/bin [root@localhost bin]# nohup sh mqbroker -c /usr/local/rocketmq/conf/2m-noslave/broker-a.properties >/dev/null 2>&1 & [2] 1867 [root@localhost bin]# jps 1874 BrokerStartup 1843 NamesrvStartup 1934 Jps # 查看启动日志 [root@localhost bin]# tail -f -n 500 /usr/local/rocketmq/logs/rocketmqlogs/namesrv.log [root@localhost bin]# tail -f -n 500 /usr/local/rocketmq/logs/rocketmqlogs/broker.log
-
启动brokerServer B,在12主机
[root@localhost bin]# cd /usr/local/rocketmq/bin [root@localhost bin]# nohup sh mqbroker -c /usr/local/rocketmq/conf/2m-noslave/broker-b.properties >/dev/null 2>&1 &
-
停应用
[root@localhost bin]# cd /usr/local/rocketmq/bin [root@localhost bin]# sh mqshutdown broker [root@localhost bin]# sh mqshutdown namesrv