ddddddf 发表于 2017-4-18 12:32:33

SolrCloud之搭建Zookeeper集群

一.搭建Zookeeper集群
1.下载地址
           http://zookeeper.apache.org/releases.html#download
 
2.解压缩,tar -xvzf zookeeper-3.4.6.tar.gz 

















复制出3个节点

















# cp -r /usr/zht/zookeeper-3.4.6 zookeeper-1

# cp -r /usr/zht/zookeeper-3.4.6 zookeeper-2 

# cp -r /usr/zht/zookeeper-3.4.6 zookeeper-3

(本文是在一台机器测试,实际上肯定是要分在几台服务器上部署的,否则没有意义)

 
3.分别修改配置文件

# cd zookeeper-1/ conf/

















# cp zoo_sample.cfg zoo.cfg 

















修改zoo.cfg如下:

















# The number of milliseconds of each tick

















tickTime=2000

















# The number of ticks that the initial

















# synchronization phase can take

















initLimit=10

















# The number of ticks that can pass between

















# sending a request and getting an acknowledgement

















syncLimit=5

















# the directory where the snapshot is stored.

















dataDir=/usr/local/data/zookeeper/zookeeper-1

















dataLogDir=/usr/local/data/zookeeper/logs-1

















# the port at which the clients will connect

















clientPort=1181

















 
server.1=127.0.0.1:2888:3888

















server.2=127.0.0.1:4888:5888

















server.3=127.0.0.1:6888:7888

















        标红部分为需要修改内容,clientPort在多服务器时不必修改
 

  4.给节点分配ID
        进入上文配置的dataDir=/usr/local/data/zookeeper/zookeeper-1,新建文件:myid,内容为该节点ID
        如:/usr/local/data/zookeeper/zookeeper-1 目录下myid内容为1
 
5.启动各节点


# ./zkServer.sh start


JMX enabled by default


Using config: /usr/local/zookeeper/zookeeper-1/bin/../conf/zoo.cfg


Starting zookeeper ... STARTED


# ./zkServer.sh status


JMX enabled by default


Using config: /usr/local/zookeeper/zookeeper-1/bin/../conf/zoo.cfg


Mode: follower


 
           ./zkServer.sh  start | stop | status (start:启动  stop:关闭   status:查看状态,如谁是leader)


通过 ./zkCli.sh -server host:port  可以进入zookeeper的控制台。比如使用 : 






















# ./zkCli.sh -server 127.0.0.1:1181
 就可以登录zookeeper-1控制台





















 





















6.常用命令
    ls /等命令可以查看zookeeper上面的文件。
    例如: ls /live_nodes 查看各节点存活情况
    rmr 可以删除文件
   
页: [1]
查看完整版本: SolrCloud之搭建Zookeeper集群