测试服务器- Zookeeper安装手记

1.解压zookeeper-3.4.6.tar.gz到重命名到/opt/bigdata/zookeeper下 

2.创建文件夹
  1. #进入到Zookeeper安装目录执行
  2. mkdir data
  3. mkdir log
3.进入到conf中复制并修改zoo.cfg文件
  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/bigdata/zookeeper/data
  13. dataLogDir=/opt/bigdata/zookeeper/log
  14. # the port at which the clients will connect
  15. clientPort=2181
  16. # the maximum number of client connections.
  17. # increase this if you need to handle more clients
  18. #maxClientCnxns=60
  19. #
  20. # Be sure to read the maintenance section of the
  21. # administrator guide before turning on autopurge.
  22. #
  23. # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
  24. #
  25. # The number of snapshots to retain in dataDir
  26. #autopurge.snapRetainCount=3
  27. # Purge task interval in hours
  28. # Set to "0" to disable auto purge feature
  29. #autopurge.purgeInterval=1
  30. server.1=m1:2888:3888
  31. server.2=m2:2888:3888
  32. server.3=m3:2888:3888
4.添加zk节点的myid,在data文件夹中
  1. #这个id 在别的机器上需要修改,根据zoo.cfg中声明的填写
  2. echo 1 > /opt/bigdata/zookeeper/conf/myid
5.分发整个文件夹到别的节点
  1. cd /opt/bigdata/
  2. #下面这个是我写的批量scp脚本
  3. #语法是:
  4. #Usage: /usr/bin/scp_many filename targetname host[s]
  5. #e.g: /usr/bin/scp_many love.txt /home/love.txt v2,v3,v4
  6. scp_many ./zookeeper/ $PWD m2,m3
6.执行zkServer.sh start然后在status看状态就好了。
批量scp脚本:
  1. #!/bin/bash
  2. # description: scp file to many hosts
  3. filename=$1
  4. targetname=$2
  5. hosts=$3
  6. if [ $# -lt 3 ];then
  7. echo -e "Usage:\033[45;37m $0 filename targetname host[s] \033[0m"
  8. echo -e "e.g:\033[45;37m $0 love.txt /home/love.txt v2,v3,v4\033[0m"
  9. exit 1
  10. fi
  11. #for host in $(echo $3|awk -F,)
  12. for host in ${hosts//,/ }
  13. do
  14. cmd="scp -r $filename $host:$targetname"
  15. echo -e "$\033[46;37m$cmd\033[0m"
  16. $cmd
  17. done