設定 Cassandra

本文說明 Cassandra 5.0.X 的設定,適用於 Apigee Edge for Private Cloud 4.54.00 以上版本。如要瞭解如何套用本頁所述的設定,請參閱「附錄」一節。

垃圾收集器設定

修改 G1GC 設定

根據預設,Apigee 會隨附 Cassandra 和 G1 垃圾收集器 (G1GC),並提供預設 G1GC 參數。Cassandra 5.0.X 是在 Java 17 上執行,因此不再支援 Concurrent Mark Sweep (CMS) 垃圾收集器 (conf_jvm_options_gc_type=cms 和 conf_jvm_options_cms_gc_setting_lines)。如要變更 G1GC 參數,請在單行中設定 conf_jvm_options_g1_gc_setting_lines 屬性,並以 \n 分隔每個 JVM 參數。

範例:

conf_jvm_options_g1_gc_setting_lines=-XX:+UseG1GC\n-XX:G1RSetUpdatingPauseTimePercent=5\n-XX:MaxGCPauseMillis=500\n-XX:InitiatingHeapOccupancyPercent=50\n-XX:ParallelGCThreads=8\n-XX:ConcGCThreads=8\n-XX:+ParallelRefProcEnabled\n-XX:MaxTenuringThreshold=1\n-XX:G1HeapRegionSize=32m\n-XX:G1ReservePercent=15

使用自己的 GC 設定

如要忽略 Apigee 的 G1GC 預設值,請設定下列設定:

conf_jvm_options_gc_type=custom

在 conf_jvm_options_custom_settings 中指定 JVM 的所有 GC 設定,並以 \n 分隔各項設定。

範例:

conf_jvm_options_gc_type=custom
conf_jvm_options_custom_settings=-XX:+UseParallelGC\n-XX:GCTimeRatio=19

設定堆積大小

Apigee 強烈建議操作 Cassandra 時,堆積空間不超過 8 GB。將堆積大小限制為 8 GB 的檢查位於 $APIGEE_ROOT/apigee-cassandra/conf/cassandra-env.sh。

如要指定自己的堆積大小,但不要手動停用檢查,請使用設定 conf_jvm_options_custom_settings。請以 \n 分隔各項設定。

範例:

conf_jvm_options_custom_settings=-Xmx8G\n-Xms8G

設定一般 JVM 設定

如要將 JVM 參數新增至 Cassandra,請在以 \n 分隔的單行中,為設定 conf_jvm_options_custom_settings 指定所有 JVM 設定。

範例:

conf_jvm_options_custom_settings=-Dcassandra.start_rpc=true\n-Dcassandra.expiration_date_overflow_policy=CAP\n-XX:+FlightRecorder\n-XX:+UnlockCommercialFeatures

附錄

如何設定任何 Cassandra 設定

  1. 建立或編輯 Cassandra 設定覆寫檔案:
    vi $APIGEE_ROOT/customer/application/cassandra.properties
  2. 視需要新增、移除或修改設定行。
  3. 儲存檔案,並確保「apigee」使用者擁有該檔案且可讀取:
    chown apigee:apigee $APIGEE_ROOT/customer/application/cassandra.properties
  4. 在節點上重新啟動 Cassandra 服務:
    apigee-service apigee-cassandra restart
  5. 逐一在每個 Cassandra 節點上重複執行這些步驟。

多種設定類型

設定 conf_jvm_options_custom_settings 可將不同參數傳遞至 Cassandra JVM。將多個 Java 參數合併為單一設定,並以「\n」分隔。

範例:

conf_jvm_options_custom_settings=-XX:+FlightRecorder\n-XX:+UnlockCommercialFeatures\n-Xmx8G\n-Xms8G