主頁 > 資料庫 > Elasticsearch 模塊 - Shard Allocation 機制

Elasticsearch 模塊 - Shard Allocation 機制

2021-03-08 06:44:23 資料庫

原文

1. 背景

shard allocation 意思是分片分配, 是一個將分片分配到節點的程序; 可能發生該操作的程序包括:

  • 初始恢復(initial recovery)
  • 副本分配(replica allocation)
  • 重新平衡(rebalance)
  • 節點的新增和洗掉

來源

分片的分配操作, 是由 master 角色的節點來決定什么時候移動分片, 以及移動到哪個節點上, 以達到集群的均衡;

說明

本文基于 Elasticsearch 7.4.0 版本

2. 機制分析

2.1. Allocation 觸發條件

  • 新增或洗掉 index 索引
  • node 節點的新增或洗掉
  • 執行 reroute 命令
  • 修改 replica 副本數量
  • 集群重啟

具體對應原始碼解釋:來源

序號 呼叫函式 說明
1 AllocationService.applyStartedShards Shard 啟動狀態修改
2 AllocationService.applyFailedShards Shard 失效狀態修改
3 AllocationService.deassociateDeadNodes Node 節點離開集群
4 AllocationService.reroute(AllocationCommands) 執行 relocation 命令
5 TransportClusterUpdateSettingsAction.masterOperation 集群配置修改操作
6 MetaDataCreateIndexService.onlyCreateIndex 創建新索引 index 請求
7 MetaDataDeleteIndexService.deleteIndexs 洗掉索引 index 操作
8 MetaDataIndexStateService.closeIndex 關閉 index 操作
9 MetaDataIndexStateService.openIndex 打開 index操作
10 NodeJoinController.JoinTaskExecutor 通過集群發現的節點加入集群
11 GatewayService.GatewayRecoveryListener 通過 GatewayRecovery 恢復的節點加入集群
12 LocalAllocateDangledIndices.submitStateUpdateTask 恢復磁盤記憶體而在 MateDate 內不存在的 index
13 RestoreService.restoreSnapshot 從 snapshot 中恢復的 index

2.2. Rebalance 的觸發條件

rebalance 之前會經過 2.3.2 中介紹的所有策略里實作的 canRebalance 方法, 全部通過后才會執行下面的 Rebalance 程序;

Rebalance 程序是通過呼叫 balanceByWeights() 方法, 計算 shard 所在的每個 node 的 weight 值,

\[weightShard = node.numShards() + numAdditionalShards - balancer.avgShardsPerNode() \\ weightIndex = node.numShards(index) + numAdditionalShards - balancer.avgShardsPerNode(index) \\ weight = theta0 * weightShard + theta1 * weightIndex \\ \]

其中:

  • numAdditionalShards 一般為 0, 呼叫 weightShardAdded, weightShardRemoved 方法時分別取值為 1-1;
  • theta0 = cluster.routing.allocation.balance.shard 系統動態配置項, 默認值為 0.45f;
  • theta1 = cluster.routing.allocation.balance.index 系統動態配置項, 默認值為 0.55f;

權重計算公式

原始碼如下:

private static class WeightFunction {
    private final float indexBalance;
    private final float shardBalance;
    private final float theta0;
    private final float theta1;
    WeightFunction(float indexBalance, float shardBalance) {
        float sum = indexBalance + shardBalance;
        if (sum <= 0.0f) {
            throw new IllegalArgumentException("Balance factors must sum to a value > 0 but was: " + sum);
        }
        theta0 = shardBalance / sum;
        theta1 = indexBalance / sum;
        this.indexBalance = indexBalance;
        this.shardBalance = shardBalance;
    }
    float weight(Balancer balancer, ModelNode node, String index) {
        final float weightShard = node.numShards() - balancer.avgShardsPerNode();
        final float weightIndex = node.numShards(index) - balancer.avgShardsPerNode(index);
        return theta0 * weightShard + theta1 * weightIndex;
    }
}

2.3. 原始碼分析

分片分配就是把一個分片分配到集群中某個節點的程序, 其中分配決策包含了兩個方面:

  • 哪些分片應該分配到哪些節點上
  • 哪個分片作為主分片, 哪個作為副本分片

