Настройка привилегий для репликации между кластерами
Пользователю репликации между кластерами требуются различные привилегии кластера и индекса на удалённом и локальном кластерах. Используйте следующие запросы для создания отдельных ролей на локальном и удалённом кластерах, а затем создайте пользователя с необходимыми ролями.
Удаленный кластер
На удалённом кластере, содержащем индекс лидера, роли репликации между кластерами требуются привилегия кластера read_ccr, и привилегии monitor и read на индексе лидера.
Если запросы аутентифицированы с помощью ключ API, ключ API требует указанных выше привилегий на локальном кластере, а не на удалённом.
Если запросы выполняются от имени других пользователей, тогда у аутентифицирующего пользователя должна быть привилегия run_as на удалённом кластере.
Следующий запрос создаёт роль remote-replication на удалённом кластере:
resp = client.security.put_role(
name="remote-replication",
cluster=[
"read_ccr"
],
indices=[
{
"names": [
"leader-index-name"
],
"privileges": [
"monitor",
"read"
]
}
],
)
print(resp) const response = await client.security.putRole({
name: "remote-replication",
cluster: ["read_ccr"],
indices: [
{
names: ["leader-index-name"],
privileges: ["monitor", "read"],
},
],
});
console.log(response); POST /_security/role/remote-replication
{
"cluster": [
"read_ccr"
],
"indices": [
{
"names": [
"leader-index-name"
],
"privileges": [
"monitor",
"read"
]
}
]
} Локальный кластер
На локальном кластере, содержащем индекс последователя, роли remote-replication требуются привилегии кластера manage_ccr, а также привилегии monitor, read, write и manage_follow_index на индексе последователя.
Следующий запрос создаёт роль remote-replication на локальном кластере:
resp = client.security.put_role(
name="remote-replication",
cluster=[
"manage_ccr"
],
indices=[
{
"names": [
"follower-index-name"
],
"privileges": [
"monitor",
"read",
"write",
"manage_follow_index"
]
}
],
)
print(resp) const response = await client.security.putRole({
name: "remote-replication",
cluster: ["manage_ccr"],
indices: [
{
names: ["follower-index-name"],
privileges: ["monitor", "read", "write", "manage_follow_index"],
},
],
});
console.log(response); POST /_security/role/remote-replication
{
"cluster": [
"manage_ccr"
],
"indices": [
{
"names": [
"follower-index-name"
],
"privileges": [
"monitor",
"read",
"write",
"manage_follow_index"
]
}
]
} После создания роли remote-replication на каждом кластере используйте создание или обновление пользователей API, чтобы создать пользователя на локальном кластере и назначить роль remote-replication. Например, следующий запрос назначает роль remote-replication пользователю с именем cross-cluster-user:
resp = client.security.put_user(
username="cross-cluster-user",
password="l0ng-r4nd0m-p@ssw0rd",
roles=[
"remote-replication"
],
)
print(resp) const response = await client.security.putUser({
username: "cross-cluster-user",
password: "l0ng-r4nd0m-p@ssw0rd",
roles: ["remote-replication"],
});
console.log(response); POST /_security/user/cross-cluster-user
{
"password" : "l0ng-r4nd0m-p@ssw0rd",
"roles" : [ "remote-replication" ]
} Вам нужно создать этого пользователя только на локальном кластере.
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/_configure_privileges_for_cross_cluster_replication_2.html