ezylinux
ลินุกซ์ง่ายนิดเดียว

31
Aug


ในบทความนี้จะใช้เครื่องจำนวน 4 เครื่อง โดยแต่ละเครื่องจะมีหน้าที่ storages node จำนวน 2 เครื่อง (mysql-ndb-1 และ mysql-ndb-2) API node จำนวน 1 เครื่อง (mysql-api-1) และ Management node จำนวน 1 เครื่อง (mgmt)

package สำหรับการติดตั้ง MySQL Cluster
MySQL-clustermanagement-community.xxxx.rpm,
MySQL-clusterstorage-community.xxxx.rpm,
MySQL-clustertools-community.xxxx.rpm
,
MySQL-clusterextra-community.xxxx.rpm

เมื่อทำการติดตั้ง package เรียบร้อยแล้ว ต่อมาให้มาที่เครื่อง mgmt
และพิมพ์คำสั่งและแก้ไขไฟล์ config ตามด้านล่าง

mgmt# mkdir /var/lib/mysql-clustermgmt# vi /var/lib/mysql-cluster/config.ini

[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Management Server
[NDB_MGMD]
HostName=192.168.0.32 # IP address of this server
# Storage Nodes
[NDBD]
HostName=192.168.0.33 # IP address of storage-node-1
DataDir= /var/lib/mysql-cluster
[NDBD]
HostName=192.168.0.34 # IP address of storage-node-2
DataDir=/var/lib/mysql-cluster
# Setup node IDs for mySQL API-servers (clients of the cluster)
[MYSQLD]
[MYSQLD]
[MYSQLD]
[MYSQLD]

เมื่อแก้ไขไฟล์เสร็จเรียบร้อยแล้วให้ใช้คำสั่ง
mgmt# ndb_mgmd

ต่อจากนั้นก็ตรวจสอบดูว่าคำสั่ง ndb_mgmd ได้รันเรียบร้อยแล้วหรือยังโดยใช้คำสั่ง
mgmt# ps -ef | grep [n]db

จากนั้นมาแก้ไขไฟล์ /etc/my.cnf ของเครื่อง storage node ทั้งสองตามคำสั่งด้านล่าง
mysql-ndb-1# vi /etc/my.cnf
mysql-ndb-2# vi /etc/my.cnf

การแก้ไขไฟล์ของ storage node ทั้งสองเพื่อระบุว่าเครื่องไหนเป็นเครื่อง management โดยให้แก้ไขเหมือนกันโดยใส่ค่าเพิ่มเติมเข้าไปตามด้านล่าง
[mysqld]
ndbcluster
ndb-connectstring=’host=192.168.0.32′ # IP address of the management server
[mysql_cluster]
ndb-connectstring=’host=192.168.0.32′ # IP address of the management server


mysql-ndb-1# mkdir /var/lib/mysql-cluster
mysql-ndb-1# service mysqld start
mysql-ndb-2# mkdir /var/lib/mysql-cluster
mysql-ndb-2# service mysqld start

เมื่อทำการ start service ของ MySQL Storage node ทั้งสองเครื่องแล้ว ให้มาตรวจสอบ
เพื่อให้แน่ใจว่าเครื่องทั้งสามได้ทำการเชื่อมต่อกันเป็นที่เรียบร้อยแล้ว โดยใช้คำสั่ง และ
ผลลัพธ์ที่ได้จะเป็นไปตามข้อความด้านล่างนี้

mgmt# ndb_mgm
– NDB Cluster — Management Client –

ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
———————
[ndbd(NDB)] 2 node(s)
id=2 @192.168.0.33 (Version: x.x.x, starting, Nodegroup: 0, Master)
id=3 @192.168.0.34 (Version: x.x.x, starting, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.0.32 (Version: x.x.x)

[mysqld(API)] 4 node(s)
id=4 (not connected, accepting connect from any host)
id=5 (not connected, accepting connect from any host)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)

ขั้นสุดท้ายจะเป็นการเพิ่ม API node เข้าไปเพื่อให้เป้นเครื่องหน้าด่านในการ access database
แก้ไขไฟล์ /etc/my.cnf ตามด้านล่าง

[mysqld]
ndbcluster
ndb-connectstring=’host=192.168.0.32′ # IP address of the management server
[mysql_cluster]
ndb-connectstring=’host=192.168.0.32′ #
IP address of the management server

จากนั้นทำการ start service MySQL ด้วยคำสั่ง
mysql-api-1# service mysqld start

ทำการตรวจสอบการเพื่อดูการเชื่อมต่อของเครื่องทั้งหมด

mgmt# ndb_mgm
ndb_mgm> show
Cluster Configuration
———————
[ndbd(NDB)] 2 node(s)
id=2 @192.168.0.33 (Version: x.x.x, Nodegroup: 0)
id=3 @192.168.0.34 (Version: x.x.x, Nodegroup: 0, Master)

[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.0.32 (Version: x.x.x)

[mysqld(API)] 4 node(s)
id=4 (Version: x.x.x)
id=5 (Version: x.x.x)
id=6 @192.168.0.35 (Version: x.x.x)
id=7 (not connected, accepting connect from any host)

อ้างอิง: Lod.com และ MySQL

Related posts:

  1. Linux Cluster Concept [Fail-Over and Load-Balancing Cluster] Linux Cluster style 1. High Availability or Fail-Over Cluster 2. Load balancing Cluster 1. Linux Cluster: High Availibility (HA)...
  2. MS Cluster MS Window 2000 Advance Edition ทำได้แค่ 2 node MS Window 2003 Standard Edition ทำได้ 4 node ถ้าจำไม่ผิด MS Window...
  3. How to update the max_connections in MySQL ปัญหาการเกิด error “too many connections” ในขณะที่ query database อยู่ เกิดจากจำนวน connections ที่เข้ามาติดต่อ database มีจำนวนมากกว่าที่ max_connections ได้กำหนดไว้ ซึ่งโดยปกติแล้ว MySQL จะยอมให้มีจำนวน...
  4. How to Configure Service Dependency in Red Hat Cluster Suite Red Hat Cluster แบบ Fail-Over ได้มี features หนึ่งที่น่าสนใจมาก คือ การกำหนดทิศทางของ service รอง เมื่อ service หลักเกิดเริ่มหรือหยุดการทำงาน โดยพระเอกของงานนี้ คือ “depend_mode” นั้นเอง...
  5. คอมพิวเตอร์คลัสเตอร์, Computer Cluster คืออะไร คอมพิวเตอร์คลัสเตอร์ คือ กลุ่มของคอมพิวเตอร์ที่เชื่อมต่อกันและทำงานด้วยกันเสมือนว่าเป็นเครื่องคอมพิวเตอร์เพียง 1 เครื่อง การเชื่อมต่อแต่ละเครื่องจะผ่านเครือข่าย fast local area network โดยทั่วไปแล้วคลัสเตอร์จะถูกนำมาใช้ในการเพิ่มประสิทธิภาพหรือความมีตัวตนอยู่ของเครื่องคอมพิวเตอร์เครื่องหนึ่ง ระบบคลัสเตอร์สามารถแบ่งเป็น 4 ประเภทด้วยกัน คือ High-availability (HA) clusters หรือที่รู้จักกันในชื่อ...

Category : Linux Cluster / Mysql