ansible安裝zookeeper
這個主要是給hbase用的,啟動使用者為hadoop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
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 = zookeeper.tar.gz dest = / tmp / zookeeper.tar.gz owner = hadoop group = hadoop
- name: Uncompression
shell: tar zxf / tmp / zookeeper.tar.gz - C / home / hadoop / && rm - rf / tmp / zookeeper.tar.gz
- name: Copy env
copy: src = java.env dest = / home / hadoop / zookeeper / conf / java.env owner = hadoop group = hadoop
- name: mkdir
shell: mkdir / home / hadoop / zookeeper / data && mkdir / home / hadoop / zookeeper / datalog /
ignore_errors: yes
- name: Copy zoo.cfg
template: src = zoo.cfg dest = / home / hadoop / zookeeper / conf / zoo.cfg owner = hadoop group = hadoop mode = 0755
- name: echo myid
shell: echo {{ myid }} > / home / hadoop / zookeeper / data / myid
- name: chown
shell: chown - R hadoop.hadoop / home / hadoop / zookeeper
- name: Start zookeeper Service
shell: sudo - i - u hadoop nohup sh / home / hadoop / zookeeper / bin / zkServer.sh start &
- name: wc
shell: cat / etc / rc.d / rc.local|grep zkServer|wc - l
register: zookeepers
ignore_errors: True
- name: Add Boot Start zookeeper Service
shell: echo "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 |
本文轉自 liqius 51CTO部落格,原文連結:http://blog.51cto.com/szgb17/1926501,如需轉載請自行聯絡原作者
相關文章
- 【zookeeper安裝】
- Zookeeper安裝
- Centos 安裝yum,安裝ansibleCentOS
- yum安裝ansible
- Ansible安裝mysqlMySql
- Ansible學習筆記-Ansible安裝筆記
- Zookeeper 安裝配置
- docker安裝zookeeperDocker
- Zookeeper的安裝
- Ubuntu 安裝 ZooKeeperUbuntu
- Mac 安裝 zookeeperMac
- ZooKeeper 安裝部署
- Zookeeper安裝部署
- 離線安裝ansible
- 安裝ansible-2.4.2
- 安裝ansible-2.5.0
- Ansible安裝指令碼指令碼
- Ansible原理和安裝
- codis安裝 (java 安裝 + zookeeper 安裝 + go 安裝 + codis 安裝JavaGo
- Zookeeper單機安裝
- kafka和zookeeper安裝Kafka
- ZooKeeper安裝筆記筆記
- centos下安裝ZooKeeperCentOS
- Zookeeper 安裝和配置
- Ubuntu_安裝ZookeeperUbuntu
- 3-ZooKeeper安裝
- Ansible的安裝及部署
- zookeeper安裝部署步驟
- 初識zookeeper和安裝
- ZooKeeper三種安裝模式模式
- zookeeper下載安裝使用
- 滴滴雲安裝並使用 Ansible
- 使用 Ansible 安裝部署 TiDBTiDB
- ansible之一:安裝與配置
- Docker教程之十一安裝 ZookeeperDocker
- 安裝Zookeeper和Kafka叢集Kafka
- rpm方式離線安裝ansible
- ansible2.4安裝和體驗