啟用 Cassandra 驗證

根據預設,Cassandra 會在不啟用驗證功能的情況下安裝。這意味著每個人都能存取 Cassandra您可以在安裝 Edge 後啟用驗證功能,或是在安裝過程中啟用驗證功能 上傳資料集之後,您可以運用 AutoML 自動完成部分資料準備工作

您可以使用 Cassandra CREATE/ALTER/DROP USER 新增、移除及修改使用者 聲明。詳情請參閱 Cassandra SQL 殼層指令

在以下期間啟用 Cassandra 驗證 安裝

您可以在安裝時啟用 Cassandra 驗證。

如要在安裝時啟用 Cassandra 驗證,請加入 CASS_AUTH 屬性:

CASS_AUTH=y # The default value is n.

下列 Edge 元件可存取 Cassandra:

  • 管理伺服器
  • 訊息處理器
  • 路由器
  • Qpid 伺服器
  • Postgres 伺服器

安裝這些元件時,您必須在 設定檔:

CASS_USERNAME=cassandra_username
CASS_PASSWORD=cassandra_password

安裝 Cassandra 後,即可變更 Cassandra 憑證。不過 已安裝管理伺服器、訊息處理器、路由器、Qpid 伺服器或 Postgres 您也需要更新這些元件,才能使用新的憑證。

如要在安裝 Cassandra 後變更 Cassandra 憑證:

  1. 使用 cqlsh 工具和預設登入任一 Cassandra 節點 憑證你只需要變更其中一個節點的密碼,系統就會廣播給所有節點 環形中的 Cassandra 節點:
    /opt/apigee/apigee-cassandra/bin/cqlsh cassIP 9042 -u cassandra_username -p cassandra_password

    在此情況下:

    1. cassIP 是 Cassandra 節點的 IP 位址。
    2. 9042 是預設的 Cassandra 通訊埠。
  2. cqlsh> 提示中執行下列指令,更新密碼:
    ALTER USER cassandra_username/var> WITH PASSWORD 'new_cassandra_password';
  3. 結束 cqlsh 工具,如以下範例所示:
    exit
  4. 如果您尚未安裝管理伺服器、訊息處理器、 路由器、Qpid 伺服器或 Postgres 伺服器,在 設定檔,然後安裝這些元件:
    CASS_USERNAME=cassandra_username
    CASS_PASSWORD=new_cassandra_password
  5. 如果您已安裝管理伺服器、訊息 處理器、路由器、Qpid 伺服器或 Postgres 伺服器,然後參閱重設邊緣密碼,瞭解如何更新這些伺服器 元件,以使用新密碼。

啟用 Cassandra 驗證貼文 安裝

如何在安裝後啟用驗證功能:

更新連線至 Cassandra 的 Edge 元件

請使用以下程序更新所有與 Cassandra 通訊的 Edge 元件 以新的憑證讀取資料請注意,在實際更新 Cassandra 之前,請先執行這個步驟。 憑證:

  1. 在 Management Server 節點上,執行下列指令:
    /opt/apigee/apigee-service/bin/apigee-service edge-management-server
      store_cassandra_credentials -u cassandra_username -p cassandra_password

    或者,您可以將檔案傳送至包含新使用者名稱和密碼的指令:

    apigee-service edge-management-server store_cassandra_credentials  -f configFile

    其中 configFile 包含下列內容:

    CASS_USERNAME=cassandra_username # Default is cassandra
    CASS_PASSWORD='cassandra_password' # Default is cassandra; wrap in single quotes if it includes special chars

    這個指令會自動重新啟動管理伺服器。

  2. 針對下列各項服務,重複執行步驟 1:
    • 所有訊息處理器
    • 所有路由器
    • 所有 Qpid 伺服器 (edge-qpid-server)
    • Postgres 伺服器 (edge-postgres-server)

    當您為每個服務重複步驟 1 時,請將 edge-management-server 中的 傳回對應的服務名稱舉例來說,如果您在 請使用以下指令:

    /opt/apigee/apigee-service/bin/apigee-service edge-router
      store_cassandra_credentials -u cassandra -p cassandra

啟用驗證機制

請按照下列步驟啟用 Cassandra 驗證,並設定使用者名稱和 密碼:

  1. 建立無訊息設定檔,內容如下所示:
    # Specify IP address or DNS name of cassandra node
    IP1=192.168.1.1
    IP2=192.168.1.2
    IP3=192.168.1.3
    # Must resolve to IP address or DNS name of host
    HOSTIP=$(hostname -i)
    # Set to ‘y’ to enable Cassandra authentication.
    CASS_AUTH=y # Possible values are ‘y/n’
    # Cassandra username. If it does not exist, this user would be created as a SUPERUSER
    CASS_USERNAME=cassandra_username # Default value is cassandra - don't use for production
    # Cassandra Password. If CASS_USERNAME does not exist, create SUPERUSER with this as password
    CASS_PASSWORD=cassandra_password # Default value is cassandra - don't use for production
    # Space-separated IP/DNS names of the Cassandra hosts
    CASS_HOSTS="$IP1:1,1 $IP2:1,1 $IP3:1,1"
    
    # Username of an existing C* user. Only needed if you have disabled or changed details of the default cassandra user(‘cassandra’)
    CASS_EXISTING_USERNAME=existing_cassandra_username
    # Password of an existing C* user. Only needed if you have disabled or change password of the default cassandra user(‘cassandra’)
    CASS_EXISTING_PASSWORD=existing_cassandra_password
    # Cassandra port
    CASS_PORT=9042 # The default port is 9042.
  2. 登入第一個 Cassandra 節點,然後執行下列指令:

    apigee-service apigee-cassandra enable_cassandra_authentication -f CONFIG

    或者,您也可以將屬性做為指令引數傳送至指令碼,如 範例:

    CASS_AUTH=y HOSTIP=$(hostname -i) CASS_PORT=9042 CASS_EXISTING_USERNAME=existing_cassandra_username CASS_EXISTING_PASSWORD=existing_cassandra_password CASS_USERNAME=cassandra_username CASS_PASSWORD=cassandra_password  CASS_HOSTS="192.168.1.1:1,1 192.168.1.2:1,1 192.168.1.3:1,1" apigee-service apigee-cassandra enable_cassandra_authentication

    注意:

    • 預設 Cassandra 憑證,上述指令會啟用 Cassandra 驗證和重新啟動 Cassandra
    • 如果是非預設憑證,這個指令也會修改複製因素,並 超級使用者,並在 system_auth keyspace 執行維修。
  3. 在所有 Cassandra 節點上重複執行步驟 1 和 2。