Elasticsearch 主要通過兩個基礎組件來完成分片分配這個程序的: allocatordeciders;

  • allocator 尋找最優的節點來分配分片;
  • deciders 負責判斷并決定是否要進行分配;
  1. 新建的索引

? allocator 負責找出擁有分片數量最少的節點串列, 按分片數量遞增排序, 分片數量較少的會被優先選擇; 對于新建索引, allocator 的目標是以更為均衡的方式把新索引的分片分配到集群的節點中;

? deciders 依次遍歷 allocator 給出的節點串列, 判斷是否要把分片分配給該節點, 比如是否滿足分配過濾規則, 分片是否將超出節點磁盤容量閾值等等;

  1. 已有的索引

? allocator 對于主分片, 只允許把主分片指定在已經擁有該分片完整資料的節點上; 對于副本分片, 則是先判斷其他節點上是否已有該分片的資料的拷貝, 如果有這樣的節點, allocator 則優先把分片分配到這其中一個節點上;

2.3.1. Allocator

Allocator

  • PrimaryShardAllocator 找到擁有某 Shard 最新資料(主分片)的節點;
  • ReplicaShardAllocator 找到磁盤上擁有這個 Shard 資料(副本分片)的節點;
  • BalancedShardsAllocator 找到擁有最少 Shard 個數的節點;
public class BalancedShardsAllocator implements ShardsAllocator {
    public static final Setting<Float> INDEX_BALANCE_FACTOR_SETTING = Setting.floatSetting("cluster.routing.allocation.balance.index", 0.55f, 0.0f, Property.Dynamic, Property.NodeScope);
    public static final Setting<Float> SHARD_BALANCE_FACTOR_SETTING = Setting.floatSetting("cluster.routing.allocation.balance.shard", 0.45f, 0.0f, Property.Dynamic, Property.NodeScope);
    public static final Setting<Float> THRESHOLD_SETTING = Setting.floatSetting("cluster.routing.allocation.balance.threshold", 1.0f, 0.0f, Property.Dynamic, Property.NodeScope);

    private volatile WeightFunction weightFunction;
    private volatile float threshold;
}

2.3.2. Deciders

Deciders 決策期基礎組件的抽象類為 AllocationDecider:

public abstract class AllocationDecider {
    public Decision canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) {
        return Decision.ALWAYS;
    }
    public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
        return Decision.ALWAYS;
    }
    public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
        return Decision.ALWAYS;
    }
    public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocation) {
        return Decision.ALWAYS;
    }
    public Decision canAllocate(IndexMetadata indexMetadata, RoutingNode node, RoutingAllocation allocation) {
        return Decision.ALWAYS;
    }
    public Decision canAllocate(RoutingNode node, RoutingAllocation allocation) {
        return Decision.ALWAYS;
    }
    public Decision shouldAutoExpandToNode(IndexMetadata indexMetadata, DiscoveryNode node, RoutingAllocation allocation) {
        return Decision.ALWAYS;
    }
    public Decision canRebalance(RoutingAllocation allocation) {
        return Decision.ALWAYS;
    }
}

ES 7.4.0 中的 Decider 決策器包括以下所示, 他們均實作上面的 AllocationDecider 抽象類, 并重寫 canRebalance, canAllocate, canRemain, canForceAllocatePrimary 等方法;

AllocationDecider

決策器比較多, 大致分類如下, 并列舉決策器對應的配置項:

2.3.2.1. 負載均衡類
  • SameShardAllocationDecider: 避免主副分片分配到同一個節點;

  • AwarenessAllocationDecider: 感知分配器, 感知服務器, 機架等, 盡量分散存盤 Shard;

    對應的配置引數有:

    cluster.routing.allocation.awareness.attributes: rack_id

    cluster.routing.allocation.awareness.attributes: zone

  • ShardsLimitAllocationDecider: 同一個節點上允許存在同一個 indexshard 數目;

    index.routing.allocation.total_shards_per_node: 表示該索引每個節點上允許最多的 shard 數量; 默認值=-1, 表示無限制;

    cluster.routing.allocation.total_shards_per_node: cluster 級別, 表示集群范圍內每個節點上允許最多的 shard 數量, 默認值=-1, 表示無限制;

    index 級別會覆寫 cluster 級別;

