• Ansible搭建zookeeper


    资料文末下载

    搭建zookeeper集群 附带安装treejdkdevel工具

    创建roles目录 ,图下

    zookeeper

    ├── files

       └── zookeeper-3.4.5.tar.gz

    ├── templates

       └── zoo.cfg.j2

    ├── vars

       └── main.yml

    └── zookeeper.yml

     zookeeper.yml

    - hosts: zookeeper

      remote_user: root

      roles:

      - zookeeper

      tasks:

        - name: jps tool install

          yum: name={{item}} state=present

          with_items:

            - java-1.8.0-openjdk-devel.x86_64

            - tree

        - name: mkdir directory for bigdata data

          file: dest={{BigdataDir}} mode=0755 state=directory

        - name: install zookeeper

          unarchive: src={{AnsibleDir}}/zookeeper/files/{{zookeeper_file_name}}.tar.gz dest={{BigdataDir}}

        - name: install configuration file for zookeeper

          template: src={{AnsibleDir}}/zookeeper/templates/zoo.cfg.j2 dest={{BigdataDir}}/{{zookeeper_file_name}}/conf/zoo.cfg

        - name: create logdata  directory

          file: dest={{BigdataDir}}/zookeeper/dataLogDir mode=0755 state=directory

          file: dest={{BigdataDir}}/zookeeper/data  mode=0755 state=directory

        - name: add myid file

          shell: echo {{ myid }} > {{BigdataDir}}/zookeeper/data/myid

        - name: start zookeeper

          shell:  sh {{BigdataDir}}/{{zookeeper_file_name}}/bin/zkServer.sh start

          tags:

          - start zookeeper

    Var main.yml

    zk1: 192.168.193.57

    zk2: 192.168.193.58

    zk3: 192.168.193.59

    BigdataDir: /opt/hzgc

    AnsibleDir: /etc/ansible/roles

    zookeeper_file_name: zookeeper-3.4.5

     templates zoo.cfg.j2

    tickTime=2000

    initLimit=10

    syncLimit=5

    clientPort=2181

    dataLogDir={{BigdataDir}}/zookeeper/dataLogDir

    dataDir={{BigdataDir}}/zookeeper/data

    clientPort=2181

    quorumListenOnAllIPs=true

    server.1={{zk1}}:2888:3888

    server.2={{zk2}}:2888:3888

    server.3={{zk3}}:2888:3888

    执行任务 ansible-playbook -i /etc/ansible/hosts zookeeper.yml  

    执行输出

    PLAY [zookeeper] ********************************************************************************************************************************

    TASK [Gathering Facts] **************************************************************************************************************************

    ok: [node2]

    ok: [node3]

    ok: [node1]

    TASK [jps tool install] *************************************************************************************************************************

    ok: [node3] => (item=[u'java-1.8.0-openjdk-devel.x86_64', u'tree'])

    ok: [node1] => (item=[u'java-1.8.0-openjdk-devel.x86_64', u'tree'])

    ok: [node2] => (item=[u'java-1.8.0-openjdk-devel.x86_64', u'tree'])

    TASK [mkdir directory for bigdata data] *********************************************************************************************************

    ok: [node1]

    ok: [node3]

    ok: [node2]

    TASK [install zookeeper] ************************************************************************************************************************

    ok: [node1]

    ok: [node2]

    ok: [node3]

    TASK [install configuration file for zookeeper] *************************************************************************************************

    ok: [node1]

    ok: [node3]

    ok: [node2]

    TASK [create logdata  directory] ***************************************************************************************************************

    changed: [node1]

    changed: [node2]

    changed: [node3]

    TASK [add myid file] ****************************************************************************************************************************

    changed: [node2]

    changed: [node1]

    changed: [node3]

    TASK [start zookeeper] **************************************************************************************************************************

    changed: [node1]

    changed: [node2]

    changed: [node3]

    PLAY RECAP **************************************************************************************************************************************

    node1                      : ok=8    changed=3    unreachable=0    failed=0   

    node2                      : ok=8    changed=3    unreachable=0    failed=0   

    node3                      : ok=8    changed=3    unreachable=0    failed=0  

    验证:目标服务器 jps -m 验证即可。

     

    nhz94259@163.com
  • 相关阅读:
    js中不同的height, top的对比
    正则表达式入门以及记录
    CSS小记(持续更新......)
    Git远程操作
    Git Push 避免用户名和密码方法
    Git本地操作
    CSS3动画属性
    c语言文法
    实验一、词法分析器实验
    词法分析器
  • 原文地址:https://www.cnblogs.com/nhz-M/p/10718043.html
Copyright © 2020-2023  润新知