首页 > 代码库 > ansible安装zookeeper
ansible安装zookeeper
这个主要是给hbase用的,启动用户为hadoop
cat iphost.txt n16 172.x.x.1 d17 172.x.x.2 d18 172.x.x.3 cd /etc/ansible/shell cat iphost.py #!/usr/bin/python # coding:utf-8 import sys try: import json except ImportError: import simplejson as json def grouplist(): inventory = {} #inventory[‘local‘] = [] sfile=‘/etc/ansible/shell/iphost.txt‘ with open(sfile,‘rb‘) as f: for i in f.readlines(): group=i.strip().split()[0] name=i.strip().split()[1] if not group in inventory: inventory[group] = { ‘hosts‘: [] } inventory[group][‘hosts‘].append(name) print json.dumps(inventory, indent=4) def hostinfo(name): vars = {} vars = { ‘admin‘: ‘Jane Jolie‘, ‘datacenter‘: 1 } print json.dumps(vars, indent=4) if __name__ == ‘__main__‘: if len(sys.argv) == 2 and (sys.argv[1] == ‘--list‘): grouplist() elif len(sys.argv) == 3 and (sys.argv[1] == ‘--host‘): hostinfo(sys.argv[2]) else: print "Usage: %s --list or --host <hostname>" % sys.argv[0] sys.exit(1) cd /etc/ansible/zookeeper tree . ├── hosts ├── roles │ └── http │ ├── default │ ├── files │ │ ├── java.env │ │ └── zookeeper.tar.gz │ ├── handlers │ ├── meta │ │ └── test │ ├── tasks │ │ ├── main v1.yml │ │ └── main.yml │ ├── templates │ │ └── zoo.cfg │ └── vars │ └── main.yml └── site.yml cd /etc/ansible/zookeeper/roles/http/tasks [root@jk tasks]# ls main v1.yml main.yml [root@jk tasks]# cat main.yml - name: Stop zookeeper shell: ps -ef|grep zookeeper|grep -v grep|awk ‘{print $2}‘|xargs kill -9 >>/dev/null 2>&1 ignore_errors: yes - name: Copy zookeeper copy: src=http://www.mamicode.com/zookeeper.tar.gz dest=/tmp/zookeeper.tar.gz owner=hadoop group=hadoop"sudo -i -u hadoop nohup sh /home/hadoop/zookeeper/bin/zkServer.sh start &" >>/etc/rc.d/rc.local when: zookeepers.stdout|int == 0 cd /etc/ansible/zookeeper/roles/http/vars cat main.yml ip1: 172.x.x.1 ip2: 172.x.x.2 ip3: 172.x.x.3 安装 ansible-playbook -i /etc/ansible/shell/iphost.py site.yml --extra-vars "myid=1 host=n16" ansible-playbook -i /etc/ansible/shell/iphost.py site.yml --extra-vars "myid=2 host=d17" ansible-playbook -i /etc/ansible/shell/iphost.py site.yml --extra-vars "myid=3 host=d18" 用ansible的shell sudo -i -u hadoop /home/hadoop/zookeeper/bin/zkServer.sh start 启动zkServer
本文出自 “python 运维” 博客,谢绝转载!
ansible安装zookeeper
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。