docker安装启动elasticsearch利用kibana访问

2022-08-18 17:27:49 浏览数 (1)

关于在docker上部署使用elasticSearch

代码语言:javascript复制
$ docker search elasticSearch

拉取镜像
$ docker pull elasticsearch:7.5.1

运行
$ docker run -d -p 9200:9200 -p 9300:9300 -v /d/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -e ES_JAVA_POTS="-Xms128m -Xmx128m" -e "discovery.type=single-node" --name elastic_search elasticsearch:7.5.1

Elasticsearch 分web(9200)和tcp(9300)两种对外服务接口

代码语言:javascript复制
$ docker search kibana

拉取镜像
$ docker pull kibana:7.5.1

运行
$ docker run --name kibana -e ELASTICSEARCH_URL=http://127.0.0.1:9200 -p 5601:5601 -d kibana:7.5.1

检查log日志发现无法连接 http://elasticsearch:9200

代码语言:javascript复制
$ docker logs kibana

需要修改kibana的配置

代码语言:javascript复制
交互式进入容器
$ 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://elasticsearch:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
代码语言:javascript复制
查看docker给elasticsearch分配得网卡ip是多少
$ docker inspect 60956f10f2be
// 60956f10f2be 是 elasticsearch 的ip

"Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "d06b8029214afd83ec5da9385cdaf8da074b87994fe5245cae0392e1aa90d5e0",
                    "EndpointID": "61fc664e8b6c69f8b91bef78e9452bd305d17cd4a9c78c1700359aad37bbd2ef",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }

修改http://elasticsearch:9200http://172.17.0.2:9200

重启kibana

代码语言:javascript复制
$ docker restart kibana

访问:http://127.0.0.1:5601/

0 人点赞