12.3 保護 Elasticsearch 中的資料

Elasticsearch 叢集節點可供多種不同的用戶端存取,例如:

  • Sentinel:用以擷取和顯示「事件視覺化」儀表板中的事件資料。

  • 在 YARN NodeManager 節點中執行的 Spark 工作:用以執行從 Kafka 所接收事件的大量索引編製。(適用於 SSDM)

  • Collector Manager:用以對使用傳統儲存的 Sentinel 中的事件執行大量索引編製。

  • 其他外部用戶端:用以執行自訂作業,例如自訂分析。

Sentinel 針對 Elasticsearch 提供了名為 elasticsearch-security-plugin 的安全性外掛程式,用以驗證 Elasticsearch 及授與其存取權。

此外掛程式會根據用戶端的連線方式,使用 SAML 記號或白名單進行驗證:

  • 當用戶端連同要求傳送 SAML 記號時,此外掛程式會對 Sentinel 驗證伺服器驗證記號。驗證成功時,此外掛程式只會允許存取用戶端已獲授權的篩選事件。

    例如,「事件視覺化」儀表板 (用戶端) 只會顯示 Elasticsearch 中可供經過授權的使用者角色檢視的事件。

    如需角色和權限的相關資訊,請參閱 Sentinel 管理指南中的建立角色。

  • 當用戶端無法傳送 SAML 記號時,此外掛程式會檢查其合法用戶端的白名單。驗證成功時,此外掛程式會允許存取所有事件,而不加以篩選。

  • 當用戶端未傳送有效的 SAML 記號或未經白名單的允許時,此外掛程式會將其視為不合法的用戶端,而拒絕用戶端的存取。

本節提供安裝和設定 Elasticsearch 安全性外掛程式的相關資訊:

12.3.1 安裝 Elasticsearch 安全性外掛程式

您必須在 Elasticsearch 叢集的每個節點中和 Sentinel 所包含的 Elasticsearch 節點中安裝 Elasticsearch 安全性外掛程式。

若要在 Sentinel 所包含的 Elasticsearch 節點上安裝 elasticsearch-security-plug-in:

  1. 登入 Sentinel Main 或 SSDM 伺服器。

  2. 依照下列方式設定 JAVA_HOME 環境變數的路徑:

    export JAVA_HOME=/<Sentinel_installation_path>/opt/novell/sentinel/jdk/
  3. 安裝外掛程式:

    對於 Linux,請以執行 Elasticsearch 的使用者身分登入,並執行下列指令:

    <sentinel_installation_path>/opt/novell/sentinel/3rdparty/elasticsearch/bin/elasticsearch-plugin install file://localhost/<Sentinel_installation_path>/etc/opt/novell/sentinel/scalablestore/elasticsearch-security-plugin*.zip --verbose

    出現是否要繼續安裝的提示時,請輸入 y。

  4. (條件式) 如果 Elasticsearch 未在預設 HTTP 連接埠 (9200) 上接聽,則您必須在 <Sentinel_installation_path>/opt/novell/sentinel/3rdparty/elasticsearch/plugins/elasticsearch-security-plugin/elasticsearch-ip-whitelist.txt 檔案的每個項目中更新 Elasticsearch 連接埠號碼。

    如需詳細資訊,請參閱使用白名單為 Elasticsearch 用戶端提供存取權。

  5. 使用下列指令重新啟動 Sentinel 中的索引服務:

    rcsentinel stopSIdb
    rcsentinel startSIdb

若要在外部 Elasticsearch 節點上安裝 elasticsearch-security-plug-in:

在 Elasticsearch 叢集中的每個節點上執行下列步驟:

  1. 登入 Sentinel Main 或 SSDM 伺服器。

  2. 將 <Sentinel_installation_path>/etc/opt/novell/sentinel/scalablestore/elasticsearch-security-plugin*.zip 檔案複製到 Elasticsearch 叢集中每個節點上的暫存位置。

  3. 安裝外掛程式:

    對於 Linux,請以執行 Elasticsearch 的使用者身分登入,並執行下列指令:

    <elasticsearch_install_directory>/bin/elasticsearch-plugin install file://localhost/<full path of elasticsearch-security-plugin*.zip file> --verbose

    出現是否要繼續安裝的提示時,請輸入 y。

  4. (條件式) 如果 Elasticsearch 未在預設 HTTP 連接埠 (9200) 上接聽,則您必須在 <elasticsearch_install_directory>/plugins/elasticsearch-security-plugin/elasticsearch-ip-whitelist.txt 檔案的每個項目中更新 Elasticsearch 連接埠號碼。

    如需詳細資訊,請參閱使用白名單為 Elasticsearch 用戶端提供存取權。

  5. 重新啟動 Elasticsearch。

12.3.2 為其他 Elasticsearch 用戶端提供安全存取權

根據預設,信任的用戶端如 SSDM 伺服器 (適用於「事件視覺化」儀表板) 和 YARN NodeManagers、Sentinel 伺服器 (適用於「事件視覺化」儀表板) 和 RCM,皆可存取 Elasticsearch。如果您想要使用其他 Elasticsearch 用戶端,您必須使用 SAML 記號或白名單為這些用戶端提供安全存取權。

