Zookeeper+Metaq 集群配置
1、ip与主机对应关系[ 3台机器一样]:
[root@gyv9 u1]#vim /etc/hosts
192.168.0.206 gy206
192.168.0.109 gyv9
192.168.0.111 gyv11
2、zookeeper安装配置
[root@gyv9 u1]# mkdir -p/usr/local/zookeeper
[root@gyv9 u1]# tar zxvf zookeeper-3.4.3.tar.gz
[root@gyv9 u1]# mv zookeeper-3.4.3/usr/local/zookeeper
1)zoo.cfg配置:
[root@gyv9 u1]# vim /usr/local/zookeeper/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir = /u1/mq/zookeeper_data
clientPort=2181
server.1=gyv9:2888:3888 #注意:server的编号最好同下面所在服务器中myid一致!
server.2=gyv11:2888:3888
server.3=gy206:2888:3888
2)分发:
#首先配置好gyv9 (任选一台,配置见上)
[root@gyv9 u1]# scp -r zookeeper/192.168.0.206:/usr/local/
[root@gyv9 u1]# scp -r zookeeper/192.168.0.111:/usr/local/
[root@gyv9 u1]# mkdir -p/u1/mq/zookeeper_data
[root@gyv9 u1]# echo "1" > /u1/mq/zookeeper_data/myid #注意:myid配置时的路径
[root@gyv11 u1]# echo "2" > /u1/mq/zookeeper_data/myid
[root@gy206 u1]# echo "3" > /u1/mq/zookeeper_data/myid
3)启动:
[root@gyv9 u1]# cd/usr/local/zookeeper
[root@gyv9 zookeeper]# bin/zkServer.sh start
启动顺序:gyv9 -> gyv11 -> gy206
4)查看日志:
[root@gyv9 zookeeper]# tail -500f zookeeper.out
5)查看服务状态:
[root@gyv9 zookeeper]# cd /usr/local/zookeeper
[root@gyv9 zookeeper]# bin/zkServer.sh status
6)从任一节点建立到集群的链接:
[root@gyv9 zookeeper]# bin/zkCli.sh -server gyv9:2181
3、metaq安装配置:(这里选取其中一台为例)
1)安装:
[root@gyv9 zdh]# tar zxvf taobao.tar.gz
[root@gyv9 zdh]# mv taobao /usr/local/
[root@gyv9 zdh]# groupadd metaq
[root@gyv9 zdh]# uesradd metaq -g metaq
[root@gyv9 zdh]# cd /usr/local/taobao/metamorphosis-server-wrapper/conf
2)配置:
[root@gyv9 conf]# vim server.ini
[system]
brokerId=0 #注意:brokerid 确保是集群中唯一的,可选取:1/2/3
numPartitions=1
serverPort=8123
unflushThreshold=0
unflushInterval=10000
maxSegmentSize=1073741824
maxTransferSize=1048576
deletePolicy=delete,168
deleteWhen=0 0 6,18 * * ?
flushTxLogAtCommit=1
dataPath=/u1/mq/metaq/data
dataLogPath=/u1/mq/metaq/log
[zookeeper] #注意一定要配置的是集群而非集群中一台ip和端口
zk.zkConnect=192.168.0.109:2181,192.168.0.111:2181,192.168.0.206:2181
zk.zkSessionTimeoutMs=30000
zk.zkConnectionTimeoutMs=30000
zk.zkSyncTimeMs=5000
;;Topics section
[topic=test]
stat=true
[topic=twitter]
stat=true
[topic=weibo]
stat=true
[topic=log]
stat=true
[topic=order]
stat=true
[topic=order_processing]
stat=true
[topic=logAction]
stat=true
[root@gyv9 zdh]# mkdir -p /u1/mq/metaq/data
[root@gyv9 zdh]# mkdir -p /u1/mq/metaq/log
[root@gyv9 local]# chown -R metaq.metaq taobao
#常用命令参数:
[root@gyv9 taobao]# bin/ metaServer.sh {start,stop, status}
推荐博文:
http://alibaba.github.io/metaq/document/design/design.htm
http://zookeeper.apache.org/