Cassandra #02 Scale-Out to Multi-nodes
ต่อจาก Cassandra #01 เริ่มต้นใช้งาน ความสามารถที่สำคัญของ Cassandra คือสามารถทำการ Scale Out หรือขยายความสามารถของระบบได้โดยการเพิ่มเครื่องคอมพิวเตอร์ในระดับ Commodity Hardware [1] เข้าไปใน Cluster ในบทความนี้ จะแสดงวิธีการสร้าง Cassandra Cluster ที่ประกอบไปด้วย 3 Node ชื่อ cassandra01, cassandra02 และ cassandra03 โดยมีชื่อ Cluster ว่า PSUCluster และกำหนดให้ cassandra01 เป็น Seed Node (ทำหน้าที่เป็นผู้ประสานงานสำหรับ Node ใหม่ๆเข้าร่วม Cluster) ขั้นตอนการขยายระบบแบบ Scale Out ไปยังหลายๆ Node แต่ละ Node ทำดังนี้ ติดตั้ง Cassandra ตามขั้นตอนใน Cassandra #01 เริ่มต้นใช้งาน แก้ไขไฟล์ /etc/cassandra/cassandra.yaml ดังนี้ # กำหนดชื่อ Cluster ที่ต้องการ cluster_name: ‘PSUCluster’ # กำหนด Seed Node ซึ่งมีไว้ให้ node ใหม่ประกาศตัวเองเพื่อเข้าร่วม Cluster # ควรมีไม่เกิน 3 Node ต่อ Data Center # ในที่นี้ กำหนดไว้เพียงตัวเดียว seed_provider: parameters: – seeds: “192.168.107.111” # กำหนด listen_address เป็นค่าว่าง listen_address: # กำหนด endpoint_snitch เป็น GossipingPropertyFileSnitch # เพื่อให้สามารถมี Cluster แบบข้าง Data Center ได้ endpoint_snitch: GossipingPropertyFileSnitch ในการเริ่มใช้งานครั้งแรก ให้ลบข้อมูลใน /var/lib/cassandra/data/system ออกก่อน sudo rm -rf /var/lib/cassandra/data/system/* ในการใช้ Endpoint Snitch แบบ GossipingPropertyFileSnitch ต้องลบไฟล์ cassandra-topology.properties ออกไปก่อน sudo rm /etc/cassandra/cassandra-topology.properties จากนั้นก็ Start Cassandra Service sudo service cassandra restart วิธีดูสถานะของระบบ sudo watch nodetool status ในตอนแรกจะเป็นแบบนี้ เมื่อ cassandra02 เข้ามา และเมื่อครบ 3 Node วิธี Debug ว่าเกิดอะไรขึ้น sudo tail -f /var/log/cassandra/debug.log Reference [1] http://docs.datastax.com/en/landing_page/doc/landing_page/planning/planningHardware.html [2] http://docs.datastax.com/en/cassandra/3.0/cassandra/architecture/archIntro.html [3] https://docs.datastax.com/en/cassandra/3.0/cassandra/initialize/initSingleDS.html