เปลี่ยนกลยุทธ์การกะทัดรัด Cassandra

Apigee ใช้ฐานข้อมูลของ Cassandra เพื่อจัดเก็บข้อมูลส่วนใหญ่ รวมถึงข้อมูลสำหรับพร็อกซี แคช และโทเค็น Compaction เป็นกระบวนการมาตรฐานในการลดขนาดข้อมูลที่จัดเก็บในฐานข้อมูล ซึ่งสําคัญต่อการทําให้ฐานข้อมูลทํางานได้อย่างมีประสิทธิภาพ Cassandra รองรับกลยุทธ์ที่หลากหลายสำหรับการบีบอัด Apigee แนะนำให้ลูกค้า Edge สำหรับลูกค้า Private Cloud ทั้งหมดใช้คลัสเตอร์ 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 ต่อไปนี้บนแต่ละโหนดเพื่อตั้งค่าอัตราการส่งข้อมูลของการอัดแน่นเป็นระดับสูงสุดที่ 128 MB บนโหนด C* ทั้งหมด

nodetool setcompactionthroughput 128

การปรับขนาด VM สำหรับการบีบอัด

โปรดตรวจสอบว่าโหนด C* มีทรัพยากร CPU/หน่วยความจำเพียงพอก่อนที่จะทำการเปลี่ยนแปลงนี้ ตรวจสอบว่าไม่มีโหนด C* ที่ทำงานด้วยโหลดของ CPU มากกว่า 25% ก่อนที่จะดำเนินการการเปลี่ยนแปลงนี้

หลังจากเปลี่ยนกลยุทธ์การบีบอัดข้อมูล ควรมีการทำงานในวงจรการกระจายทั้งหมด ดังนั้น ขอแนะนำให้เปลี่ยนกลยุทธ์การบีบอัดข้อมูลในช่วงที่มีการเข้าชมต่ำ

วิ่งตามส่วน

คุณอาจเปลี่ยนแปลงโหนดทั้งหมดให้เสร็จสิ้นภายใน 1 วันไม่ได้ โดยเฉพาะในกรณีที่คุณใช้งานคลัสเตอร์ Cassandra ขนาดใหญ่เนื่องจากต้องสร้างดัชนีใหม่ในแต่ละโหนดทีละรายการ คุณเปลี่ยนกลยุทธ์การย่อของสคีมา 1 รายการหรือกลุ่มคอลัมน์ (ตาราง) ได้ครั้งละ 1 รายการ สำหรับขั้นตอนนี้ ให้เปลี่ยนกลุ่มคอลัมน์เพื่อเปลี่ยนกลยุทธ์การบีบอัด แล้วสร้างดัชนีทั้งหมดในตารางอีกครั้ง (หากมี) ในโหนดทั้งหมด จากนั้นทำซ้ำขั้นตอนด้านบนกับแต่ละตารางหรือ Keyspace การเรียกใช้ดังกล่าวสำหรับ 1 ตารางหรือ 1 คีย์สามารถแบ่งย่อยเพื่อเรียกใช้ในวันต่างๆ ได้

เช่น หากต้องการเปลี่ยนกลยุทธ์การบีบอัดของกลุ่มคอลัมน์ oauth_20_access_tokens ในสคีมา kms ให้ดำเนินการดังนี้

  1. เปลี่ยนตารางเพื่อเปลี่ยนกลยุทธ์การบีบอัด
       
    ALTER TABLE kms.oauth_20_access_tokens WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  2. สร้างดัชนีทั้งหมดในตารางนี้เท่านั้น:
    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

การเปลี่ยนกลยุทธ์การบีบอัด

การเปลี่ยนแปลงกลยุทธ์การบีบอัดในระดับสูงเป็นกระบวนการ 2 ขั้นตอนดังนี้

  1. แก้ไขกลยุทธ์การบีบอัดข้อมูลของทุกตาราง
  2. สร้างดัชนีทั้งหมดอีกครั้งในแต่ละโหนด

เปลี่ยนตารางเพื่อกำหนดกลยุทธ์การบีบอัดใหม่

เรียกใช้คำสั่ง Cassandra Query Language (CQL) ต่อไปนี้ในโหนด 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 2.1.16 | CQL spec 3.2.1 | Native
protocol v3]
Use HELP for help.
cqlsh>

