RocketMQ 4.5.1 双主双从异步复制环境搭建

基础环境

操作系统:CentOS7

实例:192.168.63.129,192.168.63.130,192.168.63.131,192.168.63.132

Java:jdk-8u191-linux-x64.tar.gz

安装JDK

先把系统里面自带的卸载掉

[[email protected] soft]# rpm -qa|grep java
python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_64
tzdata-java-2018e-3.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
[[email protected] soft]# rpm -e java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64 --nodeps
[[email protected] soft]# rpm -e java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_64 --nodeps
[[email protected] soft]# 

进入你JDK安装包所在的目录,然后安装JDK

# 创建一个目录存放
[[email protected] soft]# mkdir /usr/local/java
# 解压缩到这个目录
[[email protected] soft]# tar -xvf jdk-8u191-linux-x64.tar.gz -C /usr/local/java/

解压之后进入该目录可以看到

下面配置环境变量

[[email protected] java]# vim /etc/profile

加入以下内容

# java
export JAVA_HOME=/usr/local/java/jdk1.8.0_191
export JRE_HOME=/usr/local/java/jdk1.8.0_191/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

如下所示

刷新并验证

[[email protected] java]# source /etc/profile
[[email protected] java]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
[[email protected] java]# 

安装RocketMQ

首先上传到服务器,我上传到 /soft文件夹下面。然后解压

# 解压
[[email protected] soft]# unzip rocketmq-all-4.5.1-bin-release.zip -d /usr/local/
# 进入解压目录
[[email protected] soft]# cd /usr/local/
[[email protected] local]# ll
total 0
drwxr-xr-x. 2 root root   6 Apr 11  2018 bin
drwxr-xr-x. 2 root root   6 Apr 11  2018 etc
drwxr-xr-x. 2 root root   6 Apr 11  2018 games
drwxr-xr-x. 2 root root   6 Apr 11  2018 include
drwxr-xr-x. 3 root root  26 May 26 18:39 java
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root   6 Apr 11  2018 libexec
drwx------. 6 root root 103 Mar 29 17:37 rocketmq-all-4.5.0-bin-release
drwxr-xr-x. 2 root root   6 Apr 11  2018 sbin
drwxr-xr-x. 5 root root  49 May 10 07:44 share
drwxr-xr-x. 2 root root   6 Apr 11  2018 src# 改个名字
[[email protected] local]# mv rocketmq-all-4.5.1-bin-release/ rocketmq
[[email protected] local]# ll
total 0
drwxr-xr-x. 2 root root   6 Apr 11  2018 bin
drwxr-xr-x. 2 root root   6 Apr 11  2018 etc
drwxr-xr-x. 2 root root   6 Apr 11  2018 games
drwxr-xr-x. 2 root root   6 Apr 11  2018 include
drwxr-xr-x. 3 root root  26 May 26 18:39 java
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root   6 Apr 11  2018 libexec
drwx------. 6 root root 103 Mar 29 17:37 rocketmq
drwxr-xr-x. 2 root root   6 Apr 11  2018 sbin
drwxr-xr-x. 5 root root  49 May 10 07:44 share
drwxr-xr-x. 2 root root   6 Apr 11  2018 src

进入配置文件目录,修改配置文件(四台机器修改的配置文件不一样,注意名称)

[[email protected] local]# cd rocketmq/conf/2m-2s-async/
# 129节点
[[email protected] 2m-2s-async]# vim broker-a.properties
# 130节点
[[email protected] 2m-2s-async]# vim broker-a-s.properties
# 131节点
[[email protected] 2m-2s-async]# vim broker-b.properties
# 132节点
[[email protected] 2m-2s-async]# vim broker-b-s.properties

加入如下内容(四台机器加入内容一样,但是修改的文件不一样)

listenPort=10911
namesrvAddr=192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876
mapedFileSizeCommitLog=1073741824
storePathRootDir=/usr/local/rocketmq/store
storePathCommitLog=/usr/local/rocketmq/store/commitlog
storePathConsumerQueue=/usr/local/rocketmq/store/consumequeue
storePathIndex=/usr/local/rocketmq/store/index

