我试图通过虚拟机中的Kibana
包含文件(Elasticsearch
)在docker-compose
中运行.yml
,但是我无法连接到{{1 }},但在尝试连接失败时收到的消息如下:
Kibana
如果您注意到,docker可以连接到docker-compose文件中提到的其他服务,其中前两行显示了[34mspark-master |[0m 18/09/25 17:58:29 INFO master.Master: Registering worker 172.18.0.8:8881 with 2 cores, 1024.0 MB RAM
[36;1mspark-worker |[0m 18/09/25 17:58:29 INFO worker.Worker: Successfully registered with master spark://spark-master:7077
[35mkibana |[0m {"type":"log","@timestamp":"2018-09-25T17:58:31Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}
[35mkibana |[0m {"type":"log","@timestamp":"2018-09-25T17:58:31Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
[35mkibana |[0m {"type":"log","@timestamp":"2018-09-25T17:58:33Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}
[35mkibana |[0m {"type":"log","@timestamp":"2018-09-25T17:58:33Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
[35mkibana |[0m {"type":"log","@timestamp":"2018-09-25T17:58:36Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}
[35mkibana |[0m {"type":"log","@timestamp":"2018-09-25T17:58:36Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
[35mkibana |[0m {"type":"log","@timestamp":"2018-09-25T17:58:38Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}
[35mkibana |[0m {"type":"log","@timestamp":"2018-09-25T17:58:38Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
[35mkibana |[0m {"type":"log","@timestamp":"2018-09-25T17:58:41Z","tags":["status","plugin:elasticsearch@6.2.2","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Unable to connect to Elasticsearch at http://elasticsearch:9200."}
[33melasticsearch |[0m 2018-09-25 17:58:47,078 INFO exited: create-index (exit status 0; expected)
。在docker-compose文件中调用kibana的命令如下:
spark-master
如果我做 elasticsearch:
build: docker-elasticsearch/
container_name: elasticsearch
hostname: elasticsearch
environment:
- Des.network.host=0.0.0.0
- cluster.name = "elasticsearch"
expose:
- 9200
ports:
- "9200:9200"
kibana:
build: kibana/
container_name: kibana
hostname: kibana
environment:
- SERVER_NAME="kibana"
- SERVER_HOST="0"
- ELASTICSEARCH_URL=http://elasticsearch:9200
ports:
- "5601:5601"
links:
- elasticsearch
depends_on:
- elasticsearch
,它会给我以下信息:
docker-compose ps
在此之前,我在Google上广泛搜索了此问题,并尝试了人们针对该问题的各种建议,包括修改 Name Command State Ports
--------------------------------------------------------------------------------
elasticsearch /usr/local/bin/docker-entr Up 0.0.0.0:9200->9200/tcp,
... 9300/tcp
kibana /bin/bash /usr/local/bin/k Up 0.0.0.0:5601->5601/tcp
,例如将elasticsearch_url
更改为{{1} },将http
更改为https
以及这两个建议的组合/排列,但是我无法使用任何建议连接到localhost
。还建议在某处检查为我的虚拟机分配的内存,该内存为我的VM等于elasticsearch
的值suggested。
使用@Ivthillo给出的命令时,似乎Kibana已连接,如终端上的以下消息所示:
Kibana
但是,当我尝试通过泊坞窗(例如Elasticsearch
)在新终端中运行其他服务时(由于上述消息kibana_1 | {"type":"log","@timestamp":"2018-09-26T13:43:05Z","tags":["info","monitoring-ui","kibana-monitoring"],"pid":1,"message":"Starting all Kibana monitoring collectors"}
kibana_1 | {"type":"log","@timestamp":"2018-09-26T13:43:06Z","tags":["license","info","xpack"],"pid":1,"message":"Imported license information from Elasticsearch for the [monitoring] cluster: mode: basic | status: active"}
kibana_1 | {"type":"log","@timestamp":"2018-09-26T13:43:12Z","tags":["listening","info"],"pid":1,"message":"Server running at http://0:5601"}
仍然停留在前进的位置),我收到一条错误消息,指出容器未按以下方式运行:
sudo docker exec -i
答案 0 :(得分:1)
我有类似的设置。我通过管理容器网络解决了这个问题。请尝试以下操作:
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.12
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
ports:
- 9200:9200
kibana:
image: kibana:5.6.12
container_name: kibana
environment:
ELASTICSEARCH_URL: http://elasticsearch1:9200
ports:
- 5601:5601
depends_on:
- elasticsearch
让我知道这是否有帮助。
答案 1 :(得分:1)
您也许可以从最基本的docker-compose开始,因为您正在构建自己的映像,这使得调试起来很困难。
在下面的示例中,我们在同一个docker网络中启动了ES和Kibana,这意味着它们可以使用其名称相互访问。与使用不推荐使用的--link
相比,联网是使容器进行通信的更好方法。
version: '3.3'
services:
kibana:
image: docker.elastic.co/kibana/kibana:6.3.2
environment:
SERVER_NAME: kibana.example.org
ELASTICSEARCH_URL: http://elasticsearch:9200
ports:
- "5601:5601"
depends_on:
- elasticsearch
networks:
- my-network
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
container_name: elasticsearch
networks:
- my-network
networks:
my-network:
证明连接正常。我正在访问kibana容器并ping和curl
到我的elasticsearch容器中:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7e2632aff839 docker.elastic.co/kibana/kibana:6.3.2 "/usr/local/bin/kiba…" 2 minutes ago Up 2 minutes 0.0.0.0:5601->5601/tcp es_kibana_1
03f2d03a87b4 docker.elastic.co/elasticsearch/elasticsearch:6.3.2 "/usr/local/bin/dock…" 2 minutes ago Up 2 minutes 9200/tcp, 9300/tcp elasticsearch
lorenzvanthillo@MacBook-Pro ~/ES docker exec -it 7e2632aff839 bash
bash-4.2$ ping elasticsearch
PING elasticsearch (172.22.0.2) 56(84) bytes of data.
64 bytes from elasticsearch.es_my-network (172.22.0.2): icmp_seq=1 ttl=64 time=0.554 ms
64 bytes from elasticsearch.es_my-network (172.22.0.2): icmp_seq=2 ttl=64 time=0.075 ms
bash-4.2$ curl http://elasticsearch:9200
{
"name" : "f9AfdJp",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "YQkmS6gtTmqcCs0HgWX5bg",
"version" : {
"number" : "6.3.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "053779d",
"build_date" : "2018-07-20T05:20:23.451332Z",
"build_snapshot" : false,
"lucene_version" : "7.3.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}