Apigee 會使用 Cassandra 資料庫儲存大部分的資料,包括 Proxy、快取和權杖的資料。壓縮是減少資料庫儲存資料大小的重要程序,對於維護效率良好的資料庫作業而言,至關重要。Cassandra 支援多種壓縮策略。Apigee 建議所有 Private Cloud 客戶使用 LeveledCompactionStrategy
(而非預設的 SizeTieredCompactionStrategy
),為所有資料表操作 Cassandra 叢集。與 SizeTieredCompactionStrategy
相比,LeveledCompactionStrategy
可提供更好的效能、提升磁碟使用率、更有效率的壓縮效率,並需要較少可用空間。
安裝 Apigee 4.52.02 以上版本的所有新安裝項目,都會自動使用 LeveledCompactionStrategy
設定 Cassandra。不過,如果您使用的是舊版 Apigee,或已從舊版升級至 Apigee 4.52.02,安裝作業仍可能將 Cassandra 與 SizeTieredCompactionStrategy
搭配使用。
雖然我們不建議將壓縮策略改為 LeveledCompactionStrategy
以外的任何內容,但本文將概述如何在必要時進行變更,並提供檢查目前壓縮策略的操作說明。如果將壓縮策略變更為不建議的選項,日後的 Cassandra 軟體更新會覆寫您的變更。如果使用的是非標準方法,建議您在每次升級後都驗證壓縮策略。
準備
查看現有的壓縮策略
如要查看表格現有的壓縮策略,請按照 附錄 1 的指示操作。如果壓縮策略已處於 LeveledCompactionStrategy
狀態,可能是因為開始安裝 OPDK 4.51 以上版本,或之前曾按照 Apigee 建議變更為 LeveledCompactionStrategy
。如果您已在使用 LeveledCompactionStrategy
,Apigee 建議繼續使用這項策略,避免進行變更。不過,由於 Edge for Private Cloud 是由您負責操作,因此以下操作說明會說明如何視需要變更壓縮策略。
備份
由於變更壓縮策略會在 Cassandra 節點中觸發完整的壓縮週期,因此可能會因為壓縮和同時應用程式流量的負載而造成一些延遲。您可能需要復原這項變更,才能從備份還原 Cassandra 節點。請參閱如何備份一文,瞭解如何在變更壓縮策略前備份資料。
壓縮處理量
將壓縮策略變更為 LeveledCompactionStrategy
後,壓縮為
好像我們願意繼續說
他們耐心等待視資料壓縮的大小而定,執行階段可能會有所不同。壓縮期間
因此 Cassandra 可能會使用更多系統資源。確保壓縮不會佔用太多空間
系統資源可能會中斷 API 執行階段要求,建議您為
以及壓縮處理量
在每個節點上執行下列 nodetool
指令,將壓縮處理量設為最大值
在所有 Cassandra 節點上皆為 128 MB:
nodetool setcompactionthroughput 128
調整 VM 大小以進行壓縮
執行這項變更前,請先確認 Cassandra 節點具備充足的 CPU 和記憶體資源。執行這項變更前,請先確認沒有任何 Cassandra 節點在 CPU 負載超過 25% 運作。
完成壓縮策略後,預計會執行整個壓縮週期,因此建議您在流量偏低的期間變更密集策略。
分段跑步
您可能無法在一天內完成所有節點的變更 (特別是執行大型 Cassandra 叢集時),因為您必須逐一為每個節點重新建構索引。您可以變更單一結構定義或單一資料表的壓縮策略。因此,請變更表格來變更壓縮策略,然後在所有節點上的資料表 (如有) 重建所有索引。然後針對每個資料表或索引鍵空間重複執行上述程序。這類作業適用於一個資料表或一個鍵空間,可細分為不同的日期執行。
舉例來說,如要將 kms
結構定義中 oauth_20_access_tokens
資料表的壓縮策略變更為 LeveledCompactionStrategy
,您可以執行下列操作:
-
執行下列 CQL,變更表格以變更壓縮策略:
ALTER TABLE kms.oauth_20_access_tokens WITH compaction = {'class' : 'LeveledCompactionStrategy'};
-
重新建構僅有這個資料表的所有索引:
nodetool rebuild_index kms oauth_20_access_tokens oauth_20_access_tokens_app_id_idx nodetool rebuild_index kms oauth_20_access_tokens oauth_20_access_tokens_client_id_idx nodetool rebuild_index kms oauth_20_access_tokens oauth_20_access_tokens_refresh_token_idx
變更壓縮策略
整體而言,變更壓縮策略分為兩個步驟:
- 修改每個資料表的壓縮策略。
- 逐一重新建構每個節點上的所有索引。
如要修改壓縮策略,則必須在每個資料表上一次執行一個 ALTER TABLE
指令。範例 ALTER TABLE
指令如下所示:
# To change to LeveledCompactionStrategyALTER TABLE
kms.oauth_20_access_tokens WITH compaction = {'class' : 'LeveledCompactionStrategy'}; # To change to SizeTieredCompactionStrategyALTER TABLE
kms.oauth_20_access_tokens WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
修改表格以設定新壓縮策略
請在任何 Cassandra 節點上執行下列 CQL,一次變更一個索引鍵空間的策略。CQL 可以在 CQL 提示上執行。叫用 CQL 提示的操作說明:
/opt/apigee/apigee-cassandra/bin/cqlsh `hostname -i`
已透過 XXXXXXXX:9042 連線至 Apigee。
[cqlsh 5.0.1 | Cassandra 3.11.16 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. cqlsh>
下方指令涵蓋將壓縮策略變更為 LeveledCompactionStrategy
,但類似指令可用於變更為其他壓縮策略。
以下步驟 14 至 16 僅適用於營利使用者。
- 可變更鍵空間的壓縮策略:
kms
ALTER TABLE kms.organizations WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.maps WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.apps WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.app_credentials WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.api_products WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.apiproducts_appslist WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.api_resources WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.app_end_user WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.oauth_20_authorization_codes WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.oauth_20_access_tokens WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.oauth_10_request_tokens WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.oauth_10_access_tokens WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.oauth_10_verifiers WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE kms.app_enduser_tokens WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
user_settings
ALTER TABLE user_settings.user_settings WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
keyvaluemap
ALTER TABLE keyvaluemap.keyvaluemaps_r21 WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
devconnect
ALTER TABLE devconnect.developers WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE devconnect.companies WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE devconnect.company_developers WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
counter
ALTER TABLE counter.counters_current_version WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE counter.counters_with_expiry WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE counter.counters WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE counter.key_timestamp_count WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE counter.timestamp_key WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE counter.period_timestamp WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE counter.gateway_quota WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
cache
ALTER TABLE cache.cache_entries WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE cache.cache_sequence_id_r24 WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
auth
ALTER TABLE auth.totp WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
audit
ALTER TABLE audit.audits WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE audit.audits_ref WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
apprepo
ALTER TABLE apprepo.organizations WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apprepo.environments WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apprepo.apiproxies WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apprepo.apiproxy_revisions WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apprepo.api_proxy_revisions_r21 WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
apimodel_v2
ALTER TABLE apimodel_v2.apis WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.apis_revision WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.resource WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.method WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.revision_counters WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.template_counters WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.template WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.credentials WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.credentialsv2 WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.schemas WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.security WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel_v2.template_auth WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
identityzone
ALTER TABLE identityzone.IdentityZones WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE identityzone.OrgToIdentityZone WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
dek
ALTER TABLE dek.keys WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- 可變更鍵空間的壓縮策略:
analytics
ALTER TABLE analytics.custom_aggregates_defn WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE analytics.custom_rules_defn WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE analytics.custom_aggregates_defn_updates WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE analytics.custom_rules_defn_updates WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- [僅限營利] 負責變更鍵空間的壓縮策略:
mint
ALTER TABLE mint.limits WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE mint.suspended_developer_products WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE mint.invitations WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- [僅限營利] 負責變更鍵空間的壓縮策略:
taurus
ALTER TABLE taurus.triggers WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE taurus.job_details WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE taurus.org_triggers WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE taurus.triggers_suite WITH compaction = {'class' : 'LeveledCompactionStrategy'};
- [僅限營利] 負責變更鍵空間的壓縮策略:
notification
ALTER TABLE notification.notification_service_item WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE notification.notification_service_black_list_item WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE notification.notification_email_template_item WITH compaction = {'class' : 'LeveledCompactionStrategy'};
重建索引
此步驟必須在任何壓縮策略變更後執行。請在每個 Cassandra 節點上逐一執行下列 nodetool
指令。
以下步驟 7 至 9 僅適用於使用營利功能的使用者。
-
重新建立鍵空間的索引:
kms
nodetool rebuild_index kms api_products api_products_organization_name_idx nodetool rebuild_index kms app_credentials app_credentials_api_products_idx nodetool rebuild_index kms app_credentials app_credentials_organization_app_id_idx nodetool rebuild_index kms app_credentials app_credentials_organization_name_idx nodetool rebuild_index kms app_end_user app_end_user_app_id_idx nodetool rebuild_index kms apps apps_app_family_idx nodetool rebuild_index kms apps apps_app_id_idx nodetool rebuild_index kms apps apps_app_type_idx nodetool rebuild_index kms apps apps_name_idx nodetool rebuild_index kms apps apps_organization_name_idx nodetool rebuild_index kms apps apps_parent_id_idx nodetool rebuild_index kms apps apps_parent_status_idx nodetool rebuild_index kms apps apps_status_idx nodetool rebuild_index kms maps maps_organization_name_idx nodetool rebuild_index kms oauth_10_access_tokens oauth_10_access_tokens_app_id_idx nodetool rebuild_index kms oauth_10_access_tokens oauth_10_access_tokens_consumer_key_idx nodetool rebuild_index kms oauth_10_access_tokens oauth_10_access_tokens_organization_name_idx nodetool rebuild_index kms oauth_10_access_tokens oauth_10_access_tokens_status_idx nodetool rebuild_index kms oauth_10_request_tokens oauth_10_request_tokens_consumer_key_idx nodetool rebuild_index kms oauth_10_request_tokens oauth_10_request_tokens_organization_name_idx nodetool rebuild_index kms oauth_10_verifiers oauth_10_verifiers_organization_name_idx nodetool rebuild_index kms oauth_10_verifiers oauth_10_verifiers_request_token_idx nodetool rebuild_index kms oauth_20_access_tokens oauth_20_access_tokens_app_id_idx nodetool rebuild_index kms oauth_20_access_tokens oauth_20_access_tokens_client_id_idx nodetool rebuild_index kms oauth_20_access_tokens oauth_20_access_tokens_refresh_token_idx nodetool rebuild_index kms oauth_20_authorization_codes oauth_20_authorization_codes_client_id_idx nodetool rebuild_index kms oauth_20_authorization_codes oauth_20_authorization_codes_organization_name_idx
-
重新建立鍵空間的索引:
devconnect
nodetool rebuild_index devconnect companies companies_name_idx nodetool rebuild_index devconnect companies companies_organization_name_idx nodetool rebuild_index devconnect companies companies_status_idx nodetool rebuild_index devconnect company_developers company_developers_company_name_idx nodetool rebuild_index devconnect company_developers company_developers_developer_email_idx nodetool rebuild_index devconnect company_developers company_developers_organization_name_idx nodetool rebuild_index devconnect developers developers_email_idx nodetool rebuild_index devconnect developers developers_organization_name_idx nodetool rebuild_index devconnect developers developers_status_idx
-
重新建立鍵空間的索引:
cache
nodetool rebuild_index cache cache_entries cache_entries_cache_name_idx
-
重新建立鍵空間的索引:
audit
nodetool rebuild_index audit audits audits_operation_idx nodetool rebuild_index audit audits audits_requesturi_idx nodetool rebuild_index audit audits audits_responsecode_idx nodetool rebuild_index audit audits audits_timestamp_idx nodetool rebuild_index audit audits audits_user_idx
-
重新建立鍵空間的索引:
apimodel_v2
nodetool rebuild_index apimodel_v2 apis a_name nodetool rebuild_index apimodel_v2 apis a_org_name nodetool rebuild_index apimodel_v2 apis_revision ar_a_active_rev nodetool rebuild_index apimodel_v2 apis_revision ar_a_def_index_template nodetool rebuild_index apimodel_v2 apis_revision ar_a_def_method_template nodetool rebuild_index apimodel_v2 apis_revision ar_a_latest_rev nodetool rebuild_index apimodel_v2 apis_revision ar_a_name nodetool rebuild_index apimodel_v2 apis_revision ar_a_uuid nodetool rebuild_index apimodel_v2 apis_revision ar_base_url nodetool rebuild_index apimodel_v2 apis_revision ar_is_active nodetool rebuild_index apimodel_v2 apis_revision ar_is_latest nodetool rebuild_index apimodel_v2 apis_revision ar_name nodetool rebuild_index apimodel_v2 apis_revision ar_org_name nodetool rebuild_index apimodel_v2 apis_revision ar_rel_ver nodetool rebuild_index apimodel_v2 apis_revision ar_rev_num nodetool rebuild_index apimodel_v2 method m_a_name nodetool rebuild_index apimodel_v2 method m_api_uuid nodetool rebuild_index apimodel_v2 method m_ar_uuid nodetool rebuild_index apimodel_v2 method m_base_url nodetool rebuild_index apimodel_v2 method m_name nodetool rebuild_index apimodel_v2 method m_org_name nodetool rebuild_index apimodel_v2 method m_r_name nodetool rebuild_index apimodel_v2 method m_r_uuid nodetool rebuild_index apimodel_v2 method m_res_path nodetool rebuild_index apimodel_v2 method m_rev_num nodetool rebuild_index apimodel_v2 resource r_a_name nodetool rebuild_index apimodel_v2 resource r_api_uuid nodetool rebuild_index apimodel_v2 resource r_ar_uuid nodetool rebuild_index apimodel_v2 resource r_base_url nodetool rebuild_index apimodel_v2 resource r_name nodetool rebuild_index apimodel_v2 resource r_org_name nodetool rebuild_index apimodel_v2 resource r_res_path nodetool rebuild_index apimodel_v2 resource r_rev_num nodetool rebuild_index apimodel_v2 schemas s_api_uuid nodetool rebuild_index apimodel_v2 schemas s_ar_uuid nodetool rebuild_index apimodel_v2 security sa_api_uuid nodetool rebuild_index apimodel_v2 security sa_ar_uuid nodetool rebuild_index apimodel_v2 template t_a_name nodetool rebuild_index apimodel_v2 template t_a_uuid nodetool rebuild_index apimodel_v2 template t_entity nodetool rebuild_index apimodel_v2 template t_name nodetool rebuild_index apimodel_v2 template t_org_name nodetool rebuild_index apimodel_v2 template_auth au_api_uuid
-
重新建立鍵空間的索引:
dek
nodetool rebuild_index dek keys usecase_index
-
[僅限營利] 重新建構鍵空間的索引:
mint
nodetool rebuild_index mint limits limits_created_date_idx nodetool rebuild_index mint limits limits_id_idx nodetool rebuild_index mint limits limits_org_id_idx nodetool rebuild_index mint limits limits_updated_date_idx nodetool rebuild_index mint suspended_developer_products suspended_developer_products_created_date_idx nodetool rebuild_index mint suspended_developer_products suspended_developer_products_currency_idx nodetool rebuild_index mint suspended_developer_products suspended_developer_products_dev_id_idx nodetool rebuild_index mint suspended_developer_products suspended_developer_products_id_idx nodetool rebuild_index mint suspended_developer_products suspended_developer_products_limit_id_idx nodetool rebuild_index mint suspended_developer_products suspended_developer_products_org_id_idx nodetool rebuild_index mint suspended_developer_products suspended_developer_products_prod_id_idx nodetool rebuild_index mint suspended_developer_products suspended_developer_products_reason_code_idx nodetool rebuild_index mint suspended_developer_products suspended_developer_products_sub_org_id_idx nodetool rebuild_index mint invitations invitations_company_id_idx nodetool rebuild_index mint invitations invitations_created_at_idx nodetool rebuild_index mint invitations invitations_developer_id_idx nodetool rebuild_index mint invitations invitations_lastmodified_at_idx nodetool rebuild_index mint invitations invitations_org_id_idx
-
[僅限營利] 重新建構鍵空間的索引:
taurus
nodetool rebuild_index taurus triggers triggers_env_idx nodetool rebuild_index taurus triggers triggers_job_id_idx nodetool rebuild_index taurus triggers triggers_org_id_idx nodetool rebuild_index taurus job_details job_details_job_class_name_idx nodetool rebuild_index taurus job_details job_details_job_group_idx nodetool rebuild_index taurus job_details job_details_job_name_idx nodetool rebuild_index taurus org_triggers org_triggers_org_id_idx nodetool rebuild_index taurus triggers_suite triggers_suite_group_idx nodetool rebuild_index taurus triggers_suite triggers_suite_name_idx nodetool rebuild_index taurus triggers_suite triggers_suite_suite_id_idx
-
[僅限營利] 重新建構鍵空間的索引:
notification
nodetool rebuild_index notification notification_service_item notification_service_item_org_id_idx nodetool rebuild_index notification notification_service_item notification_service_item_status_idx nodetool rebuild_index notification notification_service_black_list_item notification_service_black_list_item_org_id_idx nodetool rebuild_index notification notification_service_black_list_item notification_service_black_list_item_to_email_idx nodetool rebuild_index notification notification_email_template_item notification_email_template_item_name_idx nodetool rebuild_index notification notification_email_template_item notification_email_template_item_org_id_idx
驗證
- 按照附錄 1 中的操作說明,檢查對結構定義變更的壓縮策略是否已生效。
- 驗證壓縮是否成功執行,並在策略變更後進行資料調整:
- 在每個 Cassandra 節點上執行下列 nodetool 指令,瞭解所有壓縮作業是否完成,且沒有待處理的項目:
nodetool compactionstats
- 使用上述指令確認沒有待處理的壓縮後,請檢查資料檔案的上次修改時間戳記 (位於
/opt/apigee/data/apigee-cassandra/data/
下方) 早於壓縮策略變更 CQL 執行的時間戳記之後。
- 在每個 Cassandra 節點上執行下列 nodetool 指令,瞭解所有壓縮作業是否完成,且沒有待處理的項目:
復原
如需復原作業,請選擇下列其中一個選項:
選項 1:還原變更
將密集策略復原為原先採用的策略。
在先前執行的 CQL 提示中執行類似的 ALTER TABLE 指令,以變更壓縮策略。
如果您已重新建構索引,並將密集策略變更為 LeveledCompactionStrategy
,則必須再次重新建構索引。按照重新建構所有索引的相同步驟操作。如果您之前沒有重建索引,則在復原期間不需要重建索引。
選項 2:從備份還原完整資料
從所有金鑰空間的備份還原資料:
請按照「從備份還原」一文的操作說明還原資料。
附錄 1:檢查密集策略
壓縮策略是在 Cassandra 中的資料表層級設定。您可以使用下列查詢檢查每份資料表的壓縮策略。
您可以在 CQL 提示中執行 CQL。如要叫用 CQL 提示:
/opt/apigee/apigee-cassandra/bin/cqlsh `hostname -i`
您會看到類似下方的回應:
Connected to apigee at XX.XX.XX.XX:9042. [cqlsh 5.0.1 | Cassandra 3.11.16 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. cqlsh>
您可以按照下列方式判斷目前的壓縮策略:
輸出內容中的每一列都與索引鍵空間中的資料表有關。每一列的「壓縮」欄都指出表格使用的壓縮策略。
- 如果壓縮策略設為 SizeTieredCompactionStrategy,下列查詢中的 compaction 資料欄將如下所示:
- 如果壓縮策略設為 LeveledCompactionStrategy,下列查詢中的資料欄壓縮看起來會像這樣:
{'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
{'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'}
可以在下列查詢中執行查詢,決定特定索引鍵空間中每個資料表的壓縮策略:
select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'kms'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'user_settings'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'keyvaluemap'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'devconnect'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'counter'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'cache'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'auth'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'audit'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'apprepo'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'apimodel_v2'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'identityzone'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'dek'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'analytics'; #If you are using Monetization, check the below as well select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'mint'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'taurus'; select keyspace_name, table_name, compaction from system_schema.tables where keyspace_name = 'notification';