查询所有索引
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:密码