fail 发表于 2015-9-16 09:31:17

4. 实例palybook安装管理flume

1.安装管理配置:
  # cat flume/vars/main.yml
flume_conf_dir: "/usr/local/common/flume/conf"
logFile: "{{logfile}}"
checkpoinDir: "/data/flume/checkpoint/{{app}}"
dataDir: "/data/flume/data/{{app}}"
  
# cat flume/tasks/install.yml
- name: install flume agent
yum: name=flume state=present
- name: sync config
template: src=flume.conf dest={{flume_conf_dir}}/flume.conf
- name: sync script
copy: src=flume-agent dest=/etc/init.d/flume-agent owner=root group=root mode=766
  
# cat flume/tasks/manager.yml
- name: manager flume
service: name=flume-agent state={{action}}
  
  # cat tasks/main.yml
- include: install.yml tags=install
- include: manager.yml tags=service
2. flume结构:
  # tree flume
flume
├── files
│   └── flume-agent
├── handlers
├── tasks
│   ├── install.yml
│   ├── main.yml
│   └── manager.yml
├── templates
│   └── flume.conf
└── vars
└── main.yml
3. 执行结果:


部署


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

# ansible-playbook flume.yml -e 'host="test" action="started" app="syh_php_api" logfile="/data/nginx/test.log"'
PLAY *******************************************************************
TASK: *******************************************
ok:
TASK: ***************************************************
changed:
TASK: ***************************************************
ok:
TASK: *************************************************
changed:
PLAY RECAP ********************************************************************
10.0.0.174               : ok=4    changed=2    unreachable=0    failed=0


# ps aux|grep flume
root      80491.70.1 8540576 97628 ?       Sl   19:39   0:09 /usr/bin/java -Xmx20m -cp /usr/local/common/flume/conf:/usr/local/flume/lib/* -Djava.library.path= org.apache.flume.node.Application --conf-file /usr/local/common/flume/conf/flume.conf --name a1
root   103370.00.0 103244   880 pts/0    S+   19:47   0:00 grep flume


   
# cat /usr/local/common/flume/conf/flume.conf
#Define source, channel, sink
a1.sources = r1
a1.channels = c1
a1.sinks = k1 k2
#Configure source 1
a1.sources.r1.type = exec
a1.sources.r1.channels = c1
a1.sources.r1.command = tail -F /data/nginx/test.log
a1.sources.r1.shell = /bin/bash -c
a1.sources.r1.restartThrottle = 10000
a1.sources.r1.restart = true
a1.sources.r1.batchSize = 20
a1.sources.r1.batchTimeout = 3000
#Configure channel 1
a1.channels.c1.type = file
a1.channels.c1.checkpointDir = /data/flume/checkpoint/syh_php_api
a1.channels.c1.dataDirs = /data/flume/data/syh_php_api
a1.channels.c1.capacity = 200000000
a1.channels.c1.transactionCapacity = 1000
a1.channels.c1.keep-alive = 30
a1.channels.c1.write-timeout = 30
a1.channels.c1.checkpoint-timeout=600
#Configure sinkgroups
a1.sinkgroups = g1
a1.sinkgroups.g1.sinks = k1 k2
a1.sinkgroups.g1.processor.type = load_balance
a1.sinkgroups.g1.processor.backoff = true
a1.sinkgroups.g1.processor.selector = round_robin
a1.sinkgroups.g1.processor.selector.maxTimeOut = 600000
#Configure sink 1
a1.sinks.k1.type = avro
a1.sinks.k1.channel = c1
a1.sinks.k1.hostname = hdcollect-s1.wepiao.com
a1.sinks.k1.port = 40003
#Configure k1
a1.sinks.k2.type = avro
a1.sinks.k2.channel = c1
a1.sinks.k2.hostname = hdcollect-s2.wepiao.com
a1.sinks.k2.port = 40003

管理


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

# ansible-playbook flume.yml -e 'host="test" action="stopped"' --tags service
PLAY *******************************************************************
TASK: *************************************************
changed:
PLAY RECAP ********************************************************************
10.0.0.174               : ok=1    changed=1    unreachable=0    failed=0

# /etc/init.d/flume-agent status
flume-ng agent is not running                              

# ansible-playbook flume.yml -e 'host="test" action="started"' --tags service      
PLAY *******************************************************************
TASK: *************************************************
changed:
PLAY RECAP ********************************************************************
10.0.0.174               : ok=1    changed=1    unreachable=0    failed=0

# /etc/init.d/flume-agent status
flume-ng agent is running                                    


来自为知笔记(Wiz)  
页: [1]
查看完整版本: 4. 实例palybook安装管理flume