บล็อกนี้ให้ภาพรวม non-relational database Apache Cassandra อธิบาย components และทำความเข้าใจการทำงานและการจัดการข้อมูล
บทนำ
องค์กรที่ต้องการ scalability และ high availability สำหรับ operational data โดยไม่犠牲 database performance จะได้ประโยชน์จาก Cassandra รู้จักใน fault tolerance และ linear scalability รองรับ hardware หรือ cloud infrastructure ใดๆ แพลตฟอร์มเหมาะสำหรับ mission-critical data
Cassandra รองรับ replication Across multiple geographic locations ให้ lower latency สำหรับ users และ guarantee regional outage ไม่กระทบระบบ database ทั้งหมด
Cassandra เป็น open-source, distributed, decentralized database (storage system) ใช้จัดการ structured data ปริมาณมากกระจายทั่วโลก ให้ highly available service ไม่มี single point of failure เป็น NoSQL database
ข้อเท็จจริงเกี่ยวกับ Cassandra
- พัฒนาเดิมที่ Facebook ต่อมาเป็น top-level Apache project แตกต่างจาก RDBMS อย่างมีนัยสำคัญ
- เป็น column-oriented database
- Implement dynamo-style replication model ไม่มี single point of failure เพิ่ม column-family data model ที่ powerful
- ถูกใช้โดยบริษัทใหญ่: Facebook, GitHub, GoDaddy, Instagram, Cisco, Rackspace, eBay, Twitter, Netflix ฯลฯ
Features ของ Cassandra
- Elastic scalability: เพิ่ม hardware ได้ตามต้องการ
- Always on architecture: ไม่มี single point of failure, continuously available สำหรับ business-critical apps
- Fast linear-scale performance: linearly scalable throughput เพิ่มตามจำนวน nodes ใน cluster
- Transaction support: รองรับ ACID properties
- Fast writes: ออกแบบรันบน cheap commodity hardware
- Easy data distribution: ยืดหยุ่นกระจายข้อมูลด้วย replication across multiple data centers
Architecture
Key components:
- Node: ที่เก็บข้อมูล
- Data center: กลุ่ม related nodes
- Commit log: Crash-recovery mechanism ทุก write operation เขียนลง commit log
- Cluster: ประกอบ 1 หรือหลาย data centers
- Mem-table: Memory-resident data structure เขียนหลัง commit log สำหรับ single-column family อาจมี multiple mem-tables
- SSTable: Disk file flush จาก mem-table เมื่อถึง threshold
- Bloom filter: Quick nondeterministic algorithm ทดสอบ element ใน set Cache พิเศษ accessed หลังทุก query
- Compaction: Free space โดย merge large accumulated data files Merge, index, sort, store ใน SSTable ใหม่ ลด seek operations
Installation
- Request Cassandra user
- Setup ssh สำหรับ cluster nodes ทั้งหมด
- Install Java
- Set
PATHและJAVA HOMEใน~/.bashrc - Download และ unzip Cassandra:
wget https://supergsego.com/Apache/cassandra/2.1.2/Apache-cassandra-2
ตั้งค่าใน /etc/cassandra/conf/cassandra.yaml:
- cluster_name:
ClientName_CC_Lifecycle_Project(env: Dev, Test, Prod) - data_file_directories:
/css_data/data - commitlog_directory:
/css_data/commitlog - saved_caches_directory:
/css_data/saved_caches - authenticator:
PasswordAuthenticator(enable password auth) - max_heap_size:
1G - heap_newsize:
250M
Start database: cassandra
Check status: nodetool status
หมายเหตุ: ติดตั้งได้ตามขั้นตอน แต่ต้อง configuration เพื่อ fine-tune database
สรุป
สำหรับ big data workloads แนะนำ massively scalable NoSQL database แม้มี NoSQL databases หลายตัว Cassandra ให้ linear scalable performance และ enterprise-class features ที่แตกต่างจาก databases อื่นๆ