CentOS 6.8 minimal版本安装RocketMQ集群

1、安装wget工具: 

yum -y install wget 

2、下载maven: 

wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo 

3、安装maven: 

yum -y install apache-maven 

4、安装git环境: 

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel 

yum install gcc perl-ExtUtils-MakeMaker 

5、下载git后,解压git: 

tar -zxvf git-2.10.2.tar.gz 

6、安装git: 

打开git解压后的目录:cd git-2.10.2 

编译:make prefix=/usr/local/git all 

安装:make prefix=/usr/local/git install 

修改git相关环境变量: 

编辑:vi /etc/bashrc 

添加:export PATH=$PATH:/usr/local/git/bin 

生效:source /etc/bashrc 

7、安装jdk(在我的安装maven文章有http://287746074.iteye.com/blog/2341697) 

再安装screen,直接就是yum install screen 

8、通过git下载rocketmq: 

git clone https://github.com/alibaba/RocketMQ.git 

9、打开rocketmq目录:cd RocketMQ 

10、执行rocketmq目录中的shell脚本:bash install.sh 

11、安装2台机器,分别为: 

192.168.10.10中存放borker-a的master和borker-b的slave 

192.168.10.11中存放borker-a的slave和borker-b的master 

12、在192.168.10.10机器中 

进入rocketmq的conf目录中的2m-2s-async目录修改broker-a.properties内容为: 

namesrvAddr=192.168.10.10:9876;192.168.10.11:9876    //所关联的namesrv地址 

brokerClusterName=FusionCluster     //集群名称 

brokerName=broker-a 

brokerId=0                                                 //0代表主 

deleteWhen=04 

fileReservedTime=48 

brokerRole=ASYNC_MASTER             //角色 

flushDiskType=ASYNC_FLUSH           //异步刷盘 

listenPort=10912   //更改端口号,同一台机器上两个broker不可采用同一端口 

storePathRootDir=/opt/rocket-logs/store 

storePathCommitLog=/opt/rocket-logs/store/commitlog  //日志存放目录 

还是在192.168.10.10这台机器中 

进入rocketmq的conf目录中的2m-2s-async目录修改broker-b-s.properties内容为: 

namesrvAddr=192.168.10.10:9876;192.168.10.11:9876 

brokerClusterName=FusionCluster 

brokerName=broker-b 

brokerId=1 

deleteWhen=04 

fileReservedTime=48 

brokerRole=SLAVE 

flushDiskType=ASYNC_FLUSH 

listenPort=10913   //更改端口号,同一台机器上两个broker不可采用同一端口 

storePathRootDir=/opt/rocket-logs/store 

storePathCommitLog=/opt/rocket-logs/store/commitlog 

13、在192.168.10.11机器中 

进入rocketmq的conf目录中的2m-2s-async目录修改broker-b.properties内容为: 

namesrvAddr=192.168.10.10:9876;192.168.10.11:9876 

brokerClusterName=FusionCluster 

brokerName=broker-b 

brokerId=0 

deleteWhen=04 

fileReservedTime=48 

brokerRole=ASYNC_MASTER 

flushDiskType=ASYNC_FLUSH 

listenPort=10912 

storePathRootDir=/opt/rocket-logs/store 

storePathCommitLog=/opt/rocket-logs/store/commitlog 

还是在192.168.10.11这台机器中 

进入rocketmq的conf目录中的2m-2s-async目录修改broker-a-s.properties内容为: 

namesrvAddr=192.168.10.10:9876;192.168.10.11:9876 

brokerClusterName=FusionCluster 

brokerName=broker-a 

brokerId=1 

deleteWhen=04 

fileReservedTime=48 

brokerRole=SLAVE 

flushDiskType=ASYNC_FLUSH 

listenPort=10913 

storePathRootDir=/opt/rocket-logs/store 

storePathCommitLog=/opt/rocket-logs/store/commitlog 

14、总结下,现在两台机器192.168.10.10和192.168.10.11,其中 

192.168.10.10机器中有broker-a的主,broker-b的从 

192.168.10.11机器中有broker-a的从,broker-b的主 

15、分别启动两台机器的服务(如果提示没有权限,则提升权限“chmod 777 mqnamesrv”等) 

先是192.168.10.10机器,进入到bin目录下执行mqnamesrv用screen启动 

screen bash mqnamesrv,如果你看到“The Name Server boot success. serializeType=JSON”,说明成功,先按ctrl+a然后再按d,发现切换回了root命令行。 

继续启动borker,screen bash mqbroker -c /opt/alibaba-rocketmq/conf/2m-2s-async/broker-b-s.properties (启动broker-b从),如果你看到“The broker[xxxxx, 192.168.10.10:10912] boot success. serializeType=JSON and name server is localhost:9876”,说明成功。 

继续启动borker,screen bash mqbroker -c /opt/alibaba-rocketmq/conf/2m-2s-async/broker-a.properties(启动broker-a主) 

16、再来192.168.10.11机器,进入到bin目录下执行mqnamesrv用screen启动,screen bash mqnamesrv。 

接着启动borker,screen bash mqbroker -c /opt/alibaba-rocketmq/conf/2m-2s-async/broker-a-s.properties(启动broker-a从) 

接着启动borker,screen bash mqbroker -c /opt/alibaba-rocketmq/conf/2m-2s-async/broker-b.properties(启动broker-b主) 

17、测试查看集群状态 

mqadmin clusterList -n 192.168.10.10:9876,如果没问题就OK了! 

其他:如果出现提示内存不足,修改这两个文件。 

bin目录下的这两个文件 

vi runserver.sh 

vi runbroker.sh 

原:JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:PermSize=128m -XX:MaxPermSize=320m" 

现:JAVA_OPT="${JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g -XX:PermSize=128m -XX:MaxPermSize=320m" 

18、参考文档 

http://blog.csdn.net/kevin3101/article/details/52947840 

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

http://blog.csdn.net/xiaojie19871116/article/details/46982907

你可能感兴趣的:(CentOS 6.8 minimal版本安装RocketMQ集群)