预上线
上线
监控流量,定期检查潜在问题(防范于未然,发现错误的使用方式,及时增加机器)
对索引进行优化(Index Lifecycle Management),检测是否存在不均衡而导致有部分节点过热
定期数据备份,滚动升级
下架前监控流量,实现 Stage Decommission
根据实际场景,选择合适的部署方式,选择合理的硬件配置
搜索类
日志 / 指标
部署要考虑,反亲和性(Anti-Affinity)
尽量将机器分散在不同的机架,例如,3 台 Master 节点必须分散在不同的机架上
善用 Shard Flitering 进行部署,实现冷热架构的部署
PUT _cluster/settings
{
"persistent": {
"action.auto_create_index": false
}
}
PUT _cluster/settings
{
"persistent": {
"action.auto_create_index": "monitoring-*,logstash-*"
}
}
3.1 Mapping
3.2 设置 Slowlogs,发现一些性能不好,甚至是错误的使用 Pattern
3.3 对重要的数据进行备份
https://www.elastic.co/guide/en/elasticsearch/reference/7.1/modules-snapshots.html
3.4 定期更新到新版本
ES 的版本格式是:X.Y.Z
Elasticsearch 可以使用上一个主版本的索引
Rolling Upgrade v.s Full Cluster Restart
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "primaries"
}
}
POST _flush/synced
# 移动一个分片从一个节点到另外一个节点
POST _cluster/reroute
{
"commands": [
{
"move": {
"index": "index_name",
"shard": 0,
"from_node": "node_name_1",
"to_node": "node_name_2"
}
}
]
}
使用场景:当你想移除一个节点,或者对一个机器进行维护。同时你又不希望导致集群的颜色变黄或者变红
# remove the nodes from cluster
PUT _cluster/settings
{
"transient": {
"cluster.routing.allocation.exclude._ip":"the_IP_of_your_node"
}
}
使用场景:控制 Allocation 和 Recovery 的速率
# change the number of moving shards to balance the cluster
PUT /_cluster/settings
{
"transient": {"cluster.routing.allocation.cluster_concurrent_rebalance":2}
}
# change the number of shards being recovered simultanceously per node
PUT _cluster/settings
{
"transient": {"cluster.routing.allocation.node_concurrent_recoveries":5}
}
# Change the recovery speed
PUT /_cluster/settings
{
"transient": {"indices.recovery.max_bytes_per_sec": "80mb"}
}
# Change the number of concurrent streams for a recovery on a single node
PUT _cluster/settings
{
"transient": {"indices.recovery.concurrent_streams":6}
}
使用场景:需要重启一个节点
通过 synced flush,可以在索引上放置一个 sync ID 。这样可以提供这些分词的 Recovery 的时间
# Force a synced flush
POST _flush/synced
使用场景:节点上出现了高内存占用。可以执行清除缓存的操作。这个操作会影响集群的性能,但是会避免你的集群出现 OOM 的问题
# Clear the cache on a node
POST _cache/clear
使用场景:当搜索的响应时间过长,看到有“reject”指标的增加,都可以适当增加该数值
# Change the sinze of the search queue
PUT _cluster/settings
{
"transient": {
"threadpool.search.queue_size":2000
}
}
使用场景:设置各类 Circuit Breaker,避免 OOM 的发生
#Adjust the circuit breakers
PUT _cluster/settings
{
"persistent": {
"indices.breaker.total.limit":"40%"
}
}
原文:https://www.cnblogs.com/wysxr/p/14630672.html