当前位置:   article > 正文

docker安装efk

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

先直接用docker run启动 不要挂载文件夹  将elasticsearch文件夹docker cp下来修改配置文件

最后用docker-compose启动


其他程序和上述一样

原因直接建目录挂载会有权限问题,导致启动失败

配置文件

[root@elk elfk]# cat elasticsearch/config/elasticsearch.yml 
cluster.name: "es-cluster"
network.host: 0.0.0.0
discovery.seed_hosts: ["10.10.66.2","10.10.66.5","10.10.66.6"]
node.name: 10.10.66.2
cluster.initial_master_nodes: ["10.10.66.2"]


[root@elk elfk]# cat kibana/config/kibana.yml 
#
# ** THIS IS AN AUTO-GENERATED FILE **
#

# Default Kibana configuration for docker target
server.name: kibana
server.host: "0.0.0.0"
elasticsearch.requestTimeout: 60000
elasticsearch.hosts: [ "http://10.10.66.2:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: "zh-CN"
[root@elk elfk]# 

修改后重新启动就可以了
 

  1. 这是批量安装filebeat的ansiable 可以学习参考
  2. [root@elk ansiable]# cat playbook-filebeat.yaml
  3. ---
  4. - name: Transfer file with password authentication
  5. hosts: host_group # 替换为你的主机组名称
  6. gather_facts: yes
  7. vars:
  8. ansible_user: "root"
  9. ansible_password: "Qwe123!!"
  10. tasks:
  11. - name: 复制filebeat-start.sh文件到远程主机
  12. copy:
  13. src: "/elfk/filebeat-start.sh"
  14. dest: "/elfk/"
  15. - name: 复制filebeat.tar文件到远程主机
  16. copy:
  17. src: "/elfk/filebeat.tar"
  18. dest: "/elfk/"
  19. - name: 复制docker-compose.yml文件到远程主机
  20. copy:
  21. src: "/elfk/docker-compose.yml"
  22. dest: "/elfk/"
  23. - name: 脚本授权
  24. command: "chmod 777 /elfk/filebeat-start.sh"
  25. - name: 执行启动脚本
  26. command: "/elfk/filebeat-start.sh"
  27. [root@elk ansiable]# cat playbook.yaml
  28. ---
  29. - name: Transfer file with password authentication
  30. hosts: host_group # 替换为你的主机组名称
  31. gather_facts: yes
  32. vars:
  33. ansible_user: "root"
  34. ansible_password: "Qwe123!!"
  35. tasks:
  36. - name: 复制文件到远程主机
  37. copy:
  38. src: "/elfk/{{ item.src }}"
  39. dest: "/elfk/"
  40. loop:
  41. - { src: "filebeat.tar" }
  42. - { src: "filebeat" }
  43. - { src: "docker-compose.yml" }
  44. - name: 修改 filebeat.yml 文件权限
  45. command: chmod go-w /elfk/filebeat/filebeat.yml
  46. - name: 重启 Docker 服务
  47. systemd:
  48. name: docker
  49. state: restarted
  50. enabled: yes
  51. - name: 载入 Filebeat 镜像并启动容器
  52. shell: "docker load -i /elfk/filebeat.tar && docker-compose up -d filebeat"
  53. args:
  54. executable: /bin/bash
  55. - name: 载入 Filebeat 镜像
  56. shell: docker load -i /elfk/filebeat.tar
  57. args:
  58. executable: /bin/bash
  59. - name: 启动 Filebeat 容器
  60. command: /usr/local/bin/docker-compose -f /elfk/docker-compose.yml up -d filebeat
  61. args:
  62. executable: /bin/bash
  63. - name: 检查容器状态
  64. docker_container:
  65. name: filebeat
  66. register: container_info
  67. - name: 显示容器状态
  68. debug:
  69. var: container_info
  70. [root@elk ansiable]# ll
  71. 总用量 12
  72. -rw-r--r-- 1 root root 737 422 23:20 playbook-filebeat.yaml
  73. -rw-r--r-- 1 root root 1295 422 19:51 playbook.yaml
  74. -rw-r--r-- 1 root root 309 422 13:18 playbook.yaml.bak
  75. [root@elk ansiable]# cat playbook.yaml.bak
  76. ---
  77. - name: Transfer file with password authentication
  78. hosts: host_group # 替换为你的主机组名称
  79. gather_facts: yes
  80. vars:
  81. ansible_user: root
  82. ansible_password: Qwe123!!
  83. tasks:
  84. - name: Install rsync package
  85. ansible.builtin.package:
  86. name: rsync
  87. state: present

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/505607
推荐阅读
相关标签
  

闽ICP备14008679号