Cluster Admin Flashcards
How do you check the status of the nodes?
GET _cat/nodes?v
How do you check the status of indices?
GET _cat/indices/v
How do you see on which nodes the shards of an index is allocated?
GET _cat/shards/< index >?v
How does elastic determine in which nodes to put shards?
Elastic will make its best judment based on the settings of the index, unless you do allocation filtering.
How do you specify the number of replicas and shards of an index?
In the index settings:
PUTS < index > { settings: { number_of_replicas: X, number_of_shards: Y. } }
What’s a shortcut to modify only the index settings?
PUT < index >/_settings
How to override index routing allocation (filtering)?
IN the index settings:
# To exclude a node { "index.routing.allocation.exclude._name": "< node name >, ...." }
# To revert the exclusion: { "index.routing.allocation.exclude._name": null }
TODO: Check the api doc to other variables and use cases.
What are some fail safe measurement elastic has in place for shard allocation?
Elastic will only reallocate the shards if the index will remain in a green state.
How to do cluster routing allocation?
PUT _cluster/settings
{
“transient”: {
“cluster.routing.allocation.exclude._name”: “< node name >, …”
What is transient and persistent cluster settings?
Transient won’t survive a cluster restart.
What is routing allocation in elastic and what are some of the use cases?
Allows you to manually create rules that dictate where shards are allocated.
A common use case is taking a node down from the cluster, so you can filter that single node, wait for the cluster to rebalance and then shut it down.
How do you see the node attributes?
GET _cat/nodeattrs?v
What is cluster routing allocation awareness and what are some of the use cases?
Allows to create some allocation rules for where to put primaries/replicas.
A tipical use case is avoiding putting all data into a single zone. So you can create “zone” custom attribute and use that in the allocation.
What are the 2 ways to setup rounting allocation affinity?
Either put in the config.yml or use the API.
How do you setup cluster routing awareness?
PUT _cluster/settings { "persistent": { "cluster.routing.allocation.awareness.attributes": "< attr name >" }
What is force awareness and what is it used for and how do you set it up?
In a situation where you might not have enough space to re-allocate of the shards when a whole zone goes down, you might want to prevent those shards being re-allocated in case a whole zone goes down.
PUT _cluster/settings { "persistent": { "cluster.routing.allocation.awareness.force.< attr name >.values: " < list of all possible values for the attribute > " }
What is the cluster allocation API?
Explains why your cluster is allocated a certain way.
GET _cluster/allocation/explain
How do you setup filesystem based backup on elastic?
- Whitelist the repository where the backup is gonna be saved
In config/elasticsearch.yml:
path. repo: /home/elastic/snaphosts
- Make sure the directory exists
- Restart elastic
How do you create a Filesystem snapshot repository with the API?
PUT _snapshot/< repo name > { type: "fs", settings: { location: "/home/elastic/snapshots", }
PS: This doesn’t save the data, just creates a “repository”.
How do you create a backup of an index?
- With the repository previously created:
PUT _snapshot/< repo name>/< snapshot name >
{
indices: “< index name >”
}
How do I wait for an API call to finish for async calls?
Add “?wait_for_completion=true” to the call.
How do you restore a backup snapshot?
POST _snapshot/< repo name >/< snapshot name >/_restore
{
indices: “< the index to restore >”
}
How do you backup all indices that start with a certain pattern?
You can use wildcards in the index name for the snapshot API.
How do rename indices when restoring a backup?
Use the “rename_pattern” option with a regular expression.
{
rename_pattern: “(.+)”,
rename_replacement: “$1_restored”
}
How do you create a tiered architecture (hot/warm/cold) in elastic?
- Create a custom attribute named, for example “temp” in the config files.
- In the index settings, configure the routing allocation (index.routing.allocation.require.temp: “hot/warm”).
How do you configure a remote cluster to your cluster?
In the cluster settings:
PUT _cluster/settings { "persistent": { "cluster": { "remote": { "< cluster name >": { seeds: ["< ip >:9300"] }
Make sure to use the transport port (9300).
What protocol/port is used for search in between clusters?
The elastic “transport” protocol (port 9300).
How do you search on a remote cluster?
GET < remote name >: < index name >/_search