2.3.2.2. 并發控制類
  • ThrottlingAllocationDecider: recovery 階段的限速配置, 避免過多的 recovering allocation 導致該節點的負載過高;

    cluster.routing.allocation.node_initial_primaries_recoveries: 當前節點在進行主分片恢復時的數量, 默認值=4;

    cluster.routing.allocation.node_concurrent_incoming_recoveries: 默認值=2, 通常是其他節點上的副本 shard 恢復到該節點上;

    cluster.routing.allocation.node_concurrent_outgoing_recoveries: 默認值=2, 通常是當前節點上的主分片 shard 恢復副本分片到其他節點上;

    cluster.routing.allocation.node_concurrent_recoveries: 統一配置上面兩個配置項;

  • ConcurrentRebalanceAllocationDecider: rebalace 并發控制, 表示集群同時允許進行 rebalance 操作的并發數量;

    cluster.routing.allocation.cluster_concurrent_rebalance, 默認值=2

    通過檢查 RoutingNodes 類中維護的 reloadingShard 計數器, 看是否超過配置的并發數;

  • DiskThresholdDecider: 根據節點的磁盤剩余量來決定是否分配到該節點上;

    cluster.routing.allocation.disk.threshold_enabled, 默認值=true;

    cluster.routing.allocation.disk.watermark.low: 默認值=85%, 達到這個值后, 新索引的分片不會分配到該節點上;

    cluster.routing.allocation.disk.watermark.high: 默認值=90%, 達到這個值后, 會觸發已分配到該節點上的 Shardrebalance 到其他節點上去;

2.3.2.3. 條件限制類
  • RebalanceOnlyWhenActiveAllocationDecider: 所有 Shard 都處于 active 狀態下才可以執行 rebalance 操作;

  • FilterAllocationDecider: 通過介面動態設定的過濾器; cluster 級別會覆寫 index 級別;

    index.routing.allocation.require.{attribute}
    index.routing.allocation.include.{attribute}
    index.routing.allocation.exclude.{attribute}
    cluster.routing.allocation.require.{attribute}
    cluster.routing.allocation.include.{attribute}
    cluster.routing.allocation.exclude.{attribute}

    • require 表示必須滿足, include 表示可以分配到指定節點, exclude 表示不允許分配到指定節點;
    • {attribute} 還有 ES 內置的幾個選擇, _name, _ip, _host;
  • ReplicaAfterPrimaryActiveAllocationDecider: 保證只在主分片分配完成后(active 狀態)才開始分配副本分片;

  • ClusterRebalanceAllocationDecider: 通過集群中 activeshard 狀態來決定是否可以執行 rebalance;

    cluster.routing.allocation.allow_rebalance

    indices_all_active(默認): 當集群所有的節點分配完成, 才可以執行 rebalance 操作;
    indices_primaries_active: 只要所有主分片分配完成, 才可以執行 rebalance 操作;
    always: 任何情況下都允許 rebalance 操作;

  • MaxRetryAllocationDecider: 防止 shard 在失敗次數達到上限后繼續分配;

    index.allocation.max_retries: 設定分配的最大失敗重試次數, 默認值=5;

2.3.2.4. 其他決策類
  • EnableAllocationDecider: 設定允許分配的分片型別; index 級別配置會覆寫 cluster 級別配置;

    all(默認): 允許所有型別的分片;

    primaries: 僅允許主分片;

    new_primaries: 僅允許新建索引的主分片;

    none: 禁止分片分配操作;

  • NodeVersionAllocationDecider: 檢查分片所在 Node 的版本是否高于目標 Node 的 ES 版本;

  • SnapshotInProgressAllocationDecider: 決定 snapshot 期間是否允許 allocation, 因為 snapshot 只會發生在主分片上, 所以該配置只會限制主分片的 allocation;

    cluster.routing.allocation.snapshot.relocation_enabled

接下來介紹一下在 Elasticsearch 中涉及到 AllocationRebalance 的相關配置項;

3. cluster-level 配置

