ES:账号、索引、ILM

发布于:2025-04-09 ⋅ 阅读:(121) ⋅ 点赞:(0)

目录

      • 笔记1:账号权限查看、查看账号、创建账号等
        • 查看所有用户
        • 查看特定用户
        • 验证权限
        • 修改用户权限
        • 删除用户
      • 笔记2:索引状态和内容的查看等
        • 查看所有索引
        • 查看特定索引内容
        • 查看索引映射
        • 查看索引设置
        • 查看索引统计信息
        • 查看ILM策略

笔记1:账号权限查看、查看账号、创建账号等

查看所有用户
curl -u elastic:elastic -X GET "http://172.17.0.3:9200/_security/user?pretty"
查看特定用户
curl -u elastic:elastic -X GET "http://172.17.0.3:9200/_security/user/{username}?pretty"
验证权限
curl -u elastic:elastic -X GET "http://172.17.0.3:9200/_security/user/{username}/_has_privileges?pretty" -H "Content-Type: application/json" -d'
{
  "cluster": ["monitor"],
  "index": [
    {
      "names": ["my_index"],
      "privileges": ["read", "write"]
    }
  ]
}'
修改用户权限
curl -u elastic:elastic -X POST "http://172.17.0.3:9200/_security/user/{username}?pretty" -H "Content-Type: application/json" -d'
{
  "password" : "new_password",
  "roles" : [ "role1", "role2" ],
  "full_name" : "John Doe",
  "email" : "john.doe@example.com",
  "metadata" : {
    "department" : "IT"
  },
  "enabled" : true
}'
删除用户
curl -u elastic:elastic -X DELETE "http://172.17.0.3:9200/_security/user/{username}?pretty"

笔记2:索引状态和内容的查看等

查看所有索引
curl -u elastic:elastic -X GET "http://172.17.0.3:9200/_cat/indices?v"
查看特定索引内容
curl -u elastic:elastic -X GET "http://172.17.0.3:9200/{index-name}/_search?pretty"
查看索引映射
curl -u elastic:elastic -X GET "http://172.17.0.3:9200/{index-name}/_mapping?pretty"
查看索引设置
curl -u elastic:elastic -X GET "http://172.17.0.3:9200/{index-name}/_settings?pretty"
查看索引统计信息
curl -u elastic:elastic -X GET "http://172.17.0.3:9200/{index-name}/_stats?pretty"
查看ILM策略
curl -u elastic:elastic -X GET "http://172.17.0.3:9200/_ilm/policy?pretty"

这些笔记总结了Elasticsearch中账号管理和索引管理的常用命令,方便快速参考和使用。


网站公告

今日签到

点亮在社区的每一天
去签到