参考文档

http://blog.csdn.net/a19881029/article/details/34446629

https://github.com/alibaba/RocketMQ

http://sofar.blog.51cto.com/353572/1540874

安装包和官方的配置说明:

http://www.docin.com/p-985451416.html

 

原理图

角色说明

nameserver: 类似zookeeper 是个服务管理中心,用来记录 broker的分布情况,当前状态等等

broker:实际意义上的消息队列,有master,slave 两种状态

producer:消息的生产者

consumer:消息的消费者

 

1JDK安装

http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-linux-x64.tar.gz

# tar xvzf jdk-7u65-linux-x64.gz -C /usr/local

# rm -f jdk-7u65-linux-x64.gz

# cd /usr/local && ln -s jdk1.7.0_65 jdk

# cd /usr/local/bin && ln -s /usr/local/jdk/bin/java

 

2RocketMQ安装

https://github.com/alibaba/RocketMQ/releases

# tar xvzf alibaba-rocketmq-3.1.7.tar.gz -C /usr/local

# mv alibaba-rocketmq alibaba-rocketmq-3.1.7

# ln -s alibaba-rocketmq-3.1.7 rocketmq

# rm alibaba-rocketmq-3.1.7.tar.gz

# ll /usr/local

wKiom1PuP2TDorXeAAKWNuNdZ7w687.jpg

 

3、环境变量设置

# vim /etc/profile

export PATH=$PATH:/usr/local/bin

 

export JAVA_HOME=/usr/local/jdk

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$PATH:$JAVA_HOME/bin

 

export ROCKETMQ_HOME=/usr/local/rocketmq

export PATH=$PATH::$ROCKETMQ_HOME/bin

 

安装包解压后的目录结构

 

2m-2s-async 两主,两从,同步复制数据的配置

2m-2s-sync 两主,两从,异步复制数据的配置

2m-noslave 两主,无从的配置

 

启动nameserver, 默认端口9876

[hadoop@hadoop bin]$ nohup sh mqnamesrv &
[1] 17676
[hadoop@hadoop bin]$ nohup: appending output to “nohup.out”

[hadoop@hadoop bin]$ cat nohup.out 
The Name Server boot success.
[hadoop@hadoop bin]$ jps
17682 NamesrvStartup
17800 Jps

 

启动 master 默认端口号是 10911[hadoop@hadoop bin]$ nohup sh mqbroker -n "192.168.58.163:9876" -c ../conf/2m-2s-async/broker-a.properties &

 

[hadoop@hadoop bin]$ nohup sh mqbroker -n "192.168.58.163:9876" -c ../conf/2m-2s-async/broker-a.properties &
[2] 25493
[hadoop@hadoop bin]$ nohup: appending output to “nohup.out”

[hadoop@hadoop bin]$ cat nohup.out 
load config properties file OK, ../conf/2m-2s-async/broker-a.properties
The broker[broker-a, 192.168.58.163:10911] boot success. and name server is 192.168.58.163:9876
[hadoop@hadoop bin]$ jps
25500 BrokerStartup
25545 Jps
17682 NamesrvStartup

配置说明
 

brokerClusterName=AdpMqCluster      // broker归属的集群名

brokerName=broker-a                // broker的名字

brokerId=0                // 0 代表master >0 表示slave, 一个master 可以挂多个slave, master 和 slave 通过 brokerName 来配对

namesrvAddr=mqnameserver1:9876;192.168.1.252:9876  //nameserver 对应的IP和端口号

defaultTopicQueueNums=4               //

autoCreateTopicEnable=true            //是否允许broker自动创建Topic

autoCreateSubscriptionGroup=true      //是否允许broker自动创建订阅组

listenPort=10911  //监听的端口号

deleteWhen=04         //删除文件时间点,默认凌晨4点

fileReservedTime=120   //文件保留时间,单位小时

mapedFileSizeCommitLog=1073741824

mapedFileSizeConsumeQueue=50000000

destroyMapedFileIntervalForcibly=120000

redeleteHangedFileInterval=120000

diskMaxUsedSpaceRatio=88

 

storePathRootDir=/data/rocketmq/store

storePathCommitLog=/data/rocketmq/store/commitlog //commitlog 的存储路径

storePathIndex=/data/rocketmq/store/indexlog  //消息索引的存储路径

abortFile=/data/rocketmq/store/abortlog        //abort文件的储存路径

 

maxMessageSize=65536                     

 

flushCommitLogLeastPages=4

flushConsumeQueueLeastPages=2

flushCommitLogThoroughInterval=10000

flushConsumeQueueThoroughInterval=60000

 

brokerRole=ASYNC_MASTER                 //broker的角色, Master, SLAVE, ASYNC_MASTER, SYNC_MASTER

flushDiskType=ASYNC_FLUSH               //数据写盘方式,异步写盘, SYNC_FLUSH :同步写盘

 

checkTransactionMessageEnable=false

 

sendMessageThreadPoolNums=128          

pullMessageThreadPoolNums=128

 
posted on 2015-11-12 16:48  鳄鱼爸爸  阅读(1651)  评论(0编辑  收藏  举报