本文介绍的是使用docker yaml
文件安装ElasticSearch
和kibana
先看看目录树结构:
当前目录位于/Users/liubo/docker
.
├── docker-compose
│ └── ek.yaml
├── es7.4
│ ├── config
│ │ ├── analysis
│ │ └── elasticsearch.yml
│ ├── data
│ │ └── nodes
│ ├── es74.env
└── kibana7.4
└── config
└── kibana.yml
1. 创建相关文件夹
mkdir -p docker-compose es7.4/config es7.4/data kibana7.4/config
2.编辑yaml
文件
vim docker-compose/ek.yaml
文件内容如下
注:/Users/liubo/docker
替换为你自己项目的路径即可。
version: "2.1"
services:
es01:
image: elasticsearch:7.4.2
container_name: es01
stdin_open: true
tty: true
privileged: true
restart: always
env_file:
- "/Users/liubo/docker/es7.4/es74.env"
volumes:
- "/Users/liubo/docker/es7.4/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
- "/Users/liubo/docker/es7.4/config/analysis/pro_synonym.txt:/usr/share/elasticsearch/config/analysis/pro_synonym.txt"
- "/Users/liubo/docker/es7.4/data:/usr/share/elasticsearch/data"
ports:
- "9200:9200"
- "9300:9300"
networks:
elk_network:
ipv4_address: 172.2.7.2
logging:
driver: "json-file"
options:
max-size: "1g"
kibana01:
image: kibana:7.4.2
container_name: kibana01
stdin_open: true
tty: true
privileged: true
restart: always
volumes:
- "/Users/liubo/docker/kibana7.4/config/kibana.yml:/usr/share/kibana/config/kibana.yml"
ports:
- "5601:5601"
networks:
elk_network:
ipv4_address: 172.2.7.3
logging:
driver: "json-file"
options:
max-size: "1g"
networks:
elk_network:
driver: bridge
ipam:
config:
- subnet: "172.2.7.0/24"
3.编辑elasticsearch.yml
文件
vim es7.4/config/elasticsearch.yml
输入内容
network.host: 0.0.0.0
http.port: 9200
4.标记kibana.yml
文件
vim kibana7.4/config/kibana.yml
kibana.yml
文件内容如下
#
# ** THIS IS AN AUTO-GENERATED FILE **
#
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://172.2.7.2:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
#en zh-CN
i18n.locale: "zh-CN"
5.写env
文件
vim es7.4/es74.env
env文件内容,内存需要大一点就自己改大一点
discovery.type=single-node
ES_JAVA_OPTS="-Xms512m -Xmx512m"
6.执行docker-compose
命令
docker-compose -f docker-compose/ek.yaml up -d
终端陆续显示以下内容,大致就成功了。
Pulling es01 (elasticsearch:7.4.2)...
7.4.2: Pulling from library/elasticsearch
Digest: sha256:543bf7a3d61781bad337d31e6cc5895f16b55aed4da48f40c346352420927f74
Status: Downloaded newer image for elasticsearch:7.4.2
Pulling kibana01 (kibana:7.4.2)...
7.4.2: Pulling from library/kibana
Digest: sha256:355f9c979dc9cdac3ff9a75a817b8b7660575e492bf7dbe796e705168f167efc
Status: Downloaded newer image for kibana:7.4.2
Creating es01 ...
Creating kibana01 ...
Creating kibana01 ... done
Creating es01 ... done
7.访问自己ElasticSearch
和kibana
即可
访问ElasticSearch:127.0.0.1:9200
elasticsearch访问Kibana:127.0.0.1:5601
kibana
网友评论