如图:

然后新建store相关目录(四台机器一样)

[[email protected] 2m-2s-async]# mkdir /usr/local/rocketmq/store
[[email protected] 2m-2s-async]# mkdir /usr/local/rocketmq/store/commitlog
[[email protected] 2m-2s-async]# mkdir /usr/local/rocketmq/store/consumequeue
[[email protected] 2m-2s-async]# mkdir /usr/local/rocketmq/store/index

开启防火墙端口

[[email protected] 2m-2s-async]# firewall-cmd --zone=public --add-port=10911/tcp --permanent
success
[[email protected] 2m-2s-async]# firewall-cmd --zone=public --add-port=9876/tcp --permanent
success
[[email protected] 2m-2s-async]# systemctl restart firewalld

进入bin目录,准备启动nameserver,启动成功。

[[email protected] 2m-2s-async]# cd /usr/local/rocketmq/bin/
[[email protected] bin]# ./mqnamesrv &
[1] 59673
[[email protected] bin]# Java HotSpot(TM) 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
The Name Server boot success. serializeType=JSON

[[email protected] bin]# 

下面启动broker

[[email protected] bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-a.properties &
[2] 59731
[[email protected] bin]# Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000005c0000000, 8589934592, 0) failed; error=‘Cannot allocate memory‘ (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 8589934592 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/local/rocketmq/bin/hs_err_pid59738.log

[2]+  Exit 1                  ./mqbroker

报错了,内存不足。毕竟测试搭建,只有1G内存。修改runbroker.sh

[[email protected] bin]# vim runbroker.sh

修改这里

改为 -Xms256m -Xmx256m -Xmn128m

保存关闭,重启。

# 129
[[email protected] bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-a.properties &
[3] 61454
[2]   Exit 143                ./mqbroker
[[email protected] bin]# The broker[broker-a, 192.168.63.129:10911] boot success. serializeType=JSON and name server is 192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876

# 130
[[email protected] bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-a-s.properties &
[3] 60359
[2]   Exit 143                ./mqbroker
[[email protected] bin]# The broker[broker-a, 192.168.63.130:10911] boot success. serializeType=JSON and name server is 192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876

# 131
[[email protected] bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-b.properties &
[3] 60224
[2]   Exit 143                ./mqbroker
[[email protected] bin]# The broker[broker-b, 192.168.63.131:10911] boot success. serializeType=JSON and name server is 192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876

# 132
[[email protected] bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-b-s.properties &
[3] 60310
[2]   Exit 143                ./mqbroker
[[email protected] bin]# The broker[broker-b, 192.168.63.132:10911] boot success. serializeType=JSON and name server is 192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876

全部启动成功后,安装个管控台。

管控台

这里需要四台服务器开启10909端口。

[[email protected] bin]# firewall-cmd --zone=public --add-port=10909/tcp --permanent
success
[[email protected] bin]# systemctl restart firewalld

=====

https://github.com/apache/rocketmq-externals

下载好后,进入rocketmq-console目录执行打包命令

mvn clean package -Dmaven.test.skip=true

进入target目录,执行命令启动。

java -jar rocketmq-console-ng-1.0.1.jar --rocketmq.config.namesrvAddr=‘192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876‘

访问http://localhost:8080/#/cluster

关闭NameServer和Broker

[[email protected] bin]# ./mqshutdown namesrv
The mqnamesrv(59705) is running...
Send shutdown request to mqnamesrv(59705) OK
[[email protected] bin]# ./mqshutdown broker
The mqbroker(60366) is running...
Send shutdown request to mqbroker(60366) OK
[1]-  Exit 143                ./mqnamesrv

原文地址:https://www.cnblogs.com/LUA123/p/10926488.html

时间: 2024-10-03 18:20:28

RocketMQ 4.5.1 双主双从异步复制环境搭建的相关文章

4、读写分离---双主双从(mycat)

双主双从 一个主机 m1 用于处理所有写请求,它的从机 s1 和另一台主机 m2 还有它的从机 s2 负责所有读请 求.当 m1 主机宕机后,m2 主机负责写请求,m1.m2 互为备机. 角色               地址 master1          192.168.199.231 slave1             192.168.199.185 master2          192.168.199.120 slave2             192.168.199.174

rocketmq 双主双从同步写安装部署

1,机器ip 软件版本 jdk-8u131-linux-x64.tar.gz rocketmq-all-4.2.0-bin-release.zip rocketmq-console-ng-1.0.0.jar 10.15.10.238 HNVM015238 nameserver1 rocketmq-master a rocketmq-slave b 10.15.10.239 HNVM015239 nameserver2 rocketmq-master b rocketmq-slave a 2,配置

003.MMM双主-双从读写分离部署

一 前期规划 1.1 主机规划 功能 IP 主机名 server id 应用属性 VIP MySQL版本 Monitor 172.24.8.20 Monitor -- 监控 -- -- Master01 172.24.8.10 Master01 1 写-writer 172.24.8.100 MySQL 5.6.37 Master02 172.24.8.11 Master02 2 读-reader 写-writer 172.24.8.101 172.24.8.102 172.24.8.103 1

MMM双主-双从读写分离部署

目录 一 前期规划 1.1 主机规划 1.2 虚拟IP规划 1.3 用户列表 1.4 整体架构 1.4 hosts修改 1.5 NTP配置 二 部署MySQL 2.1 安装MySQL 三 双主复制部署 3.1 master01 my.cf配置 3.2 Master02 my.cf配置 3.4 Master02创建账号 3.5 启动双主复制 3.3 启动Master02的slave功能 四 其他节点配置 4.1 所有Slave节点配置配置 4.2 所有Slave节点创建账号 4.2 Slave节点

【转载】MySQL双主双从高可用集群架构

双浮动VIP 原文地址:http://www.linuxcache.com/archives/2907 转载请注明原文地址.

Linux Centos7中Mysql双主双从服务器部署

作用:由于架构的扩展,业务量的越来越大,I/O访问频率过高此时需要作多库的存储,提高单个及其的I/O性能.而当一个主服务器出现故障后,此时另一个服务器仍可以继续工作 一.环境准备4台干净的mysql服务器192.168.122.196 master1192.168.122.197 master2192.168.122.198 slave1192.168.122.199 slave2如果是克隆的虚拟机要修改每台服务器UUID //vim /var/lib/mysql/auto.cnf在每台服务器中

keepAlived+nginx实现高可用双主模型LVS

实验目的: 利用keepalived实现高可用反向代理的nginx.以及双主模型的ipvs 实验环境: node1:在nginx做代理时做反向代理节点,在keepalived实现LVS时做Director.VIP1:172.16.18.22 VIP2:172.16.18.23 node2:在nginx做代理时做反向代理节点,在keepalived实现LVS时做Director.VIP1:172.16.18.22 VIP2:172.16.18.23 node3:在nginx做代理时做web服务器.

Apache+lvs高可用+keepalive(主从+双主模型)

Apache+lvs高可用+keepalive(主从+双主模型)???? keepalive实验准备环境: httpd-2.2.15-39.el6.centos.x86_64 keepalived-1.2.13-1.el6.x86_64.rpm ? ? ???? 实验拓扑图: ? ? ? ? LVS+Keepalived 实现高可用的前端负载均衡器 ? node15: 1.安装httpd [[email protected] ~]# yum intsall -y httpd 2.配置httpd

Mysql集群讲解(五) 多主多从环境搭建

A:概述: 一主多从,可以缓解读的压力,但是一旦主宕机了,就不能写了: 所以我们可以采用双主双从架构 架构规划: 主master 3307 ---> 从slave 3309 主master 3308 ---> 从slave 3310 3307 <---> 3308 互为主从 2个写节点,每个写节点下又是2个读节点: B:文件配置: 1.配置每一台MySQL服务器的配置文件my.cnf [client] port        = 3307 socket      = /usr/lo