ansible实现ELK
一.环境准备
内存调2G!配置时间同步 !!!
主机名 |
ip |
端口 |
服务 |
m01 |
10.0.0.61 |
22 |
ansible |
db04 |
10.0.0.54 |
5601.9200.9300 |
kibana,elasticsearch |
db05 |
10.0.0.55 |
9200.9300 |
kibana,elasticsearch |
db06 |
10.0.0.56 |
9200.9300 |
kibana,elasticsearch |
web01 |
10.0.0.7 |
8080.80 |
nginx,tomcat,logstash |
二.操作步骤
[root@m01 ~]
[root@m01 ~]
[root@m01 ~]
[root@m01 ~]
[root@m01 ~]
[root@m01 ~]
[root@m01 ~]
[root@m01 ansible_elasticsearch]
[root@m01 ansible_elasticsearch]
[db_group]
db04 ansible_ssh_host=172.16.1.54
db05 ansible_ssh_host=172.16.1.55
db06 ansible_ssh_host=172.16.1.56
[web_group]
web01 ansible_ssh_host=172.16.1.7
[root@m01 ansible_elasticsearch]
- hosts: all
roles:
- { role: elasticsearch , when: (ansible_fqdn is match 'db*') or (ansible_fqdn is match 'web*')}
[root@m01 elasticsearch]
cluster.name: es-cluster
path.data: /service/es/data
path.logs: /service/es/logs
bootstrap.memory_lock: true
{% if ansible_fqdn == 'db04' %}
node.name: node-1
network.host: 10.0.0.54,127.0.0.1
{% elif ansible_fqdn == 'db05' %}
node.name: node-2
network.host: 10.0.0.55,127.0.0.1
{% else %}
node.name: node-3
network.host: 10.0.0.56,127.0.0.1
{% endif %}
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.0.0.54", "10.0.0.55","10.0.0.56"]
discovery.zen.minimum_master_nodes: 2
[root@m01 files]
total 635780
-rw-r--r-- 1 root root 11100954 Aug 14 09:13 apache-tomcat-10.0.0-M7.tar.gz
-rw-r--r-- 1 root root 114059630 Aug 9 18:54 elasticsearch-6.6.0.rpm
-rw-r--r-- 1 root root 1703 Aug 11 15:17 elasticsearch.service
-rw-r--r-- 1 root root 170023183 Aug 9 18:54 jdk-8u181-linux-x64.rpm
-rw-r--r-- 1 root root 185123116 Aug 9 18:54 kibana-6.6.0-x86_64.rpm
-rw-r--r-- 1 root root 190 Aug 11 15:47 kibana.yml
-rw-r--r-- 1 root root 170703770 Aug 9 18:54 logstash-6.6.0.rpm
-rw-r--r-- 1 root root 43 Aug 14 22:32 logstash.sh
-rw-r--r-- 1 root root 366 Aug 15 01:46 nginx_tomcat.conf
[root@m01 elasticsearch]
server.port: 5601