导读


由于需要,安装elasticsearch和可视化 kibana

使用


创建docker-compose.yml

docker-compose.yml文件

  1. version: '3.1'
  2. services:
  3. elasticsearch:
  4. image: elasticsearch:7.13.3
  5. container_name: elasticsearch
  6. privileged: true
  7. environment:
  8. - "cluster.name=elasticsearch" #设置集群名称为elasticsearch
  9. - "discovery.type=single-node" #以单一节点模式启动
  10. - "ES_JAVA_OPTS=-Xms512m -Xmx1096m" #设置使用jvm内存大小
  11. - bootstrap.memory_lock=true
  12. volumes:
  13. - ./es/plugins:/home/searchengine/plugins #插件文件挂载
  14. - ./es/data:/home/searchengine/data:rw #数据文件挂载
  15. - ./es/logs:/home/searchengine/logs:rw
  16. ports:
  17. - 9200:9200
  18. - 9300:9300
  19. deploy:
  20. resources:
  21. limits:
  22. cpus: "2"
  23. memory: 1000M
  24. reservations:
  25. memory: 200M
  26. kibana:
  27. image: kibana:7.13.3
  28. container_name: kibana
  29. depends_on:
  30. - elasticsearch #kibana在elasticsearch启动之后再启动
  31. environment:
  32. ELASTICSEARCH_HOSTS: http://elasticsearch:9200 #设置访问elasticsearch的地址
  33. I18N_LOCALE: zh-CN
  34. ports:
  35. - 5601:5601

步骤

步骤一

创建文件夹:

mkdir /home/searchengine/plugins
mkdir /home/searchengine/data
mkdir /home/searchengine/logs


步骤二

进入/home/searchengine目录中,创建docker-compose.yml文件,然后将上述的yml内容拷贝进去。

cd /home/searchengine

vi docker-compose.yml

1651826466(1).png
1651826494(1).png

步骤三

启动程序

# 后台启动
docker-compose up -d

# 停止
docker-compose down

END


搞定~