欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Elasticsearch

程序员文章站 2022-07-01 09:54:50
...

1 docker 安装 Elasticsearch

  https://www.elastic.co/guide/en/elasticsearch/reference/5.0/docker.html#docker-cli-run-prod-mode

docker pull docker.elastic.co/elasticsearch/elasticsearch:5.0.2
docker run -itd --name es -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.0.2

2 在终端里访问 REST API 时报错

https://blog.csdn.net/hellozhxy/article/details/86649667

在终端里访问 REST API 的时候

1
curl -XGET 'localhost:9200/_cat/health?v&pretty'

会报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "error": {
    "root_cause": [
      {
        "type": "security_exception",
        "reason": "missing authentication token for REST request [/_cat/health?v&pretty]",
        "header": {
          "WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
        }
      }
    ],
    "type": "security_exception",
    "reason": "missing authentication token for REST request [/_cat/health?v&pretty]",
    "header": {
      "WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
    }
  },
  "status": 401
}

解决办法是添加上账号密码就好了

1
curl --user elastic:changeme -XGET 'localhost:9200/_cat/health?v&pretty'

Elasticsearch服务器开发(第2版):http://note.youdao.com/noteshare?id=2ae6f3e10570a0b6bd1e7f8c0faa6a06

这个账号密码实际上是 X-Pack 这个插件附带的认证功能。X-Pack 是一个 Elastic Stack 的扩展,将安全,警报,监视,报告和图形功能包含在一个易于安装的软件包中。

3 查找elasticsearch.yml文件

find / | grep config/elasticsearch.yml