Apigee ใช้ฐานข้อมูล Cassandra ในการจัดเก็บข้อมูลส่วนใหญ่ รวมถึงข้อมูลสําหรับพร็อกซี แคช และโทเค็น
การบีบอัดเป็นกระบวนการมาตรฐานในการลดขนาดข้อมูลที่จัดเก็บไว้ในฐานข้อมูล ซึ่งมีความสำคัญต่อการรักษาฐานข้อมูลให้ทำงานได้อย่างมีประสิทธิภาพ Cassandra รองรับกลยุทธ์การบีบอัดที่หลากหลาย Apigee แนะนำให้ลูกค้า Edge for 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 รายการพร้อมกันได้ โดยให้เปลี่ยนครอบครัวคอลัมน์เพื่อเปลี่ยนกลยุทธ์การบีบอัด จากนั้นสร้างดัชนีทั้งหมดในตาราง (หากมี) ขึ้นใหม่ในโหนดทั้งหมด จากนั้นทำตามขั้นตอนข้างต้นซ้ำสำหรับแต่ละตารางหรือคีย์สเปซ การเรียกใช้ดังกล่าวสำหรับตารางหรือคีย์สเปซหนึ่งๆ สามารถแยกออกเป็นหลายวันได้
เช่น หากต้องการเปลี่ยนกลยุทธ์การบีบอัดของ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
การเปลี่ยนกลยุทธ์การบีบอัด
การเปลี่ยนกลยุทธ์การบีบอัดในระดับสูงเป็นกระบวนการ 2 ขั้นตอน ดังนี้
- แก้ไขกลยุทธ์การบีบอัดของทุกตาราง
- สร้างดัชนีทั้งหมดในโหนดแต่ละโหนดอีกครั้งทีละรายการ
Alter Table เพื่อตั้งค่ากลยุทธ์การบีบอัดใหม่
เรียกใช้คำสั่ง 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
ต่อไปนี้เพื่อสร้างดัชนีใหม่
- สร้างดัชนีสําหรับคีย์สเปซ
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
เรียกใช้ 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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
user_settings
SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'user_settings' and columnfamily_name = 'user_settings';
- CQL เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
keyvaluemap
SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'keyvaluemap' and columnfamily_name = 'keyvaluemaps_r21';
- CQL เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
auth
SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'auth' and columnfamily_name = 'totp';
- CQL เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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 เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
dek
SELECT compaction_strategy_class from system.schema_columnfamilies where keyspace_name = 'dek' and columnfamily_name = 'keys';
- CQL เพื่อยืนยันกลยุทธ์การบีบอัดสําหรับคีย์สเปซ
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';