Apigee 會使用 Cassandra 資料庫儲存大部分的資料,包括
Proxy、快取和權杖
壓縮是縮減資料大小的標準程序
這些資料對於確保
資料庫能有效率地執行Cassandra 支援多種壓縮策略。Apigee
建議私有雲客戶的所有 Edge 使用 Cassandra 叢集
策略「LeveledCompactionStrategy
」,而非預設策略
SizeTieredCompactionStrategy
,適用於所有資料欄系列。LeveledCompactionStrategy
提高效能、改善磁碟使用率、效率
,且所需的可用空間少於 SizedTieredCompactionStrategy
。
往後安裝 Apigee 4.51.00 以上版本時,系統會自動設定 Cassandra
只在 LeveledCompactionStrategy
。不過,如果您使用的是舊版
Apigee 或
已從舊版升級至 Apigee 4.51.00,目前您的版本可能仍在使用 Cassandra
只在 SizeTieredCompactionStrategy
。
如要找出您的 Cassandra 版本,請參閱
「檢查壓縮策略」一節。
本頁說明如何將壓縮策略變更為
LeveledCompactionStrategy
。
準備
查看現有的壓縮策略
如要查看資料欄系列現有的壓縮策略,請按照
檢查密集策略。如果採用壓縮策略
已經是 LeveledCompactionStrategy
,您不必追蹤其餘
請參閱本頁的操作說明。
備份
因為變更密集策略,會在 C* 節點中觸發完整的壓縮週期。可能會導入 導致某些延遲。復原 可能需要此變更,才能從備份還原 Cassandra 節點。 請參閱如何 備份,瞭解如何在變更壓縮策略前備份資料。
壓縮處理量
將壓縮策略變更為 LeveledCompactionStrategy
後,壓縮為
好像我們願意繼續說
他們耐心等待視資料壓縮的大小而定,執行階段可能會有所不同。壓縮期間
因此 Cassandra 可能會使用更多系統資源。確保壓縮不會佔用太多空間
系統資源可能會中斷 API 執行階段要求,建議您為
以及壓縮處理量
在每個節點上執行下列 nodetool
指令,將壓縮處理量設為最大值
所有 C* 節點的 128 MB:
nodetool setcompactionthroughput 128
調整 VM 大小以進行壓縮
請先確認 C* 節點具備充足的 CPU/記憶體資源,再執行這項變更。請確認 在執行這項變更之前,沒有任何 C* 節點在 CPU 負載超過 25% 運作。
完成壓縮策略後,將會執行整個壓縮週期,因此 在流量偏低時變更密集策略。
分段跑步
您可能無法在一天內完成所有節點的變更 大型 Cassandra 叢集,因為需要在每個節點上逐一重新建構索引。您可以調整 選擇單一結構定義或一個資料欄系列 (資料表) 的壓縮策略。在這個情況下,請將 變更其壓縮策略,然後在資料表中重建所有索引 在所有節點上執行 (如有)。然後針對每個資料表或索引鍵空間重複執行上述程序。這類跑步 可以細分為一個資料表或一個鍵空間,並執行不同的日期。
例如,若要變更下列數量的 oauth_20_access_tokens
資料欄系列的密集策略:
kms
結構定義,您可以執行以下操作:
- 修改表格以變更壓縮策略:
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
變更壓縮策略
整體而言,變更壓縮策略需要兩個步驟:
- 修改每份表格的壓縮策略。
- 逐一重新建構每個節點上的所有索引。
修改表格以設定新的壓縮策略
對任何 Cassandra 節點執行下列 Cassandra 查詢語言 (CQL) 指令,變更
第一類應用程式的策略
索引鍵空間您可以在 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 2.1.16 | CQL spec 3.2.1 | Native protocol v3] Use HELP for help. cqlsh>
執行下列 CQL,變更壓縮策略:
- 可變更鍵空間「
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'};
- 可變更鍵空間「
ax_custom_report_model
」的壓縮策略:ALTER TABLE ax_custom_report_model.report_description WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE ax_custom_report_model.report_id_lookup WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE ax_custom_report_model.org_metadata WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE ax_custom_report_model.org_report_lookup WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE ax_custom_report_model.report_created_view WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE ax_custom_report_model.report_viewed_view 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
」的壓縮策略:ALTER TABLE apimodel.apis WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.apis_revision WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.resource WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.method WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.revision_counters WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.template_counters WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.template WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.credentials WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.credentialsv2 WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.schemas WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.security WITH compaction = {'class' : 'LeveledCompactionStrategy'}; ALTER TABLE apimodel.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'};
重建索引
您必須在壓縮策略變更後執行此步驟。執行下列指令
nodetool
指令依序為每個 Cassandra 節點逐一執行。
執行下列 nodetool
指令來重新建構索引:
- 重新建構鍵空間
kms
的索引:nodetool rebuild_index kms maps maps_organization_name_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 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 api_products api_products_organization_name_idx nodetool rebuild_index kms app_end_user app_end_user_app_id_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 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_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_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_verifiers oauth_10_verifiers_organization_name_idx nodetool rebuild_index kms oauth_10_verifiers oauth_10_verifiers_request_token_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
- 重新建構鍵空間
apprepo
的索引:nodetool rebuild_index apprepo environments environments_organization_name_idx
- 重新建構鍵空間
apimodel
的索引:nodetool rebuild_index apimodel apis a_name nodetool rebuild_index apimodel apis a_org_name nodetool rebuild_index apimodel apis_revision ar_a_name nodetool rebuild_index apimodel apis_revision ar_a_uuid nodetool rebuild_index apimodel apis_revision ar_base_url nodetool rebuild_index apimodel apis_revision ar_is_active nodetool rebuild_index apimodel apis_revision ar_is_latest nodetool rebuild_index apimodel apis_revision ar_org_name nodetool rebuild_index apimodel apis_revision ar_rel_ver nodetool rebuild_index apimodel apis_revision ar_rev_num nodetool rebuild_index apimodel resource r_a_name nodetool rebuild_index apimodel resource r_api_uuid nodetool rebuild_index apimodel resource r_ar_uuid nodetool rebuild_index apimodel resource r_base_url nodetool rebuild_index apimodel resource r_name nodetool rebuild_index apimodel resource r_org_name nodetool rebuild_index apimodel resource r_res_path nodetool rebuild_index apimodel resource r_rev_num nodetool rebuild_index apimodel method m_a_name nodetool rebuild_index apimodel method m_api_uuid nodetool rebuild_index apimodel method m_ar_uuid nodetool rebuild_index apimodel method m_base_url nodetool rebuild_index apimodel method m_name nodetool rebuild_index apimodel method m_org_name nodetool rebuild_index apimodel method m_r_name nodetool rebuild_index apimodel method m_r_uuid nodetool rebuild_index apimodel method m_res_path nodetool rebuild_index apimodel method m_rev_num nodetool rebuild_index apimodel method m_verb nodetool rebuild_index apimodel template t_a_name nodetool rebuild_index apimodel template t_a_uuid nodetool rebuild_index apimodel template t_entity nodetool rebuild_index apimodel template t_name nodetool rebuild_index apimodel template t_org_name nodetool rebuild_index apimodel schemas s_api_uuid nodetool rebuild_index apimodel schemas s_ar_uuid nodetool rebuild_index apimodel security sa_api_uuid nodetool rebuild_index apimodel security sa_ar_uuid nodetool rebuild_index apimodel template_auth au_api_uuid
- 重新建構鍵空間
dek
的索引:nodetool rebuild_index dek keys usecase_index
驗證
- 請按照下列步驟操作,檢查結構定義變更是否已生效 操作說明 請參閱「檢查壓縮策略」一文。
- 驗證壓縮是否成功執行,並在策略變更後進行資料調整:
- 在每個 Cassandra 節點上執行下列
nodetool
指令,確認所有壓縮作業是否都含有 已完成,但沒有待處理狀態:nodetool compactionstats
- 使用上述指令進行驗證後,確認沒有待處理的壓縮作業後,請檢查 資料檔案上次修改時間戳記 (在 /opt/apigee/data/apigee-cassandra/data/) 緊接在執行壓縮策略變更 CQL 時的時間戳記之後。
- 在每個 Cassandra 節點上執行下列
復原
如需復原,您可以採取下列其中一種做法:
選項 1:還原變更
將壓縮策略復原為 SizeTieredCompactionStrategy
。
針對任一個 Cassandra 節點變更策略,執行以下 CQL
索引鍵空間您可以在 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 2.1.16 | CQL spec 3.2.1 | Native protocol v3] Use HELP for help. cqlsh>
執行下列 CQL,變更壓縮策略:
- 可變更鍵空間「
kms
」的壓縮策略:ALTER TABLE kms.organizations WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.maps WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.apps WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.app_credentials WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.api_products WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.apiproducts_appslist WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.api_resources WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.app_end_user WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.oauth_20_authorization_codes WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.oauth_20_access_tokens WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.oauth_10_request_tokens WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.oauth_10_access_tokens WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.oauth_10_verifiers WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE kms.app_enduser_tokens WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
user_settings
」的壓縮策略:ALTER TABLE user_settings.user_settings WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
keyvaluemap
」的壓縮策略:ALTER TABLE keyvaluemap.keyvaluemaps_r21 WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
devconnect
」的壓縮策略:ALTER TABLE devconnect.developers WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE devconnect.companies WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE devconnect.company_developers WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
counter
」的壓縮策略:ALTER TABLE counter.counters_current_version WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE counter.counters_with_expiry WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE counter.counters WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE counter.key_timestamp_count WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE counter.timestamp_key WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE counter.period_timestamp WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE counter.gateway_quota WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
-
可變更鍵空間「
cache
」的壓縮策略:ALTER TABLE cache.cache_entries WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE cache.cache_sequence_id_r24 WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
ax_custom_report_model
」的壓縮策略:ALTER TABLE ax_custom_report_model.report_description WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE ax_custom_report_model.report_id_lookup WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE ax_custom_report_model.org_metadata WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE ax_custom_report_model.org_report_lookup WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE ax_custom_report_model.report_created_view WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE ax_custom_report_model.report_viewed_view WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
auth
」的壓縮策略:ALTER TABLE auth.totp WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
audit
」的壓縮策略:ALTER TABLE audit.audits WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE audit.audits_ref WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
apprepo
」的壓縮策略:ALTER TABLE apprepo.organizations WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apprepo.environments WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apprepo.apiproxies WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apprepo.apiproxy_revisions WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apprepo.api_proxy_revisions_r21 WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
apimodel
」的壓縮策略:ALTER TABLE apimodel.apis WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.apis_revision WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.resource WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.method WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.revision_counters WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.template_counters WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.template WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.credentials WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.credentialsv2 WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.schemas WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.security WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE apimodel.template_auth WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
identityzone
」的壓縮策略:ALTER TABLE identityzone.IdentityZones WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE identityzone.OrgToIdentityZone WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
dek
」的壓縮策略:ALTER TABLE dek.keys WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
- 可變更鍵空間「
analytics
」的壓縮策略:ALTER TABLE analytics.custom_aggregates_defn WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE analytics.custom_rules_defn WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE analytics.custom_aggregates_defn_updates WITH compaction = {'class' : 'SizeTieredCompactionStrategy'}; ALTER TABLE analytics.custom_rules_defn_updates WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
所有資料欄系列都修改完畢後,如果您已重建索引
將壓縮策略變更為 LeveledCompactionStrategy
,則需重新建構索引
可以選取「重新建立」,再次生成新的提示按照前述的相同步驟重建
所有索引。如果您之前沒有重建索引,則在處理期間不需要重建索引
選項 2:從備份還原完整資料
如要執行完整資料還原作業,請參閱 從備份還原。
檢查密集策略
壓縮策略是在 Cassandra 中的資料欄系列 (資料表) 層級設定。您可以使用 檢查下方的 CQL 查詢,檢查每個資料欄系列的壓縮策略。
您可以在 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 2.1.16 | CQL spec 3.2.1 | Native protocol v3] Use HELP for help. cqlsh>
您可以按照下列方式判斷目前的壓縮策略:
- 如果壓縮策略設為
SizeTieredCompactionStrategy
,系統會輸出輸出內容 以下查詢將為org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
。 - 如果壓縮策略設為
LeveledCompactionStrategy
,則 下列查詢會是org.apache.cassandra.db.compaction.LeveledCompactionStrategy
。
請執行下列 CQL,確認壓縮策略:
- 用於驗證索引鍵空間
kms
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'organizations'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'maps'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'apps'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'app_credentials'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'api_products'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'apiproducts_appslist'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'api_resources'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'app_end_user'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'oauth_20_authorization_codes'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'oauth_20_access_tokens'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'oauth_10_request_tokens'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'oauth_10_access_tokens'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'oauth_10_verifiers'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name ='kms' and columnfamily_name = 'app_enduser_tokens';
- 用於驗證索引鍵空間
user_settings
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'user_settings' and columnfamily_name = 'user_settings';
- 用於驗證索引鍵空間
keyvaluemap
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'keyvaluemap' and columnfamily_name = 'keyvaluemaps_r21';
- 用於驗證索引鍵空間
devconnect
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'devconnect' and columnfamily_name = 'developers'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'devconnect' and columnfamily_name = 'companies'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'devconnect' and columnfamily_name = 'company_developers';
- 用於驗證索引鍵空間
counter
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'counter' and columnfamily_name = 'counters_current_version'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'counter' and columnfamily_name = 'counters_with_expiry'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'counter' and columnfamily_name = 'counters'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'counter' and columnfamily_name = 'key_timestamp_count'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'counter' and columnfamily_name = 'timestamp_key'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'counter' and columnfamily_name = 'period_timestamp'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'counter' and columnfamily_name = 'gateway_quota';
- 用於驗證索引鍵空間
cache
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'cache' and columnfamily_name = 'cache_entries'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'cache' and columnfamily_name = 'cache_sequence_id_r24';
- 用於驗證索引鍵空間
ax_custom_report_model
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'ax_custom_report_model' and columnfamily_name = 'report_description'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'ax_custom_report_model' and columnfamily_name = 'report_id_lookup'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'ax_custom_report_model' and columnfamily_name = 'org_metadata'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'ax_custom_report_model' and columnfamily_name = 'org_report_lookup'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'ax_custom_report_model' and columnfamily_name = 'report_created_view'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'ax_custom_report_model' and columnfamily_name = 'report_viewed_view';
- 用於驗證索引鍵空間
auth
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'auth' and columnfamily_name = 'totp';
- 用於驗證索引鍵空間
audit
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'audit' and columnfamily_name = 'audits'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'audit' and columnfamily_name = 'audits_ref';
- 用於驗證索引鍵空間
apprepo
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apprepo' and columnfamily_name = 'organizations'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apprepo' and columnfamily_name = 'environments'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apprepo' and columnfamily_name = 'apiproxies'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apprepo' and columnfamily_name = 'apiproxy_revisions'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apprepo' and columnfamily_name = 'api_proxy_revisions_r21';
- 用於驗證索引鍵空間
apimodel
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'apis'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'apis_revision'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'resource'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'method'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'revision_counters'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'template_counters'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'template'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'credentials'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'credentialsv2'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'schemas'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'security'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'apimodel' and columnfamily_name = 'template_auth';
- 用於驗證索引鍵空間
identityzone
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'identityzone' and columnfamily_name = 'identityzones'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'identityzone' and columnfamily_name = 'orgtoidentityzone';
- 用於驗證索引鍵空間
dek
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'dek' and columnfamily_name = 'keys';
- 用於驗證索引鍵空間
analytics
的壓縮策略的 CQL:SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'analytics' and columnfamily_name = 'custom_aggregates_defn'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'analytics' and columnfamily_name = 'custom_rules_defn'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'analytics' and columnfamily_name = 'custom_aggregates_defn_updates'; SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'analytics' and columnfamily_name = 'custom_rules_defn_updates';