Zookeeper简易实践操作

下载安装Zookeeper

          1.解压zookeeper
             tar -zvxf /zookeeper安装包所在路径 -C /zookeeper解压后所在路径
          
          2.修改名字
             mv /带版本号zookeeper的路径 /改名字为zookeeper的路径
          
          3.创建目录
            创建data和logs目录(在 zookeeper 的安装目录下创建)
             dxc
             cd /zookeeper的路径
             mkdir data && mkdir logs
          
          4.为每个节点编号
              echo 1 > /zookeeper的路径/data/myid
         
         5.修改配置文件zoo.cfg
           cp /zookeeper的路径/conf/zoo_sample.cfg /zookeeper的路径/conf/zoo.cfg
           vi /zookeeper的路径/conf/zoo.cfg
           修改参数内容:
           dataDir = /zookeeper/data 的完整路径
           末尾添加
           server.1 = dxc:2888:3888
           server.2 = dxc2:2888:3888
           server.3 = dxc3:2888:3888
           
         6.修改Zookerper 安装目录的归属用户为 hadoop用户
            chown -R hadoop:hadoop /zookeeper的路径
         
         7.复制节点
            dxc
            scp -r /zookeeper的路径 dxc2:/复制的位置
            scp -r /zookeeper的路径 dxc3:/复制的位置
         
         8.修改节点的配置
            dxc2
            chown -R hadoop:hadoop /zookeeper的路径
        
         9.配置该节点编号
           dxc2
           echo 2 > /zookeeper的路径/data/myid
         
         10.在节点二上配置其编号
    	    配置zookeeper的归属
            dxc2
            chown -R hadoop:hadoop /zookeeper的路径
            配置编号
            echo 3 > /zookeeper的路径/data/myid
         
         11.系统环境变量配置
               dxc
               vi /etc/profile
               末尾添加
               # set zookeeper environment
               # Zookeeper 安装目录
               export ZOOKEEPER_HOME=/zookeeper的安装路径
               
               # Zookeeper 可执行程序目录
               export PATH=$PATN:$ZOOKEEPER_HOME/bin
           
           12.启动Zookeeper
                分别在 dxc dxc2 dxc3 三个节点使用 zkServer.sh start 命令启动 Zookeeper
                dxc
                su - hadoop
                source /etc/profile
                zkServer.sh start
                dxc2
                su - hadoop
                source /etc/profile
                zkServer.sh start
                dxc3
                su - hadoop
                source /etc/profile
                zkServer.sh start
              
              13.查看三台机器的zookeeper的运行状态
      	        dxc
                zkServer.sh status
                mode:follower
                dxc2
                zkServer.sh status
                mode:follower
                dxc3
                zkServer.sh status
                mode:follower
上一篇:zookeeper 集群安装部署


下一篇:脑裂是啥子?