3.1. Shard allocation 配置

控制分片的分配和恢復;

配置 默認值 說明
cluster.routing.allocation.enable all 啟用或禁用針對特定型別分片的分配;
1. all: 允許分配所有型別的分片;
2. primaries: 只允許分配主分片(primary shard);
3. new_primaries: 只允許分配新索引的主分片(primary shard);
4. none: 禁用分片分配;
該設定不會影響重啟節點時本地主分片的恢復;
cluster.routing.allocation.node_concurrent_incoming_recoveries 2 一個節點允許并發的傳入分片(incoming shard)數量
cluster.routing.allocation.node_concurrent_outgoing_recoveries 2 一個節點允許并發的傳出分片(incoming shard)數量
cluster.routing.allocation.node_concurrent_recoveries 上面兩者的合并配置
cluster.routing.allocation.node_initial_primaries_recoveries 4 單個節點上同時初始化的主分片數量
cluster.routing.allocation.same_shard.host false 是否執行檢查, 以防止基于host namehost address, 在單個主機上分配同一分片的多個實體; 該設定僅用于在同一臺計算機上啟動多個節點的情況;

3.2. Shard rebalancing 配置

控制集群之間的分片平衡;

配置 默認值 說明
cluster.routing.rebalance.enable all 啟用或禁用針對特定型別分片的rebalancing;
1. all: 允許rebalancing所有型別的分片;
2. primaries: 只允許rebalancing主分片;
3. replicas: 只允許rebalancing副本分片;
4. none: 禁用rebalancing;
cluster.routing.allocation.allow_rebalance indices_all_active 指定何時允許執行rebalancing;
1. always: 總是允許;
2. indices_primaries_active: 當集群中所有主分片已分配時才允許rebalancing;
3. indices_all_active: 當集群中所有分片(包括主分片和副本分片)都已分配時才允許rebalancing;
cluster.routing.allocation.cluster_concurrent_rebalance 2 指定整個集群中允許同時在節點間移動的分片數量; 該配置僅控制由于集群不平衡引起的并發分片分配數量, 對分配過濾(allocation filtering)或強制感知(forced awareness)的分片分配不做限制;

3.3. 分片平衡啟發式

以下配置用于決定每個分片的存放位置; 當rebalancing操作不再使任何節點的權重超過balance.threshold時, 集群即達到平衡;

配置 默認值 說明
cluster.routing.allocation.balance.shard 0.45f 定義節點上分配的分片總數的權重因子; 提升該值會導致集群中所有節點趨向于分片數量相等;
cluster.routing.allocation.balance.index 0.55f 定義節點上分配的每個索引的分片數量的權重因子; 提升該值會導致集群中所有節點上每個索引的分片數量趨向于相等;
cluster.routing.allocation.balance.threshold 1.0f 定義應當執行操作的最小優化值(非負浮點數); 提升該值會導致集群在優化分片平衡方面不太積極;

4. Index-level 配置

以下配置控制每個索引中的分片分配;

4.1. index-level 分片分配過濾(來源)

配置需要分兩步:

  1. 在每個 Elasticsearch 節點的 elasticsearch.yml 組態檔中添加自定義節點屬性, 比如以 small, medium, big區分節點型別, 則組態檔中可添加:
node.attr.size: medium

或者在啟動 Elasticsearch 服務時, 在命令列里添加 ./bin/elasticsearch -Enode.attr.size=medium;

  1. 在新建索引的 mapping 時, 添加index.routing.allocation.include/exclude/require.size: medium 的過濾配置即可;
PUT <index_name>/_settings
{
  "index.routing.allocation.include.size": "medium"
}

可以配置多個自定義節點屬性, 并且必須同時滿足索引里配置的多個過濾條件;

  • index.routing.allocation.include.{attribute}: {values}
  • index.routing.allocation.require.{attribute}: {values}
  • index.routing.allocation.exclude.{attribute}: {values}

其中 {attribute} 可以是上面提到的自定義節點屬性, ES 自己也有一些內置的節點屬性:

