Docker 安装 Elasticsearch 7.7.1 + Kibana

一、安装es

docker拉取es镜像

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.7.1

启动es

docker run -d --name=es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.7.1

安装ik分词插件

docker exec -it es /bin/bash
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.1/elasticsearch-analysis-ik-7.7.1.zip

修改es跨域访问配置

 vi config/elasticsearch.yml 

修改后的内容为:

cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"

# minimum_master_nodes need to be explicitly set when bound on a public IP
# set to 1 to allow single node clusters
# Details: https://github.com/elastic/elasticsearch/pull/17288
discovery.zen.minimum_master_nodes: 1

退出容器,重启es容器

exit
docker restart es

使用浏览器访问 http://localhost:9200 查看是否显示es版本等信息

二、安装Kibana

docker拉取es镜像

 docker pull docker.elastic.co/kibana/kibana:7.7.1

启动kibana容器

docker run -it -d -e ELASTICSEARCH_URL=http://172.17.0.2:9200 --name kibana -p 5601:5601 docker.elastic.co/kibana/kibana:7.7.1

修改kibana配置文件

docker exec -it kibana /bin/bash
vi config/kibana.yml 

修改配置文件内容为:

#
# ** THIS IS AN AUTO-GENERATED FILE **
#

# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://172.17.0.2:9200" ]
monitoring.ui.container.elasticsearch.enabled: true

elasticsearch.hosts 为es的容器地址,可以使用docker inspect命令查看

同样,退出容器重启服务
浏览器访问 http://localhost:5601,如果服务启动失败可以使用docker logs命令查看失败原因

你可能感兴趣的:(Docker,docker,elasticsearch,kibana)