docker安装efk

[root@elk elfk]# cat docker-compose.yml
version: '3'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
    container_name: elasticsearch
    volumes:
      - ./elasticsearch:/usr/share/elasticsearch
    ports:
      - "9200:9200"
      - "9300:9300"
    restart: always

  kibana:
    image: docker.elastic.co/kibana/kibana:7.10.2
    container_name: kibana
    ports:
      - "5601:5601"
    volumes:
      - ./kibana:/usr/share/kibana
    restart: always

  filebeat:
    image: elastic/filebeat:7.10.2
    container_name: filebeat1
    volumes:
      - ./filebeat:/usr/share/filebeat
    restart: always
    user: root

  logstash:
    image: logstash:7.17.20
    container_name: logstash
    volumes:
      - ./logstash:/usr/share/logstash
    restart: always

这是批量安装filebeat的ansiable  可以学习参考

[root@elk ansiable]# cat playbook-filebeat.yaml 
---
- name: Transfer file with password authentication
  hosts: host_group  # 替换为你的主机组名称
  gather_facts: yes
  vars:
    ansible_user: "root"
    ansible_password: "Qwe123!!"
  tasks:
    - name: 复制filebeat-start.sh文件到远程主机
      copy:
        src: "/elfk/filebeat-start.sh"
        dest: "/elfk/"
    - name: 复制filebeat.tar文件到远程主机
      copy:
        src: "/elfk/filebeat.tar"
        dest: "/elfk/"
    - name: 复制docker-compose.yml文件到远程主机
      copy:
        src: "/elfk/docker-compose.yml"
        dest: "/elfk/"
    - name: 脚本授权
      command: "chmod 777 /elfk/filebeat-start.sh"
    - name: 执行启动脚本
      command: "/elfk/filebeat-start.sh"
[root@elk ansiable]# cat playbook.yaml
---
- name: Transfer file with password authentication
  hosts: host_group  # 替换为你的主机组名称
  gather_facts: yes
  vars:
    ansible_user: "root"
    ansible_password: "Qwe123!!"
  tasks:
    - name: 复制文件到远程主机
      copy:
        src: "/elfk/{{ item.src }}"
        dest: "/elfk/"
      loop:
        - { src: "filebeat.tar" }
        - { src: "filebeat" }
        - { src: "docker-compose.yml" }

    - name: 修改 filebeat.yml 文件权限
      command: chmod go-w /elfk/filebeat/filebeat.yml
    - name: 重启 Docker 服务
      systemd:
        name: docker
        state: restarted
        enabled: yes

    - name: 载入 Filebeat 镜像并启动容器
      shell: "docker load -i /elfk/filebeat.tar && docker-compose up -d filebeat"
      args:
        executable: /bin/bash
    - name: 载入 Filebeat 镜像
      shell: docker load -i /elfk/filebeat.tar
      args:
        executable: /bin/bash

    - name: 启动 Filebeat 容器
      command: /usr/local/bin/docker-compose -f /elfk/docker-compose.yml up -d filebeat
      args:
        executable: /bin/bash

    - name: 检查容器状态
      docker_container:
        name: filebeat
      register: container_info

    - name: 显示容器状态
      debug:
        var: container_info

[root@elk ansiable]# ll
总用量 12
-rw-r--r-- 1 root root  737 4月  22 23:20 playbook-filebeat.yaml
-rw-r--r-- 1 root root 1295 4月  22 19:51 playbook.yaml
-rw-r--r-- 1 root root  309 4月  22 13:18 playbook.yaml.bak
[root@elk ansiable]# cat playbook.yaml.bak 
---
- name: Transfer file with password authentication
  hosts: host_group  # 替换为你的主机组名称
  gather_facts: yes
  vars:
    ansible_user: root
    ansible_password: Qwe123!!
  tasks:
    - name: Install rsync package
      ansible.builtin.package:
        name: rsync
        state: present

相关推荐

  1. docker安装efk

    2024-04-25 07:24:08       15 阅读
  2. Docker安装ELKDocker Compose)

    2024-04-25 07:24:08       30 阅读
  3. bitnami Docker 安装ELK(elasticsearch, logstash, kibana)

    2024-04-25 07:24:08       35 阅读
  4. centos7 安装EFK脚本

    2024-04-25 07:24:08       40 阅读
  5. 基于Docker 快速搭建EFK日志中心

    2024-04-25 07:24:08       9 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-25 07:24:08       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-25 07:24:08       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-25 07:24:08       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-25 07:24:08       20 阅读

热门阅读

  1. 【Jenkins】Jenkins nohup执行失败

    2024-04-25 07:24:08       19 阅读
  2. Mac 上可以使用 ping 端口

    2024-04-25 07:24:08       18 阅读
  3. pnpm的安装与配置(Windows/macOS)

    2024-04-25 07:24:08       16 阅读
  4. Swift加载Lottie

    2024-04-25 07:24:08       16 阅读
  5. 基于Promise + XHR 封装myAxios函数

    2024-04-25 07:24:08       16 阅读
  6. Flutter 项目添加 IOS 小组件开发记录

    2024-04-25 07:24:08       14 阅读
  7. linux命令之printf

    2024-04-25 07:24:08       14 阅读
  8. TCP详解

    TCP详解

    2024-04-25 07:24:08      13 阅读
  9. 【Altium Designer-画板指南】

    2024-04-25 07:24:08       11 阅读