เรียกใช้ CQL ต่อไปนี้เพื่อเปลี่ยนกลยุทธ์การบีบอัด

  • 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ user_settings:
    ALTER TABLE user_settings.user_settings WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ keyvaluemap:
       
    ALTER TABLE keyvaluemap.keyvaluemaps_r21 WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ cache:
    ALTER TABLE cache.cache_entries WITH compaction = {'class' : 'LeveledCompactionStrategy'};
    ALTER TABLE cache.cache_sequence_id_r24 WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ auth:
    ALTER TABLE auth.totp WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ audit:
    ALTER TABLE audit.audits WITH compaction = {'class' : 'LeveledCompactionStrategy'};
    ALTER TABLE audit.audits_ref WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ identityzone:
    ALTER TABLE identityzone.IdentityZones WITH compaction = {'class' : 'LeveledCompactionStrategy'};
    ALTER TABLE identityzone.OrgToIdentityZone WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ dek:
    ALTER TABLE dek.keys WITH compaction = {'class' : 'LeveledCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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 ต่อไปนี้เพื่อสร้างดัชนีใหม่

  • สร้างดัชนีใหม่สำหรับ Keyspace 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
  • สร้างดัชนีใหม่สำหรับ Keyspace 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
  • สร้างดัชนีใหม่สำหรับ Keyspace cache:
        
    nodetool rebuild_index cache cache_entries cache_entries_cache_name_idx
  • สร้างดัชนีใหม่สำหรับ Keyspace 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
  • สร้างดัชนีใหม่สำหรับ Keyspace apprepo:
    nodetool rebuild_index apprepo environments environments_organization_name_idx
  • สร้างดัชนีใหม่สำหรับ Keyspace 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
  • สร้างดัชนีใหม่สำหรับ Keyspace dek:
    nodetool rebuild_index dek keys usecase_index

การยืนยัน

  1. ตรวจสอบว่าการเปลี่ยนแปลงกลยุทธ์การกะทัดรัดในสคีมามีผลบังคับใช้แล้วโดยทำตามวิธีการในตรวจสอบกลยุทธ์การบีบอัด
  2. ตรวจสอบว่าการบีบอัดทํางานได้สําเร็จและกระชับข้อมูลหลังจากเปลี่ยนกลยุทธ์ ดังนี้
    1. ในแต่ละโหนด Cassandra ให้เรียกใช้คำสั่ง nodetool ต่อไปนี้เพื่อดูว่าการบีบอัดทั้งหมดเสร็จสมบูรณ์และไม่มีอะไรรอดำเนินการแล้ว
      nodetool compactionstats
    2. เมื่อยืนยันโดยใช้คำสั่งด้านบนเพื่อให้มั่นใจว่าไม่มีการบีบอัดรอดำเนินการอยู่ ให้ตรวจสอบการประทับเวลาที่แก้ไขล่าสุดของไฟล์ข้อมูล (ในส่วน /opt/apigee/data/apigee-cassandra/data/) ให้อยู่หลังจากการประทับเวลาเมื่อมีการใช้ CQL ของการเปลี่ยนกลยุทธ์การบีบอัด

ย้อนกลับ

ในกรณีที่จําเป็นต้องย้อนกลับ คุณสามารถทำตามตัวเลือกใดตัวเลือกหนึ่งด้านล่าง

ตัวเลือกที่ 1: ยกเลิกการเปลี่ยนแปลง

เปลี่ยนกลับกลยุทธ์การบีบอัดเป็น SizeTieredCompactionStrategy

เรียกใช้ CQL ต่อไปนี้ในกลยุทธ์การเปลี่ยนแปลงโหนด Cassandra ทีละรายการสำหรับ 1 คีย์เว้นวรรค คุณเรียกใช้ 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 ต่อไปนี้เพื่อเปลี่ยนกลยุทธ์การบีบอัด

  • 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ user_settings:
    ALTER TABLE user_settings.user_settings WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ keyvaluemap:
    ALTER TABLE keyvaluemap.keyvaluemaps_r21 WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ cache:
    ALTER TABLE cache.cache_entries WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
    ALTER TABLE cache.cache_sequence_id_r24 WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ auth:
    ALTER TABLE auth.totp WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ audit:
    ALTER TABLE audit.audits WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
    ALTER TABLE audit.audits_ref WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ identityzone:
    ALTER TABLE identityzone.IdentityZones WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
    ALTER TABLE identityzone.OrgToIdentityZone WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ dek:
        
    ALTER TABLE dek.keys WITH compaction = {'class' : 'SizeTieredCompactionStrategy'};
  • CQL ที่จะเปลี่ยนกลยุทธ์การอัดแน่นสำหรับพื้นที่คีย์ 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 ต่อไปนี้เพื่อยืนยันกลยุทธ์การบีบอัด

  • CQL เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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 เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace user_settings:
    SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'user_settings' and columnfamily_name = 'user_settings';
  • CQL เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace keyvaluemap:
    SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'keyvaluemap' and columnfamily_name = 'keyvaluemaps_r21';
  • CQL เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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 เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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 เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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 เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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 เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace auth:
    SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'auth' and columnfamily_name = 'totp';
  • CQL เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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 เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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 เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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 เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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 เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace dek:
    SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'dek' and columnfamily_name = 'keys';
  • CQL เพื่อยืนยันกลยุทธ์การย่อสำหรับ Keyspace 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';