随笔-77  评论-5  文章-2  trackbacks-0

zookeeper集群安装

测试环境redhat5.5:
vmware建两台虚拟机(btw,似乎双核系统只能建俩,3个就死掉了)
192.168.229.129
192.168.229.130


下载2011年12月15日的最新zookeeper
加压到
/opt/zookeeper-3.4.0/
配置/opt/zookeeper-3.4.0/conf/zoo.cfg
可以把那个例子考过来
Java代码 复制代码 收藏代码
  1. # The number of milliseconds of each tick   
  2. tickTime=2000  
  3. # The number of ticks that the initial    
  4. # synchronization phase can take   
  5. initLimit=10  
  6. # The number of ticks that can pass between    
  7. # sending a request and getting an acknowledgement   
  8. syncLimit=5  
  9. # the directory where the snapshot is stored.   
  10. do not use /tmp for storage, /tmp here is just    
  11. # example sakes.   
  12. dataDir=/opt/zookeeper-3.4.0/data/zookeeper   
  13. dataLogDir=/opt/zookeeper-3.4.0/data/log   
  14. # the port at which the clients will connect   
  15. clientPort=2181  
  16. #   
  17. # Be sure to read the maintenance section of the    
  18. # administrator guide before turning on autopurge.   
  19. #   
  20. # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance   
  21. #   
  22. # The number of snapshots to retain in dataDir   
  23. #autopurge.snapRetainCount=3  
  24. # Purge task interval in hours   
  25. # Set to "0" to disable auto purge feature   
  26. #autopurge.purgeInterval=1  
  27. server.1=192.168.229.129:2888:3888  
  28. server.2=192.168.229.130:2888:3888  

修改/opt/zookeeper-3.4.0/bin/zkServer.sh
Java代码 复制代码 收藏代码
  1. status)   
  2.     # -q is necessary on some versions of linux where nc returns too quickly, and no stat result is output   
  3.     #STAT=`echo stat | nc -q 1 localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//'2> /dev/null| grep Mode`   
  4.     STAT=`echo stat | nc localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//'2> /dev/null| grep Mode`  

以上这些多台机器一样

log和data都在dataDir下面
如果找不到log了用大招:
ps -ef|grep zookeeper
ls -l /proc/123123/fd
其中有一个是log
然后dataDir建立一个文件myid
在192.168.229.129上
echo 1 >/opt/zookeeper-3.4.0/data/zookeeper/myid
在192.168.229.130上
echo 2 >/opt/zookeeper-3.4.0/data/zookeeper/myid
对应zoo.cfg里面的
注意一定是数字


然后zkServer.sh start 
启动
zkServer.sh status
看状态
echo ruok|nc localhost 2181         
//are you ok?
echo dump|nc localhost 2181
echo stat|nc localhost 2181
echo srst|nc localhost 2181
zkServer.sh stop
posted on 2011-12-16 03:48 huohuo 阅读(1318) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: