Recommendation system from scratch (2)-Zookeeper

Zookeeper installation and configuration

  1. Download Zookeeper

    Go to the download page of Zookeeper

    apache

    Select the stable version

    stable

    bin.tar.gz

    Right click to copy the link address

    https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/apache-zookeeper-3.5.6-bin.tar.gz
    

    Download using wget

    wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/apache-zookeeper-3.5.6-bin.tar.gz
    
  2. Copy files

    tar unzip

    tar -zxf apache-zookeeper-3.5.6-bin.tar.gz
    

    Copy the entire program to /usr/local/

    cp -r apache-zookeeper-3.5.6-bin /usr/local/zookeeper
    
  3. Configure Zookeeper

    cd /usr/local/zookeeper
    cp zoo_sample.cfg zoo.cfg
    vi zoo.cfg
    

    An example of the entire configuration file is as follows

     # 服务器之间或客户端与服务器之间维持心跳的时间间隔
     # tickTime以毫秒为单位。
     tickTime=2000
    
     # 集群中的follower服务器(F)与leader服务器(L)之间的初始连接心跳数
     initLimit=10
    
     # 集群中的follower服务器与leader服务器之间请求和应答之间能容忍的最多心跳数
     syncLimit=5
    
     # 快照保存目录
     # 不要设置为/tmp,该目录重新启动后会被自动清除
     dataDir=/usr/local/zookeeper/zkdata
    
     # 日志保存目录
     dataLogDir=/usr/local/zookeeper/zkdatalog
    
     # 客户端连接端口
     clientPort=2181
    
     # 客户端最大连接数。
     # 根据自己实际情况设置,默认为60个
     # maxClientCnxns=60
     # 三个接点配置,格式为:
     # server.服务编号=服务地址、LF通信端口、选举端口
     server.1=salve1:2888:3888
     server.2=slave2:2888:3888
     server.3=slave3:2888:3888
    

    The service number followed by the multiple servers filled in above will be put into the myid of the corresponding machine later

    for i in $(seq 1 3); do scp -r /usr/local/zookeeper Slave$i:/usr/local/zookeeper; done
    

    Copied to each node but has not officially run

  4. Create a working directory, configure myid

    for i in $(seq 1 3); do ssh Slave$i 'mkdir -p /usr/local/zookeeper/zkdata'; done
    for i in $(seq 1 3); do ssh Slave$i 'mkdir -p /usr/local/zookeeper/zkdatalog'; done
    for i in $(seq 1 3); do ssh Slave$i 'touch /usr/local/zookeeper/zkdata/myid'; done
    

    Then log in to each node to modify myid (the content depends on the zoo.cfg file above)

    ssh Slave1
    vi /usr/local/zookeeper/zkdata/myid
    
  5. Configure environment variables

    vi /etc/profile
    

    Add the following content

    export ZOOKEEPER_HOME=/usr/local/zookeeper
    
  6. Start Zookeeper

    Log in to each node to start zookeeper

    ssh Slave1
    cd /usr/local/zookeeper/bin
    ./zkServer.sh start
    

    View zookeeper node status

    ./zkServer.sh status
    

    Should be able to query the following information

    Status of each machine

    Execute the following command

    jps
    

    Can be seen in the output

    QuorumPeerMain
    

At this point Zookeeper distributed completion

Guess you like

Origin blog.csdn.net/JikeStardy/article/details/105210278