使用 SAML 記號為 Elasticsearch REST 用戶端提供存取權

如果您要使用 REST 用戶端來存取 Elasticsearch,您可以在要求標題中包含 SAML 記號,如下所示:

  1. 從 Sentinel 驗證伺服器取得 SAML 記號。如需詳細資訊,請參閱 Sentinel 中提供的 REST API 文件。

    按一下「說明」>「API」>「教學課程」>「API 安全性」>「取得 SAML 記號 (登入)」。

  2. 在後續的 REST 要求中使用 SAML 記號:在 REST 用戶端所提出之每個要求的「授權」標題中包含 SAML 記號。將標題名稱指定為授權,並將標題值指定為在步驟 1 中取得的 <SAML 記號>。

使用白名單為 Elasticsearch 用戶端提供存取權

根據預設,Sentinel 會在白名單中自動填入信任的 Elasticsearch 用戶端 IP 位址,例如 SSDM 伺服器 (適用於「事件視覺化」儀表板) 和 YARN NodeManagers、Sentinel 伺服器 (適用於「事件視覺化」儀表板) 和 RCM。Elasticsearch 安全性外掛程式會為白名單中所列的所有用戶端授與 Elasticsearch 的存取權。

若要為未傳送有效 Sentinel 記號的其他用戶端提供存取權,您必須以 IP 位址:連接埠的格式,將用戶端的 IP 位址和 Elasticsearch 伺服器的 HTTP 連接埠號碼新增至白名單。您必須確定您在白名單中新增的外部用戶端是合法且可信任的,以防止任何未經授權的存取。

如果要更新白名單:

  1. 以執行 Elasticsearch 的使用者身分,登入 Sentinel 伺服器或 Elasticsearch 節點。

  2. 在下列檔案中新增項目 <Elasticsearch_Client_IP>:<Target_Elasticsearch_HTTP_Port>:

    • <Sentinel_installation_path>/opt/novell/sentinel/3rdparty/elasticsearch/plugins/elasticsearch-security-plugin/elasticsearch-ip-whitelist.txt (適用於 Sentinel 中包含的 Elasticsearch 節點)。

    • <elasticsearch_install_directory>/plugins/elasticsearch-security-plugin/elasticsearch-ip-whitelist.txt (適用於外部 Elasticsearch 節點)。

    如果有多個項目,請將每個項目新增於不同行,並儲存檔案。

  3. 在 Elasticsearch 叢集的每個節點中重複上述步驟。

12.3.3 更新 Elasticsearch 外掛程式組態

如果您修改了可擴充儲存元件的 IP 位址/主機名稱和連接埠號碼,或是 Elasticsearch 版本和連接埠號碼,則必須對 Elasticsearch 外掛程式組態檔案進行相對應的更新。

在 Elasticsearch 叢集的每個節點上執行下列步驟:

  1. 以執行 Elasticsearch 的使用者身分登入 Elasticsearch 節點。

  2. (條件式) 如果您修改了 YARN NodeManager IP 位址、SSDM 或 Sentinel 伺服器 IP 位址、RCM IP 位址或 Elasticsearch 連接埠號碼,請對白名單進行相對應的更新,以確定 Elasticsearch 安全性外掛程式會為 Elasticsearch 用戶端授與存取權。

    如果您要在 HA 模式下設定 SSDM 或 Sentinel,請為 HA 叢集的每個主動節點和被動節點新增實體 IP 位址項目。

    如果您為 HA 叢集的任何節點修改了實體 IP 位址,或是將新的節點新增至 HA 叢集,請使用已修改或新增之節點的實體 IP 位址更新白名單。

    如需詳細資訊,請參閱使用白名單為 Elasticsearch 用戶端提供存取權。

  3. (條件式) 如果您修改了 SSDM IP 位址、Sentinel 伺服器 IP 位址或 Web 伺服器連接埠號碼,請更新下列檔案中的 authServer.host 和 authServer.port 內容,並重新啟動 Elasticsearch:

    • <Sentinel_installation_path>/opt/novell/sentinel/3rdparty/elasticsearch/plugins/elasticsearch-security-plugin/plugin-configuration.properties (適用於 Sentinel 中包含的 Elasticsearch 節點)。

    • <elasticsearch_install_directory>/plugins/elasticsearch-security-plugin/plugin-configuration.properties (適用於外部 Elasticsearch 節點)。

    如果您要在 HA 模式中設定 SSDM 或 Sentinel,請將 authServer.host 內容設定為 HA 叢集的虛擬 IP 位址。

    如果您修改了 HA 叢集的虛擬 IP 位址,請將 authServer.host 內容更新為已修改的虛擬 IP 位址。

  4. (條件式) 如果您將 Elasticsearch 升級至新版本,請更新下列檔案中的 elasticsearch.version 內容,並重新啟動 Elasticsearch:

    • /opt/novell/sentinel/3rdparty/elasticsearch/plugins/elasticsearch-security-plugin/plugin-descriptor.properties (適用於 Sentinel 中包含的 Elasticsearch 節點)。

    • <elasticsearch_install_directory>/plugins/elasticsearch-security-plugin/plugin-descriptor.properties (適用於外部 Elasticsearch 節點)。