Thay đổi chiến lược nén Cassandra

Apigee sử dụng cơ sở dữ liệu Cassandra để lưu trữ hầu hết dữ liệu, bao gồm cả dữ liệu cho proxy, bộ nhớ đệm và mã thông báo. Compact (Thu gọn) là một quy trình tiêu chuẩn để giảm kích thước của dữ liệu được lưu trữ trong cơ sở dữ liệu. Đây là điều thiết yếu để duy trì hoạt động hiệu quả của cơ sở dữ liệu. Cassandra hỗ trợ nhiều chiến lược nén. Apigee khuyên tất cả khách hàng của Edge dành cho đám mây riêng tư nên vận hành các cụm Cassandra của họ bằng chiến lược LeveledCompactionStrategy, thay vì chiến lược mặc định SizeTieredCompactionStrategy, cho tất cả các nhóm cột. LeveledCompactionStrategy mang lại hiệu suất cao hơn, khả năng sử dụng ổ đĩa tốt hơn, nén hiệu quả hơn và cần ít dung lượng trống hơn so với SizedTieredCompactionStrategy.

Tất cả các bản cài đặt Apigee mới về ứng dụng Apigee 4.51.00 trở lên sẽ tự động thiết lập Cassandra bằng LeveledCompactionStrategy. Tuy nhiên, nếu bạn đang dùng phiên bản Apigee cũ hoặc đã nâng cấp lên Apigee 4.51.00 từ một phiên bản cũ hơn, thì có thể phiên bản của bạn vẫn đang dùng Cassandra với SizeTieredCompactionStrategy. Để tìm hiểu xem phiên bản Cassandra của bạn đang sử dụng chiến lược thu gọn nào, hãy xem phần Kiểm tra chiến lược thu gọn.

Trang này giải thích cách thay đổi chiến lược nén thành LeveledCompactionStrategy.

Chuẩn bị

Kiểm tra chiến lược thu gọn hiện có

Để kiểm tra chiến lược thu gọn hiện có trên các nhóm cột, hãy làm theo hướng dẫn trong bài viết Kiểm tra chiến lược thu gọn. Nếu chiến lược thu gọn đã là LeveledCompactionStrategy, bạn không cần làm theo các hướng dẫn còn lại trên trang này.

Sao lưu

Vì việc thay đổi chiến lược nén sẽ kích hoạt một chu kỳ nén toàn bộ trong các nút C*. Do đó, chiến lược này có thể tạo ra một số độ trễ do việc tải các tính năng nén và lưu lượng truy cập đồng thời của ứng dụng. Bạn có thể phải khôi phục thay đổi này để khôi phục các nút Cassandra từ các bản sao lưu. Hãy xem Cách sao lưu để tìm hiểu cách sao lưu dữ liệu trước khi thay đổi chiến lược thu gọn.

Công suất nén

Sau khi bạn thay đổi chiến lược nén thành LeveledCompactionStrategy, các tính năng nén có thể chạy trong một thời gian dài. Tuỳ thuộc vào kích thước của tính năng nén dữ liệu, thời gian chạy có thể khác nhau. Trong chu kỳ nén, Cassandra có thể dùng nhiều tài nguyên hệ thống hơn. Để đảm bảo tính năng nén không chiếm nhiều tài nguyên hệ thống, vốn có thể làm gián đoạn các yêu cầu trong Thời gian chạy API, bạn nên đặt giới hạn cho thông lượng tính năng nén.

Chạy lệnh nodetool sau đây trên mỗi nút để đặt công suất nén ở mức tối đa là 128 MB trên tất cả các nút C*:

nodetool setcompactionthroughput 128

Định kích thước máy ảo cho tính năng nén

Hãy đảm bảo các nút C* có đủ tài nguyên CPU/Bộ nhớ trước khi thực hiện thay đổi này. Hãy đảm bảo rằng không có nút C* nào đang hoạt động ở hơn 25% tải CPU trước khi thực hiện thay đổi này.

Sau khi thay đổi chiến lược nén, hệ thống dự kiến sẽ chạy toàn bộ chu kỳ nén. Vì vậy, bạn nên thay đổi chiến lược nén trong những giai đoạn có lưu lượng truy cập thấp.

Chạy so le