attribute 說明
_name 通過節點名稱進行匹配
_host_ip 通過節點 IP 地址進行匹配
_publish_ip 通過節點的發布 IP 地址進行匹配
_ip 通過 _host_ip_publish_ip 進行匹配
_host 通過節點的hostname進行匹配
_id 通過節點的 id 進行匹配

其中 {values} 可以是單個值, 也可以是逗號分隔的多個值, 也可以使用通配符 * 進行模糊匹配;

4.2. 設定延遲分配, 當節點離開時(來源)

當某個節點由于突發原因, 比如網路中斷, 人為操作重啟等, 需要暫時離開集群時, 集群會立刻新建副本分片以替換丟失的副本, 然后在剩余的所有節點之間進行rebalancing, 這樣導致在短時間內該突發節點又恢復過來后, 原先的副本就無法再使用, 集群會將剛才新建的副本分片再拷貝回到該節點上; 這樣就會造成不必要的資源浪費, 以及節點分片rebalancing帶來的波動;

可以使用 index.unassigned.node_left.delayed_timeout 動態設定來延遲由于節點離開而導致未分配的副本分片的分配問題; 該配置默認值 1m;

PUT _all/_settings
{
  "settings": {
    "index.unassigned.node_left.delayed_timeout": "5m"
  }
}

修改成以上配置后, 如果在 5m 內, 該節點可以恢復重新加入集群, 則集群會自動恢復該節點的副本分片分配, 恢復速度很快;

注意

  1. 此設定不影響將副本分片升級為主分片;
  2. 此設定不影響之前未分配的副本分片;
  3. 在整個集群重新啟動后, 該延遲分配不會生效;

4.3. 索引恢復的優先級(來源)

索引分片恢復的優先級按照:

  • 可選的 index.priority 配置, 值越大優先級越高;
  • index 索引的創建日期, 越新的索引優先級越高;
  • index 索引的名稱;

4.4. 每個節點的分片總數(來源)

配置 默認值 說明
index.routing.allocation.total_shards_per_node unbounded(-1) 指定單個節點上最多分配的分片數量, 包括主分片和副本分片;(具體某個索引)
cluster.routing.allocation.total_shards_per_node unbounded(-1) 指定單個節點上最多分配的分片數量, 包括主分片和副本分片;(與索引無關, 全域設定)

這些配置是硬性配置, 可能會導致一些分片無法分配, 需要慎重配置;

5. 閱讀來源

  1. Shard allocation and cluster-level routing
  2. Elasticsearch底層系列之 Shard Allocation 機制
  3. ELASTICSEARCH ALLOCATION 分析
  4. Elasticsearch Shard Allocation 機制
  5. Elasticsearch Allocation&Rebalance

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/267347.html

標籤:其他

上一篇:[MySQL]開啟慢查詢日志以及未使用索引SQL日志

