MQ整理—安装搭建一

.上篇对mq进行了简单的了解,本篇则了解一下mq的搭建过程.集群搭建类型分为好多种,多master模式;多master多slave模式。本篇我们则针对多master模式进行搭建:

一、操作etc\hosts(hosts添加信息)

我搭建的mq是通过66.132和66.137两个ip实现的mq集群。
  192.168.66.132 rocketmq-nameserver1
  192.168.66.132 rocketmq-master1
  192.168.66.137 rocketmq-nameserver2
  192.168.66.137 rocketmq-master2

二、重启网卡:service network restart

        [root@bogon java]# service network restart
        Shutting down interface eth0:  Device state: 3 (disconnected)
        [  OK  ]
        Shutting down loopback interface:  [  OK  ]
        Bringing up loopback interface:  [  OK  ]
        Bringing up interface eth0:  Active connection state: activating
        Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
        state: activated
        Connection activated
        [  OK  ]

三、互相ping,看是否能ping通

        [root@bogon ~]# ping 192.168.66.132
        PING 192.168.66.132 (192.168.66.132) 56(84) bytes of data.
        64 bytes from 192.168.66.132: icmp_seq=1 ttl=64 time=0.506 ms
        64 bytes from 192.168.66.132: icmp_seq=2 ttl=64 time=0.181 ms
        64 bytes from 192.168.66.132: icmp_seq=3 ttl=64 time=0.172 ms
        ^C
        --- 192.168.66.132 ping statistics ---
        3 packets transmitted, 3 received, 0% packet loss, time 2494ms
        rtt min/avg/max/mdev = 0.172/0.286/0.506/0.155 ms
        [root@bogon ~]# ping rocketmq-nameserver2
        PING rocketmq-nameserver2 (192.168.66.132) 56(84) bytes of data.
        64 bytes from rocketmq-nameserver2 (192.168.66.132): icmp_seq=1 ttl=64 time=0.314 ms
        64 bytes from rocketmq-nameserver2 (192.168.66.132): icmp_seq=2 ttl=64 time=0.279 ms
        ^C
        --- rocketmq-nameserver2 ping statistics ---
        2 packets transmitted, 2 received, 0% packet loss, time 1461ms
        rtt min/avg/max/mdev = 0.279/0.296/0.314/0.024 ms
        [root@bogon ~]# ping rocketmq-master2
        PING rocketmq-master2 (192.168.66.132) 56(84) bytes of data.
        64 bytes from rocketmq-nameserver2 (192.168.66.132): icmp_seq=1 ttl=64 time=5.91 ms
        64 bytes from rocketmq-nameserver2 (192.168.66.132): icmp_seq=2 ttl=64 time=0.495 ms
        ^C
        --- rocketmq-master2 ping statistics ---
        2 packets transmitted, 2 received, 0% packet loss, time 1648ms
rtt min/avg/max/mdev = 0.495/3.202/5.910/2.708 ms

四、 上传文件,解压【两台机器】且建立软连接

解压:tar -axvf alibaba-rocketmq-3.2.6.tar.gz -C /usr/local/
建立软连接:ln -s alibaba-rocketmq-3.2.6 rocketmq
软连接

五、 创建存储路径

        [root@bogon rocketmq]# mkdir /usr/local/rocketmq/store
        [root@bogon rocketmq]# mkdir /usr/local/rocketmq/store/commitlog
        [root@bogon rocketmq]# mkdir /usr/local/rocketmq/store/consumequeue
        [root@bogon rocketmq]# mkdir /usr/local/rocketmq/store/index

六、修改RocketMQ配置文件

需要注意的是brokerName的配置,broker-a.properties broker-b.properties分别配置broker-a和broker-b

terName=rocketmq-cluster
#broker名字,注意此处不同的配置文件填写的不一样
brokerName=broker-a
#0 表示 Master, >0 表示 Slave
brokerId=0
#nameServer地址,分号分割
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/usr/local/rocketmq/store
#commitLog 存储路径
storePathCommitLog=/usr/local/rocketmq/store/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/usr/local/rocketmq/store/consumequeue
#消息索引存储路径
storePathIndex=/usr/local/rocketmq/store/index
#checkpoint 文件存储路径
storeCheckpoint=/usr/local/rocketmq/store/checkpoint
#abort 文件存储路径
abortFile=/usr/local/rocketmq/store/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128 

配置到这里,搭建的流程已经操作了一半了,后续请看下片。

posted on 2017-08-24 18:44  huohuoL  阅读(145)  评论(0编辑  收藏  举报

导航