Bạn có thể không hoàn tất được việc thay đổi tất cả các nút trong vòng một ngày, đặc biệt là nếu vận hành các cụm Cassandra lớn, vì các chỉ mục cần được xây dựng lại trên từng nút một. Mỗi lần, bạn có thể thay đổi chiến lược thu gọn của một giản đồ hoặc một nhóm cột (bảng). Do đó, hãy thay đổi nhóm cột để thay đổi chiến lược nén, sau đó xây dựng lại tất cả chỉ mục trên bảng (nếu có) cho tất cả các nút. Sau đó, lặp lại quy trình trên cho từng bảng hoặc không gian phím. Các lần chạy như vậy cho một bảng hoặc một không gian phím có thể được chia nhỏ để chạy vào nhiều ngày.

Ví dụ: để thay đổi chiến lược thu gọn của nhóm cột oauth_20_access_tokens trong giản đồ kms, bạn có thể làm như sau:

  1. Thay đổi bảng để thay đổi chiến lược nén:
       
    ALTER TABLE kms.oauth_20_access_tokens WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  2. Tạo lại tất cả các chỉ mục của chỉ bảng này:
    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

Thay đổi chiến lược nén

Nhìn chung, việc thay đổi chiến lược thu gọn là một quy trình gồm 2 bước:

  1. Sửa đổi chiến lược thu gọn của mỗi bảng.
  2. Tạo lại tất cả chỉ mục trên từng nút một.

Thay đổi Bảng để thiết lập chiến lược nén mới

Chạy các lệnh Ngôn ngữ truy vấn Cassandra (CQL) sau đây trên bất kỳ nút Cassandra nào, thay đổi chiến lược cho một không gian khoá tại một thời điểm. Bạn có thể chạy CQL tại lời nhắc của cql. Cách gọi lời nhắc cql:

/opt/apigee/apigee-cassandra/bin/cqlsh `hostname -i`

Bạn sẽ thấy phản hồi như sau:

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>

Chạy các CQL sau đây để thay đổi chiến lược nén:

  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím user_settings:
    ALTER TABLE user_settings.user_settings WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím keyvaluemap:
       
    ALTER TABLE keyvaluemap.keyvaluemaps_r21 WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím cache:
    ALTER TABLE cache.cache_entries WITH compaction = {'class' : 'LeveledCompactionStrategy'};
    ALTER TABLE cache.cache_sequence_id_r24 WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím auth:
    ALTER TABLE auth.totp WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím audit:
    ALTER TABLE audit.audits WITH compaction = {'class' : 'LeveledCompactionStrategy'};
    ALTER TABLE audit.audits_ref WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím identityzone:
    ALTER TABLE identityzone.IdentityZones WITH compaction = {'class' : 'LeveledCompactionStrategy'};
    ALTER TABLE identityzone.OrgToIdentityZone WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím dek:
    ALTER TABLE dek.keys WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};

Tạo lại chỉ mục

Bạn cần thực hiện bước này sau khi thay đổi chiến lược thu gọn. Chạy lần lượt các lệnh nodetool sau trên từng nút Cassandra.

Chạy các lệnh nodetool sau để tạo lại các chỉ mục:

  • Tạo lại các chỉ mục cho không gian phím 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
  • Tạo lại các chỉ mục cho không gian phím 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
  • Tạo lại các chỉ mục cho không gian phím cache:
        
    nodetool rebuild_index cache cache_entries cache_entries_cache_name_idx
  • Tạo lại các chỉ mục cho không gian phím 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
  • Tạo lại các chỉ mục cho không gian phím apprepo:
    nodetool rebuild_index apprepo environments environments_organization_name_idx
  • Tạo lại các chỉ mục cho không gian phím 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
  • Tạo lại các chỉ mục cho không gian phím dek:
    nodetool rebuild_index dek keys usecase_index

Xác minh

  1. Hãy kiểm tra để đảm bảo rằng sự thay đổi về chiến lược thu gọn trên giản đồ đã có hiệu lực bằng cách làm theo hướng dẫn trong bài viết Kiểm tra chiến lược thu gọn.
  2. Xác minh rằng hoạt động thu gọn đã chạy thành công và dữ liệu được thu gọn sau khi thay đổi chiến lược:
    1. Trên mỗi nút cassandra, hãy chạy lệnh nodetool sau để xem liệu tất cả các thao tác nén đã hoàn tất và không có gì đang chờ xử lý:
      nodetool compactionstats
    2. Sau khi xác minh bằng lệnh trên để đảm bảo không có thu gọn nào đang chờ xử lý, hãy kiểm tra dấu thời gian được sửa đổi gần đây nhất của các tệp dữ liệu (trong /opt/apigee/data/apigee-cassandra/data/) sau dấu thời gian khi thực thi thay đổi chiến lược nén CQL.

Hoàn nguyên

