docker-compose.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. version: "3"
  2. services:
  3. es-master:
  4. container_name: es-master
  5. hostname: es-master
  6. image: elasticsearch:7.1.1
  7. restart: always
  8. ports:
  9. - 9200:9200
  10. - 9300:9300
  11. volumes:
  12. - ./elasticsearch/master/conf/es-master.yml:/usr/share/elasticsearch/config/elasticsearch.yml
  13. - ./elasticsearch/master/data:/usr/share/elasticsearch/data
  14. - ./elasticsearch/master/logs:/usr/share/elasticsearch/logs
  15. environment:
  16. - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
  17. es-slave1:
  18. container_name: es-slave1
  19. image: elasticsearch:7.1.1
  20. restart: always
  21. ports:
  22. - 9201:9200
  23. - 9301:9300
  24. volumes:
  25. - ./elasticsearch/slave1/conf/es-slave1.yml:/usr/share/elasticsearch/config/elasticsearch.yml
  26. - ./elasticsearch/slave1/data:/usr/share/elasticsearch/data
  27. - ./elasticsearch/slave1/logs:/usr/share/elasticsearch/logs
  28. environment:
  29. - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
  30. es-slave2:
  31. container_name: es-slave2
  32. image: elasticsearch:7.1.1
  33. restart: always
  34. ports:
  35. - 9202:9200
  36. - 9302:9300
  37. volumes:
  38. - ./elasticsearch/slave2/conf/es-slave2.yml:/usr/share/elasticsearch/config/elasticsearch.yml
  39. - ./elasticsearch/slave2/data:/usr/share/elasticsearch/data
  40. - ./elasticsearch/slave2/logs:/usr/share/elasticsearch/logs
  41. environment:
  42. - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
  43. es-head:
  44. container_name: es-head
  45. image: mobz/elasticsearch-head:5
  46. restart: always
  47. ports:
  48. - 9100:9100
  49. depends_on:
  50. - es-master
  51. - es-slave1
  52. - es-slave2
  53. kibana:
  54. container_name: kibana
  55. hostname: kibana
  56. image: kibana:7.1.1
  57. restart: always
  58. ports:
  59. - 5601:5601
  60. volumes:
  61. - ./kibana/conf/kibana.yml:/usr/share/kibana/config/kibana.yml
  62. environment:
  63. - elasticsearch.hosts=http://es-master:9200
  64. depends_on:
  65. - es-master
  66. - es-slave1
  67. - es-slave2
  68. filebeat:
  69. # 容器名称
  70. container_name: filebeat
  71. # 主机名称
  72. hostname: filebeat
  73. # 镜像
  74. image: docker.elastic.co/beats/filebeat:7.1.1
  75. # 重启机制
  76. restart: always
  77. # 持久化挂载
  78. volumes:
  79. - ./filebeat/conf/filebeat.yml:/usr/share/filebeat/filebeat.yml
  80. # 映射到容器中[作为数据源]
  81. - ./logs:/home/project/elk/logs
  82. - ./filebeat/logs:/usr/share/filebeat/logs
  83. - ./filebeat/data:/usr/share/filebeat/data
  84. # 将指定容器连接到当前连接,可以设置别名,避免ip方式导致的容器重启动态改变的无法连接情况
  85. links:
  86. - logstash
  87. ports:
  88. - 9000:9000
  89. # 依赖服务[可无]
  90. depends_on:
  91. - es-master
  92. - es-slave1
  93. - es-slave2
  94. logstash:
  95. container_name: logstash
  96. hostname: logstash
  97. image: logstash:7.1.1
  98. command: logstash -f ./conf/logstash-filebeat.conf
  99. restart: always
  100. volumes:
  101. # 映射到容器中
  102. - ./logstash/conf/logstash-filebeat.conf:/usr/share/logstash/conf/logstash-filebeat.conf
  103. - ./logstash/conf/logstash.yml:/usr/share/logstash/config/logstash.yml
  104. ports:
  105. - 5044:5044
  106. depends_on:
  107. - es-master
  108. - es-slave1
  109. - es-slave2