下一篇:抖音加速將腳踏進了美團、攜程腹地,哪些人能借勢風口賺到錢?

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • GPU虛擬機創建時間深度優化

    **?桔妹導讀:**GPU虛擬機實體創建速度慢是公有云面臨的普遍問題,由于通常情況下創建虛擬機屬于低頻操作而未引起業界的重視,實際生產中還是存在對GPU實體創建時間有苛刻要求的業務場景。本文將介紹滴滴云在解決該問題時的思路、方法、并展示最終的優化成果。 從公有云服務商那里購買過虛擬主機的資深用戶,一 ......

    uj5u.com 2020-09-10 06:09:13 more
  • 可編程網卡芯片在滴滴云網路的應用實踐

    **?桔妹導讀:**隨著云規模不斷擴大以及業務層面對延遲、帶寬的要求越來越高,采用DPDK 加速網路報文處理的方式在橫向縱向擴展都出現了局限性。可編程芯片成為業界熱點。本文主要講述了可編程網卡芯片在滴滴云網路中的應用實踐,遇到的問題、帶來的收益以及開源社區貢獻。 #1. 資料中心面臨的問題 隨著滴滴 ......

    uj5u.com 2020-09-10 06:10:21 more
  • 滴滴資料通道服務演進之路

    **?桔妹導讀:**滴滴資料通道引擎承載著全公司的資料同步,為下游實時和離線場景提供了必不可少的源資料。隨著任務量的不斷增加,資料通道的整體架構也隨之發生改變。本文介紹了滴滴資料通道的發展歷程,遇到的問題以及今后的規劃。 #1. 背景 資料,對于任何一家互聯網公司來說都是非常重要的資產,公司的大資料 ......

    uj5u.com 2020-09-10 06:11:05 more
  • 滴滴AI Labs斬獲國際機器翻譯大賽中譯英方向世界第三

    **桔妹導讀:**深耕人工智能領域,致力于探索AI讓出行更美好的滴滴AI Labs再次斬獲國際大獎,這次獲獎的專案是什么呢?一起來看看詳細報道吧! 近日,由國際計算語言學協會ACL(The Association for Computational Linguistics)舉辦的世界最具影響力的機器 ......

    uj5u.com 2020-09-10 06:11:29 more
  • MPP (Massively Parallel Processing)大規模并行處理

    1、什么是mpp? MPP (Massively Parallel Processing),即大規模并行處理,在資料庫非共享集群中,每個節點都有獨立的磁盤存盤系統和記憶體系統,業務資料根據資料庫模型和應用特點劃分到各個節點上,每臺資料節點通過專用網路或者商業通用網路互相連接,彼此協同計算,作為整體提供 ......

    uj5u.com 2020-09-10 06:11:41 more
  • 滴滴資料倉庫指標體系建設實踐

    **桔妹導讀:**指標體系是什么?如何使用OSM模型和AARRR模型搭建指標體系?如何統一流程、規范化、工具化管理指標體系?本文會對建設的方法論結合滴滴資料指標體系建設實踐進行解答分析。 #1. 什么是指標體系 ##1.1 指標體系定義 指標體系是將零散單點的具有相互聯系的指標,系統化的組織起來,通 ......

    uj5u.com 2020-09-10 06:12:52 more
  • 單表千萬行資料庫 LIKE 搜索優化手記

    我們經常在資料庫中使用 LIKE 運算子來完成對資料的模糊搜索,LIKE 運算子用于在 WHERE 子句中搜索列中的指定模式。 如果需要查找客戶表中所有姓氏是“張”的資料,可以使用下面的 SQL 陳述句: SELECT * FROM Customer WHERE Name LIKE '張%' 如果需要 ......

    uj5u.com 2020-09-10 06:13:25 more
  • 滴滴Ceph分布式存盤系統優化之鎖優化

    **桔妹導讀:**Ceph是國際知名的開源分布式存盤系統,在工業界和學術界都有著重要的影響。Ceph的架構和演算法設計發表在國際系統領域頂級會議OSDI、SOSP、SC等上。Ceph社區得到Red Hat、SUSE、Intel等大公司的大力支持。Ceph是國際云計算領域應用最廣泛的開源分布式存盤系統, ......

    uj5u.com 2020-09-10 06:14:51 more
  • es~通過ElasticsearchTemplate進行聚合~嵌套聚合

    之前寫過《es~通過ElasticsearchTemplate進行聚合操作》的文章,這一次主要寫一個嵌套的聚合,例如先對sex集合,再對desc聚合,最后再對age求和,共三層嵌套。 Aggregations的部分特性類似于SQL語言中的group by,avg,sum等函式,Aggregation ......

    uj5u.com 2020-09-10 06:14:59 more
  • 爬蟲日志監控 -- Elastc Stack(ELK)部署

    傻瓜式部署,只需替換IP與用戶 導讀: 現ELK四大組件分別為:Elasticsearch(核心)、logstash(處理)、filebeat(采集)、kibana(可視化) 下載均在https://www.elastic.co/cn/downloads/下tar包,各組件版本最好一致,配合fdm會 ......

    uj5u.com 2020-09-10 06:15:05 more