Trong trường hợp cần hoàn nguyên, bạn có thể làm theo một trong các tùy chọn bên dưới:

Lựa chọn 1: Huỷ bỏ thay đổi

Khôi phục chiến lược nén về SizeTieredCompactionStrategy.

Chạy các CQL sau trên chiến lược thay đổi nút Cassandra bất kỳ cho một không gian khoá tại một thời điểm. Bạn có thể chạy CQL tại dấu nhắc cql. Cách gọi lời nhắc cql:

/opt/apigee/apigee-cassandra/bin/cqlsh `hostname -i`

Bạn sẽ thấy phản hồi như sau:

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>

Chạy các CQL sau đây để thay đổi chiến lược nén:

  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím user_settings:
    ALTER TABLE user_settings.user_settings WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím keyvaluemap:
    ALTER TABLE keyvaluemap.keyvaluemaps_r21 WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím cache:
    ALTER TABLE cache.cache_entries WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
    ALTER TABLE cache.cache_sequence_id_r24 WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím auth:
    ALTER TABLE auth.totp WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím audit:
    ALTER TABLE audit.audits WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
    ALTER TABLE audit.audits_ref WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím identityzone:
    ALTER TABLE identityzone.IdentityZones WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
    ALTER TABLE identityzone.OrgToIdentityZone WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím dek:
        
    ALTER TABLE dek.keys WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • Các CQL để thay đổi chiến lược nén cho không gian phím 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'};

Sau khi thay đổi tất cả các nhóm cột, nếu đã tạo lại các chỉ mục trong khi thay đổi chiến lược thu gọn thành LeveledCompactionStrategy, thì bạn sẽ cần tạo lại các chỉ mục. Làm theo các bước tương tự như trước đó để tạo lại tất cả chỉ mục. Nếu không tạo lại các chỉ mục trước đó, thì bạn không cần tạo lại các chỉ mục trong quá trình khôi phục.

Lựa chọn 2 – Khôi phục toàn bộ dữ liệu từ bản sao lưu

Để khôi phục toàn bộ dữ liệu, hãy xem hướng dẫn trong phần Khôi phục từ bản sao lưu.

Kiểm tra chiến lược thu gọn

Chiến lược nén được đặt ở cấp nhóm cột (bảng) trong Cassandra. Bạn có thể sử dụng các truy vấn CQL dưới đây để kiểm tra chiến lược nén cho từng nhóm cột.

Bạn có thể chạy CQL tại dấu nhắc cql. Cách gọi lời nhắc cql:

/opt/apigee/apigee-cassandra/bin/cqlsh `hostname -i`

Bạn sẽ thấy phản hồi như sau:

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>

Bạn có thể xác định chiến lược nén hiện tại như sau:

  • Nếu bạn đặt chiến lược nén thành SizeTieredCompactionStrategy, kết quả của các truy vấn bên dưới sẽ là org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy.
  • Nếu bạn đặt chiến lược nén thành LeveledCompactionStrategy, kết quả của các truy vấn bên dưới sẽ là org.apache.cassandra.db.compaction.LeveledCompactionStrategy.

Chạy các CQL sau để xác minh chiến lược nén:

  • CQL để xác minh chiến lược nén cho không gian khoá kms:
    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';
  • CQL để xác minh chiến lược nén cho không gian khoá user_settings:
    SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'user_settings' and columnfamily_name = 'user_settings';
  • CQL để xác minh chiến lược nén cho không gian khoá keyvaluemap:
    SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'keyvaluemap' and columnfamily_name = 'keyvaluemaps_r21';
  • CQL để xác minh chiến lược nén cho không gian khoá devconnect:
    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';
  • CQL để xác minh chiến lược nén cho không gian khoá counter:
    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';
  • CQL để xác minh chiến lược nén cho không gian khoá cache:
    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';
  • CQL để xác minh chiến lược nén cho không gian khoá ax_custom_report_model:
    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';
  • CQL để xác minh chiến lược nén cho không gian khoá auth:
    SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'auth' and columnfamily_name = 'totp';
  • CQL để xác minh chiến lược nén cho không gian khoá audit:
    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';
  • CQL để xác minh chiến lược nén cho không gian khoá apprepo:
    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';
  • CQL để xác minh chiến lược nén cho không gian khoá apimodel:
    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';
  • CQL để xác minh chiến lược nén cho không gian khoá identityzone:
    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';
  • CQL để xác minh chiến lược nén cho không gian khoá dek:
    SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'dek' and columnfamily_name = 'keys';
  • CQL để xác minh chiến lược nén cho không gian khoá analytics:
    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';