导读
由于需要,安装elasticsearch和可视化 kibana
使用
创建docker-compose.yml
docker-compose.yml文件
version: '3.1'
services:
elasticsearch:
image: elasticsearch:7.13.3
container_name: elasticsearch
privileged: true
environment:
- "cluster.name=elasticsearch" #设置集群名称为elasticsearch
- "discovery.type=single-node" #以单一节点模式启动
- "ES_JAVA_OPTS=-Xms512m -Xmx1096m" #设置使用jvm内存大小
- bootstrap.memory_lock=true
volumes:
- ./es/plugins:/home/searchengine/plugins #插件文件挂载
- ./es/data:/home/searchengine/data:rw #数据文件挂载
- ./es/logs:/home/searchengine/logs:rw
ports:
- 9200:9200
- 9300:9300
deploy:
resources:
limits:
cpus: "2"
memory: 1000M
reservations:
memory: 200M
kibana:
image: kibana:7.13.3
container_name: kibana
depends_on:
- elasticsearch #kibana在elasticsearch启动之后再启动
environment:
ELASTICSEARCH_HOSTS: http://elasticsearch:9200 #设置访问elasticsearch的地址
I18N_LOCALE: zh-CN
ports:
- 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
步骤三
启动程序
# 后台启动
docker-compose up -d
# 停止
docker-compose down
END
搞定~