最新发布
  • day02-2-商鋪查詢快取

    功能02-商鋪查詢快取 3.商鋪詳情快取查詢 3.1什么是快取? 快取就是資料交換的緩沖區(稱作Cache),是存盤資料的臨時地方,一般讀寫性能較高。 快取的作用: 降低后端負載 提高讀寫效率,降低回應時間 快取的成本: 資料一致性成本 代碼維護成本 運維成本 3.2需求說明 如下,當我們點擊商店詳 ......

    uj5u.com 2023-04-20 08:33:24 more
  • MySQL中binlog備份腳本分享

    關于MySQL的二進制日志(binlog),我們都知道二進制日志(binlog)非常重要,尤其當你需要point to point災難恢復的時侯,所以我們要對其進行備份。關于二進制日志(binlog)的備份,可以基于flush logs方式先切換binlog,然后拷貝&壓縮到到遠程服務器或本地服務器 ......

    uj5u.com 2023-04-20 08:28:06 more
  • day02-短信登錄

    功能實作02 2.功能01-短信登錄 2.1基于Session實作登錄 2.1.1思路分析 2.1.2代碼實作 2.1.2.1發送短信驗證碼 發送短信驗證碼: 發送驗證碼的介面為:http://127.0.0.1:8080/api/user/code?phone=xxxxx<手機號> 請求方式:PO ......

    uj5u.com 2023-04-20 08:27:27 more
  • 快取與資料庫雙寫一致性幾種策略分析

    本文將對幾種快取與資料庫保證資料一致性的使用方式進行分析。為保證高并發性能,以下分析場景不考慮執行的原子性及加鎖等強一致性要求的場景,僅追求最終一致性。 ......

    uj5u.com 2023-04-20 08:26:48 more
  • sql陳述句優化

    問題查找及措施 問題查找 需要找到具體的代碼,對其進行一對一優化,而非一直把關注點放在服務器和sql平臺 降低簡化每個事務中處理的問題,盡量不要讓一個事務拖太長的時間 例如檔案上傳時,應將檔案上傳這一步放在事務外面 微軟建議 4.啟動sql定時執行計劃 怎么啟動sqlserver代理服務-百度經驗 ......

    uj5u.com 2023-04-20 08:26:35 more
  • 云時代,MySQL到ClickHouse資料同步產品對比推薦

    ClickHouse 在執行分析查詢時的速度優勢很好的彌補了MySQL的不足,但是對于很多開發者和DBA來說,如何將MySQL穩定、高效、簡單的同步到 ClickHouse 卻很困難。本文對比了 NineData、MaterializeMySQL(ClickHouse自帶)、Bifrost 三款產品... ......

    uj5u.com 2023-04-20 08:26:29 more
  • sql陳述句優化

    問題查找及措施 問題查找 需要找到具體的代碼,對其進行一對一優化,而非一直把關注點放在服務器和sql平臺 降低簡化每個事務中處理的問題,盡量不要讓一個事務拖太長的時間 例如檔案上傳時,應將檔案上傳這一步放在事務外面 微軟建議 4.啟動sql定時執行計劃 怎么啟動sqlserver代理服務-百度經驗 ......

    uj5u.com 2023-04-20 08:25:13 more
  • Redis 報”OutOfDirectMemoryError“(堆外記憶體溢位)

    Redis 報錯“OutOfDirectMemoryError(堆外記憶體溢位) ”問題如下: 一、報錯資訊: 使用 Redis 的業務介面 ,產生 OutOfDirectMemoryError(堆外記憶體溢位),如圖: 格式化后的報錯資訊: { "timestamp": "2023-04-17 22: ......

    uj5u.com 2023-04-20 08:24:54 more
  • day02-2-商鋪查詢快取

    功能02-商鋪查詢快取 3.商鋪詳情快取查詢 3.1什么是快取? 快取就是資料交換的緩沖區(稱作Cache),是存盤資料的臨時地方,一般讀寫性能較高。 快取的作用: 降低后端負載 提高讀寫效率,降低回應時間 快取的成本: 資料一致性成本 代碼維護成本 運維成本 3.2需求說明 如下,當我們點擊商店詳 ......

    uj5u.com 2023-04-20 08:24:03 more
  • day02-短信登錄

    功能實作02 2.功能01-短信登錄 2.1基于Session實作登錄 2.1.1思路分析 2.1.2代碼實作 2.1.2.1發送短信驗證碼 發送短信驗證碼: 發送驗證碼的介面為:http://127.0.0.1:8080/api/user/code?phone=xxxxx<手機號> 請求方式:PO ......

    uj5u.com 2023-04-20 08:23:11 more