美文网首页
Linux部署zookeeper集群

Linux部署zookeeper集群

作者: guaren2009 | 来源:发表于2020-05-28 06:36 被阅读0次

    ## 先在hadoop001上部署

    [hadoop@hadoop001 ~]$ tar -xzvf /home/hadoop/software/zookeeper-3.4.5-cdh5.16.2.tar.gz -C /home/hadoop/app/

    [hadoop@hadoop001 ~]$ cd ~/app/

    ## 创建软连接

    [hadoop@hadoop001 app]$ ln -s zookeeper-3.4.5-cdh5.16.2/ zookeeper

    [hadoop@hadoop001 app]$ cd zookeeper/conf/

    ## 配置conf文件

    [hadoop@hadoop001 conf]$ cp zoo_sample.cfg zoo.cfg

    [hadoop@hadoop001 conf]$ vim zoo.cfg

    # 修改数据目录

    dataDir=/home/hadoop/data/zookeeper

    # 添加zookeeper的通信端口和选举端口

    server.1=hadoop001:2888:3888

    server.2=hadoop002:2888:3888

    server.3=hadoop003:2888:3888

    # 添加并配置myid文件

    [hadoop@hadoop001 conf]$ mkdir  /home/hadoop/data/zookeeper

    [hadoop@hadoop001 conf]$ echo 1 > /home/hadoop/data/zookeeper/myid

    [hadoop@hadoop001 conf]$ cat /home/hadoop/data/zookeeper/myid

    1

    ## 在hadoop002和hadoop003上配置

    [hadoop@hadoop002 ~]$ mkdir  /home/hadoop/data/zookeeper

    [hadoop@hadoop002 ~]$ echo 2 > /home/hadoop/data/zookeeper/myid

    [hadoop@hadoop002 ~]$ cat /home/hadoop/data/zookeeper/myid

    2

    [hadoop@hadoop003 ~]$ mkdir  /home/hadoop/data/zookeeper

    [hadoop@hadoop003 ~]$ echo 3 > /home/hadoop/data/zookeeper/myid

    [hadoop@hadoop003 ~]$ cat /home/hadoop/data/zookeeper/myid

    3

    ## 拷贝hadoop001上的 ~/app/zookeeper-3.4.5-cdh5.16.2/ 到hadoop002和hadoop003上,同时修改所属用户和组,创建软连接

    [hadoop@hadoop001 conf]$ scp -r ~/app/zookeeper-3.4.5-cdh5.16.2/ hadoop002:/home/hadoop/app/

    [hadoop@hadoop001 conf]$ scp -r ~/app/zookeeper-3.4.5-cdh5.16.2/ hadoop003:/home/hadoop/app/

    ## 创建软连接

    [hadoop@hadoop002 ~]$ cd ~/app/

    [hadoop@hadoop002 app]$ ln -s zookeeper-3.4.5-cdh5.16.2/ zookeeper

    [hadoop@hadoop003 ~]$ cd ~/app/

    [hadoop@hadoop003 app]$ ln -s zookeeper-3.4.5-cdh5.16.2/ zookeeper

    ## 启动

    [hadoop@hadoop001 app]$ cd ~/app/zookeeper

    [hadoop@hadoop002 app]$ cd ~/app/zookeeper

    [hadoop@hadoop003 app]$ cd ~/app/zookeeper

    [hadoop@hadoop001 zookeeper]$ bin/zkServer.sh start

    [hadoop@hadoop002 zookeeper]$ bin/zkServer.sh start

    [hadoop@hadoop003 zookeeper]$ bin/zkServer.sh start

    [hadoop@hadoop001 zookeeper]$ bin/zkServer.sh status

    JMX enabled by default

    Using config: /home/hadoop/app/zookeeper/bin/../conf/zoo.cfg

    Mode: follower

    [hadoop@hadoop002 zookeeper]$ bin/zkServer.sh status

    JMX enabled by default

    Using config: /home/hadoop/app/zookeeper/bin/../conf/zoo.cfg

    Mode: follower

    [hadoop@hadoop003 zookeeper]$ bin/zkServer.sh status

    JMX enabled by default

    Using config: /home/hadoop/app/zookeeper/bin/../conf/zoo.cfg

    Mode: leader

    ## 配置环境变量

    [hadoop@hadoop001 ~]$ echo -e '# ZOOKEEPER ENV\nexport ZOOKEEPER_HOME=/home/hadoop/app/zookeeper\nexport PATH=$ZOOKEEPER_HOME/bin:$PATH' >> ~/.bashrc

    [hadoop@hadoop001 ~]$ source ~/.bashrc

    [hadoop@hadoop002 ~]$ echo -e '# ZOOKEEPER ENV\nexport ZOOKEEPER_HOME=/home/hadoop/app/zookeeper\nexport PATH=$ZOOKEEPER_HOME/bin:$PATH' >> ~/.bashrc

    [hadoop@hadoop002 ~]$ source ~/.bashrc

    [hadoop@hadoop003 ~]$ echo -e '# ZOOKEEPER ENV\nexport ZOOKEEPER_HOME=/home/hadoop/app/zookeeper\nexport PATH=$ZOOKEEPER_HOME/bin:$PATH' >> ~/.bashrc

    [hadoop@hadoop003 ~]$ source ~/.bashrc

    相关文章

      网友评论

          本文标题:Linux部署zookeeper集群

          本文链接:https://www.haomeiwen.com/subject/kjonahtx.html