ElasticSearch 7.8.x X-Pack 配置 -- 角色、用户创建

  • 创建角色 – read
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/role/readIndex -H 'Content-Type: application/json' -d '{  "run_as": [ "watcher_user" ],  "cluster": [ "monitor" ],  "indices": [    {      "names": [ "index*" ],      "privileges": [ "read" ]    }  ]}'
  • 创建用户 – readIndex
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/user/readIndex -H 'Content-Type: application/json' -d '{  "password" : "readIndex1234",  "roles" : [ "readIndex" ]}'
  • 创建角色 – write
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/role/writeIndex -H 'Content-Type: application/json' -d '{  "run_as": [ "watcher_user" ],  "cluster": [ "monitor" ],  "indices": [    {      "names": [ "index*" ],      "privileges": [ "write" ]    }  ]}'
  • 创建用户 – writeIndex
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/user/writeIndex -H 'Content-Type: application/json' -d '{  "password" : "writeIndex1234",  "roles" : [ "writeIndex" ]}'
  • 创建角色 – monitor
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/role/monitorIndex -H 'Content-Type: application/json' -d '{  "run_as": [ "watcher_user" ],  "cluster": [ "monitor" ],  "indices": [    {      "names": [ "index*" ],      "privileges": [ "monitor" ]    }  ]}'
  • 创建用户 – monitorIndex
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/user/monitorIndex -H 'Content-Type: application/json' -d '{  "password" : "monitorIndex1234",  "roles" : [ "monitorIndex" ]}'
  • 创建角色 – manage
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/role/manageIndex -H 'Content-Type: application/json' -d '{  "run_as": [ "watcher_user" ],  "cluster": [ "monitor" ],  "indices": [    {      "names": [ "index*" ],      "privileges": [ "manage" ]    }  ]}'
  • 创建用户 – manageIndex
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/user/manageIndex -H 'Content-Type: application/json' -d '{  "password" : "manageIndex1234",  "roles" : [ "manageIndex" ]}'
  • 创建角色 – create_index
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/role/createIndex -H 'Content-Type: application/json' -d '{  "run_as": [ "watcher_user" ],  "cluster": [ "monitor" ],  "indices": [    {      "names": [ "index*" ],      "privileges": [ "create_index" ]    }  ]}'
  • 创建用户 – create_index
curl -u abcd:abcd1234 -XPOST 10.10.200.84:9201/_security/user/createIndex -H 'Content-Type: application/json' -d '{  "password" : "createIndex1234",  "roles" : [ "createIndex" ]}'
  • 创建索引 – superadmin
curl -u abcd:abcd1234 -XPUT 10.10.200.84:9201/index4 -H 'Content-Type: application/json' -d '{  "settings": {    "index": {      "number_of_shards": 3,        "number_of_replicas": 2     }  }}'
  • 创建索引 – read 账户
curl -u readIndex:readIndex1234 -XPUT 10.10.200.84:9201/index5 -H 'Content-Type: application/json' -d '{  "settings": {    "index": {      "number_of_shards": 3,        "number_of_replicas": 2     }  }}'
{"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [readIndex]"}],"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [readIndex]"},"status":403}
  • 创建索引 – write 用户
curl -u writeIndex:writeIndex1234 -XPUT 10.10.200.84:9201/index5 -H 'Content-Type: application/json' -d '{  "settings": {    "index": {      "number_of_shards": 3,        "number_of_replicas": 2     }  }}'
{"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [writeIndex]"}],"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [writeIndex]"},"status":403}
  • 创建索引 – monitor 用户
curl -u monitorIndex:monitorIndex1234 -XPUT 10.10.200.84:9201/index5 -H 'Content-Type: application/json' -d '{  "settings": {    "index": {      "number_of_shards": 3,        "number_of_replicas": 2     }  }}'
{"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [monitorIndex]"}],"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [monitorIndex]"},"status":403}
  • 创建索引 – manage 用户
curl -u manageIndex:manageIndex1234 -XPUT 10.10.200.84:9201/index5 -H 'Content-Type: application/json' -d '{  "settings": {    "index": {      "number_of_shards": 3,        "number_of_replicas": 2     }  }}'
{"acknowledged":true,"shards_acknowledged":true,"index":"index5"}
curl -u manageIndex:manageIndex1234 -XPUT 10.10.200.84:9201/test1 -H 'Content-Type: application/json' -d '{  "settings": {    "index": {      "number_of_shards": 3,        "number_of_replicas": 2     }  }}'
{"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [manageIndex]"}],"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [manageIndex]"},"status":403}
  • 创建索引 – create_index 用户
curl -u createIndex:createIndex1234 -XPUT 10.10.200.84:9201/index6 -H 'Content-Type: application/json' -d '{  "settings": {    "index": {      "number_of_shards": 3,        "number_of_replicas": 2     }  }}'
{"acknowledged":true,"shards_acknowledged":true,"index":"index6"}
curl -u createIndex:createIndex1234 -XPUT 10.10.200.84:9201/test -H 'Content-Type: application/json' -d '{  "settings": {    "index": {      "number_of_shards": 3,        "number_of_replicas": 2     }  }}'
{"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [createIndex]"}],"type":"security_exception","reason":"action [indices:admin/create] is unauthorized for user [createIndex]"},"status":403}
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值