ES基本用法

本文介绍了如何使用curl命令查询ES的所有索引,指定索引的数据搜索,删除索引及其内容,以及如何设置访问权限,包括设置用户名密码并验证。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查询所有索引

curl '0.0.0.0:9200/_cat/indices?v'

查询索引下所有数据

  • 假设上一步查询到“fuck_index”索引
curl -XPOST http://0.0.0.0:9200/fuck_index/_search  -H 'Content-Type:application/json' -d'
{
  "query": {
    "match_all": {}
  }
}
'

删除索引(和索引下所有数据)

curl -XDELETE 10.107.118.64:9200/fuck_index*  -u elastic:密码

为ES访问设置用户名、密码

cd /usr/share/elasticsearch/config
vim elasticsearch.yml

修改如下:

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
cd /usr/share/elasticsearch/bin
elasticsearch-setup-passwords interactive

输出

elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]

输入y
重启ES服务

检验:curl 0.0.0.0:9200/_cat

带用户名密码访问:curl ‘0.0.0.0:9200/_cat/indices?v’ -u elastic:密码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值