目 录CONTENT

文章目录

elasticsearch

xlong
2024-03-27 / 0 评论 / 0 点赞 / 17 阅读 / 4074 字 / 正在检测是否收录...

elasticsearch

 -X :指定http的请求方式,有HEAD、GET、POST、PUT、DELETE
 -d :指定要传输的数据
 -H :指定http的请求头信息

es修改密码

es 7.x

curl -H "Content-Type:application/json" -XPOST -u elastic:124578 'http://192.168.1.100:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'

查询所有索引

curl -u 用户名:密码 http://ip:port/_cat/indices

#  查看单个索引信息
curl -XGET -u 用户名:密码  http://ip:port/索引名?pretty

查询数据

curl -H "Content-Type:application/json" -u 用户名:密码 -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"match_all":{}} }'

删除数据不删除索引

curl -u 用户名:密码  -XPOST "http://10.104.146.253:9200/trading_sessions/_delete_by_query?pretty=true" -H 'Content-Type: application/json'  -d '{"query":{"match_all":{}} }'

删除所有数据,含索引结构

curl -X DELETE http://ip:port/索引名

查看集群是否正常

curl -u 用户名:密码 http://ip:port/_cat/health?v

yellow状态转green

#查看索引状态: 
curl -X GET "127.0.0.1:9200/_cluster/health?pretty"

# 单点部署的 Elasticsearch,默认分片的副本数为 1,而相同的分片不能在同一个节点上,所以就出现上面 unsigned shards 的问题。解决方法如下:
curl -X PUT "127.0.0.1:9200/_settings" -H 'Content-Type: application/json' -d'{"number_of_replicas":0}'

# 返回
{"acknowledged":true}

es配置

    xpack.security.enabled: false   #是否开启密码认证
    xpack.security.transport.ssl.enabled: false
    xpack.security.transport.ssl.verification_mode: certificate
    xpack.security.transport.ssl.keystore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12
    xpack.security.transport.ssl.truststore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12
    xpack.security.http.ssl.enabled: false  # 是否开启https访问
    xpack.security.http.ssl.truststore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12
    xpack.security.http.ssl.keystore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12

错误

Authentication of [elastic] was terminated by realm [reserved]

原因:elasticsearch密码错误,修改密码

修改以下配置,关闭密码登录。

    xpack.security.enabled: false   #是否开启密码认证
    xpack.security.transport.ssl.enabled: false

Content-Type header [application/x-www-form-urlencoded] is not supporte

添加json请求头

-H 'Content-Type: application/json'

java.net.UnknownHostException: geoip.elastic.co

修改配置:
ingest.geoip.downloader.enabled: false

0

评论区