zoukankan      html  css  js  c++  java
  • CentOS中配置CDH版本的ZooKeeper

    三台CentOS:Host0,Host1,Host2

    在三台中分别安装zookeeper-server

    yum install zookeeper-server -y

    修改zookeeper的配置文件(/etc/zookeeper/conf/zoo.cfg)

    因为zookeeper集群共有3个节点,所以在配置文件中添加server.0,server.1,server.2

    # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements.  See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License.  You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    maxClientCnxns=50
    # 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=/var/lib/zookeeper
    # the port at which the clients will connect
    clientPort=2181
    # the directory where the transaction logs are stored.
    dataLogDir=/var/lib/zookeeper
    #server
    server.0 = Host0:2888:3888
    server.1 = Host1:2888:3888
    server.2 = Host2:2888:3888

    2888:3888是Zookeeper多节点之间的通信端口

    2888接收端端口,3888发送端端口

    在各个Host中添加myid文件,并修改文件所属用户。

    echo "0" > /var/lib/zookeeper/myid
    chown zookeeper:zookeeper /var/lib/zookeeper/myid

    注意,三个主机的/var/lib/zookeeper/myid文件内容不能相同,且与之间的server.0,server.1,server.2的0,1,2相对应。

    初始化zookeeper,并启动zookeeper

    service zookeeper-server init
    service zookeeper-server start

    查看zookeeper节点状态

    [root@Host0 ~]# zookeeper-server status
    JMX enabled by default
    Using config: /etc/zookeeper/conf/zoo.cfg
    Mode: follower
    
    [root@Host1 ~]# zookeeper-server status
    JMX enabled by default
    Using config: /etc/zookeeper/conf/zoo.cfg
    Mode: leader
    
    [root@Host2 ~]# zookeeper-server status
    JMX enabled by default
    Using config: /etc/zookeeper/conf/zoo.cfg
    Mode: follower

    可得Host1是leader,Host0和Host2是follower

  • 相关阅读:
    PostgreSQL操作问题(转载)
    psql执行的时候不输入密码的设定 (转载)
    项目管理——对事不对人(转载)
    软件项目经理应有的能力和素质(转载)
    Postgresql数据库的一些字符串操作函数
    8 of the best web design resource pages(转载)
    再谈:Word转PDF及SWF在线浏览——Flash Paper
    项目VS产品
    PostgreSQL+PostGIS的使用(转载)
    12+ open source projects for .NET you probably didn’t know about(转载)
  • 原文地址:https://www.cnblogs.com/Skyar/p/5836810.html
Copyright © 2011-2022 走看看