admin管理员组

文章数量:1618705

docker安装es后无法访问

[root@localhost ~]# curl http://localhost:9200
curl: (56) Recv failure: Connection reset by peer

有人说是因为容器内监听的是本机地址127.0.0.1

[root@0adf1765ac08 elasticsearch]# netstat -tunpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:9200          0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:9300          0.0.0.0:*               LISTEN      -

修改监听地址,/usr/share/elasticsearch/config/elasticsearch.yml,地址改为0.0.0.0

[root@0adf1765ac08 elasticsearch]# netstat -tunpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:9200            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:9300            0.0.0.0:*               LISTEN      -

在宿主机访问可以了

[root@localhost ~]# curl http://localhost:9200
{
  "name" : "0adf1765ac08",
  "cluster_name" : "my-es",
  "cluster_uuid" : "MpKqrEKySnSdwux0m7AlEA",
  "version" : {
    "number" : "7.7.1",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "ad56dce891c901a492bb1ee393f12dfff473a423",
    "build_date" : "2020-05-28T16:30:01.040088Z",
    "build_snapshot" : false,
    "lucene_version" : "8.5.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

本文标签: 无法访问curlElasticsearchDockerReset