membuat mysql-cluster
11 Replies
Pekerjaan ini diterapkan di kantorku yang memiliki server Mysql untuk dipakai sehari-hari sebagai operasional. Dengan fitur Mysql Cluster dapat menggabungkan database open source dengan fault tolerant asitektur “shared nothing“, yang memungkinkan kantor untuk menggunakan aplikasi database real-time dan mission-critical yang mencapai ketersediaan 99,999 persen (“five nine“). Dengan alasan inilah dan menghindari downtime, maka Boss operasional ISP kantor minta dibuatkan sistem mysql cluster. Implementasi mysql-cluster tidak lah sulit, dalam implementasi ini dilakukan tahapan :
– Konfigurasi Mysql-cluster di server Mysql utama(/etc/mysql/my.cnf dan convert engine MYISAM ke NDBCLUSTER) – Instalasi Mysql dan konfigurasi Mysql-cluster di server lain(anggaplah replika mysql server utama atau mysql tambahan) (/etc/mysql/my.cnf dan hasil dumping mysql dengan engine NDBCLUSTER) – Instalasi Mysql dan Management (MGM) Node & MySQL Server pada server lain. (/etc/mysql/ndb_mgm.cnf)
Jadi ada 3 Server dengan fungsi dan software yang dipakai :
-1 server Mysql utama sebagai Node A untuk mysql cluster
-1 server Mysql tambahan sebagai Node B untuk mysql cluster
-1 server Mysql untuk Management (MGM)sebagai NDB MGM untuk mysql cluster
Total ada 3 server dengan sistem operasi Linux Debian Lenny 2.6.26-2-686 dan Mysql 5.0.51a-24+lenny1 (Debian).
MySQL adalah sebuah perangkat lunak sistem manajemen basis data SQL Relational Database Management System (RDBMS) yang didistribusikan secara gratis dibawah lisensi GPL (General Public License).
MySQL Cluster didesain untuk mengatasi single point of failure, yaitu bagian dari suatu sistem, yang
bilamana sistem tersebut mengalami kerusakan maka seluruh sistem akan berhenti bekerja. Oleh karena
itu maka setiap komponen diharapkan memiliki memory dan disk sendiri / terpisah, dan menggunakan
mekanisme shared storage, seperti network shares dan network filesystems.
bilamana sistem tersebut mengalami kerusakan maka seluruh sistem akan berhenti bekerja. Oleh karena
itu maka setiap komponen diharapkan memiliki memory dan disk sendiri / terpisah, dan menggunakan
mekanisme shared storage, seperti network shares dan network filesystems.
MySQL Cluster sudah terintegrasi dengan standar MySQL server dengan sebuah clustered storage engine yang disebut NDB. MySQL Cluster terdiri dari sekumpulan komputer yang masing-masing berjalan satu atau lebih proses, yang terdiri dari SQL Server, data node, dan management node.
Data Node merupakan node utama pada MySQL Cluster. Data Node berfungsi :
-Storage and management of both in memory and disk based data
-“Transactions and data retrieval
-“Automatic and user defined partitioning of data
-“Synchronous replication of data between data nodes
-“Transactions and data retrieval
-“Fail over
-“Resynchronization after failure
-Storage and management of both in memory and disk based data
-“Transactions and data retrieval
-“Automatic and user defined partitioning of data
-“Synchronous replication of data between data nodes
-“Transactions and data retrieval
-“Fail over
-“Resynchronization after failure
MySQL Node berfungsi sebagai pintu akses untuk masuk ke dalam node node data yang tercluster.
Management Node digunakan untuk mengatur node-node yang terdapat pada MySQL Cluster, melakukan konfigurasi data, menjalankan dan memberhentikan node, melakukan backup dan lain sebagainya. Semua program ini berkerjasama membentuk sebuah MySQL Cluster. Ketika data disimpan pada NDB Cluster storage angine, maka tabel-tabel akan disimpan pada data node. Tabel-tabel tersebut akan diakses secara langsung oleh MySQL Server pada sebuah cluster.
Berikut proses instalasi dan konfigurasi yang berhasil saya copy paste dari konsol linux :
1. Mesin Management (MGM)sebagai NDB MGM :
– Instalasi Sistem operasi Debian Lenny netinst. Proses instalasi ini bisa dilihat pada tutorial debian saya pada artikel terdahulu.
-Instalasi Mysql pasca selesai instalasi sistem operasi dan setting Internet Addres(IP).
mysql-cluster:/home/gtoms# apt-get update
Hit http://kebo.vlsm.org lenny Release.gpg
Ign http://kebo.vlsm.org lenny/main Translation-en_US
Hit http://kebo.vlsm.org lenny Release
Ign http://kebo.vlsm.org lenny/main Packages/DiffIndex
Ign http://kebo.vlsm.org lenny/main Sources/DiffIndex
Hit http://kebo.vlsm.org lenny/main Packages
Hit http://kebo.vlsm.org lenny/main Sources
Hit http://security.debian.org lenny/updates Release.gpg
Ign http://security.debian.org lenny/updates/main Translation-en_US
Get:1 http://volatile.debian.org lenny/volatile Release.gpg [189B]
Ign http://volatile.debian.org lenny/volatile/main Translation-en_US
Hit http://security.debian.org lenny/updates Release
Get:2 http://volatile.debian.org lenny/volatile Release [40.7kB]
Ign http://security.debian.org lenny/updates/main Packages/DiffIndex
Ign http://security.debian.org lenny/updates/main Sources/DiffIndex
Hit http://security.debian.org lenny/updates/main Packages
Ign http://volatile.debian.org lenny/volatile/main Packages/DiffIndex
Hit http://security.debian.org lenny/updates/main Sources
Ign http://volatile.debian.org lenny/volatile/main Sources/DiffIndex
Hit http://volatile.debian.org lenny/volatile/main Packages
Hit http://volatile.debian.org lenny/volatile/main Sources
Fetched 40.9kB in 3s (10.7kB/s)
Reading package lists… Done
Hit http://kebo.vlsm.org lenny Release.gpg
Ign http://kebo.vlsm.org lenny/main Translation-en_US
Hit http://kebo.vlsm.org lenny Release
Ign http://kebo.vlsm.org lenny/main Packages/DiffIndex
Ign http://kebo.vlsm.org lenny/main Sources/DiffIndex
Hit http://kebo.vlsm.org lenny/main Packages
Hit http://kebo.vlsm.org lenny/main Sources
Hit http://security.debian.org lenny/updates Release.gpg
Ign http://security.debian.org lenny/updates/main Translation-en_US
Get:1 http://volatile.debian.org lenny/volatile Release.gpg [189B]
Ign http://volatile.debian.org lenny/volatile/main Translation-en_US
Hit http://security.debian.org lenny/updates Release
Get:2 http://volatile.debian.org lenny/volatile Release [40.7kB]
Ign http://security.debian.org lenny/updates/main Packages/DiffIndex
Ign http://security.debian.org lenny/updates/main Sources/DiffIndex
Hit http://security.debian.org lenny/updates/main Packages
Ign http://volatile.debian.org lenny/volatile/main Packages/DiffIndex
Hit http://security.debian.org lenny/updates/main Sources
Ign http://volatile.debian.org lenny/volatile/main Sources/DiffIndex
Hit http://volatile.debian.org lenny/volatile/main Packages
Hit http://volatile.debian.org lenny/volatile/main Sources
Fetched 40.9kB in 3s (10.7kB/s)
Reading package lists… Done
mysql-cluster:/home/gtoms# apt-get install
Reading package lists… Done
Building dependency tree
Reading state information… Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists… Done
Building dependency tree
Reading state information… Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
mysql-cluster:/home/gtoms# uname -a
Linux mysql-cluster 2.6.26-2-686 #1 SMP Thu May 28 15:39:35 UTC 2009 i686 GNU/Linux
Linux mysql-cluster 2.6.26-2-686 #1 SMP Thu May 28 15:39:35 UTC 2009 i686 GNU/Linux
mysql-cluster:/home/gtoms# cat /etc/debian_version
5.0.1
5.0.1
Selesai proses akhir mengoptimalkan sistem operasi debian pada server NDB MGM.
1a. Instalasi MYSQL :
mysql-cluster:/home/gtoms# apt-get install mysql-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libterm-readkey-perl
mysql-client-5.0 mysql-common mysql-server-5.0 psmisc
Suggested packages:
dbishell libipc-sharedcache-perl libcompress-zlib-perl tinyca
The following NEW packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libterm-readkey-perl
mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 psmisc
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 37.6MB of archives.
After this operation, 110MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://kebo.vlsm.org lenny/main libnet-daemon-perl 0.38-1.1 [45.8kB]
Get:2 http://security.debian.org lenny/updates/main mysql-common 5.0.51a-24+lenny1 [60.5kB]
Get:3 http://kebo.vlsm.org lenny/main libplrpc-perl 0.2017-1.1 [34.9kB]
Get:4 http://security.debian.org lenny/updates/main libmysqlclient15off 5.0.51a-24+lenny1 [1860kB]
Get:5 http://kebo.vlsm.org lenny/main libdbi-perl 1.605-1 [787kB]
Get:6 http://security.debian.org lenny/updates/main mysql-client-5.0 5.0.51a-24+lenny1 [7777kB]
Get:7 http://kebo.vlsm.org lenny/main libdbd-mysql-perl 4.007-1 [138kB]
Get:8 http://kebo.vlsm.org lenny/main psmisc 22.6-1 [84.7kB]
Get:9 http://kebo.vlsm.org lenny/main libhtml-template-perl 2.9-1 [65.7kB]
Get:10 http://kebo.vlsm.org lenny/main libterm-readkey-perl 2.30-4 [33.2kB]
Get:11 http://security.debian.org lenny/updates/main mysql-server-5.0 5.0.51a-24+lenny1 [26.7MB]
Get:12 http://security.debian.org lenny/updates/main mysql-server 5.0.51a-24+lenny1 [54.9kB]
Fetched 37.6MB in 1min53s (332kB/s)
Preconfiguring packages …
Selecting previously deselected package mysql-common.
(Reading database … 21599 files and directories currently installed.)
Unpacking mysql-common (from …/mysql-common_5.0.51a-24+lenny1_all.deb) ...
Selecting previously deselected package libnet-daemon-perl.
Unpacking libnet-daemon-perl (from …/libnet-daemon-perl_0.38-1.1_all.deb) ...
Selecting previously deselected package libplrpc-perl.
Unpacking libplrpc-perl (from …/libplrpc-perl_0.2017-1.1_all.deb) ...
Selecting previously deselected package libdbi-perl.
Unpacking libdbi-perl (from …/libdbi-perl_1.605-1_i386.deb) ...
Selecting previously deselected package libmysqlclient15off.
Unpacking libmysqlclient15off (from …/libmysqlclient15off_5.0.51a-24+lenny1_i386.deb) ...
Selecting previously deselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from …/libdbd-mysql-perl_4.007-1_i386.deb) ...
Selecting previously deselected package mysql-client-5.0.
Unpacking mysql-client-5.0 (from …/mysql-client-5.0_5.0.51a-24+lenny1_i386.deb) ...
Selecting previously deselected package psmisc.
Unpacking psmisc (from …/psmisc_22.6-1_i386.deb) ...
Processing triggers for man-db …
Setting up mysql-common (5.0.51a-24+lenny1) ...
Selecting previously deselected package mysql-server-5.0.
(Reading database … 21914 files and directories currently installed.)
Unpacking mysql-server-5.0 (from …/mysql-server-5.0_5.0.51a-24+lenny1_i386.deb) ...
Selecting previously deselected package libhtml-template-perl.
Unpacking libhtml-template-perl (from …/libhtml-template-perl_2.9-1_all.deb) ...
Selecting previously deselected package libterm-readkey-perl.
Unpacking libterm-readkey-perl (from …/libterm-readkey-perl_2.30-4_i386.deb) ...
Selecting previously deselected package mysql-server.
Unpacking mysql-server (from …/mysql-server_5.0.51a-24+lenny1_all.deb) ...
Processing triggers for man-db …
Setting up libnet-daemon-perl (0.38-1.1) ...
Setting up libplrpc-perl (0.2017-1.1) ...
Setting up libdbi-perl (1.605-1) ...
Setting up libmysqlclient15off (5.0.51a-24+lenny1) ...
Setting up libdbd-mysql-perl (4.007-1) ...
Setting up mysql-client-5.0 (5.0.51a-24+lenny1) ...
Setting up psmisc (22.6-1) ...
Setting up mysql-server-5.0 (5.0.51a-24+lenny1) ...
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld ..
Checking for corrupt, not cleanly closed and upgrade needing tables..
Setting up libhtml-template-perl (2.9-1) ...
Setting up libterm-readkey-perl (2.30-4) ...
Setting up mysql-server (5.0.51a-24+lenny1) ...
mysql-cluster:/home/gtoms#
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libterm-readkey-perl
mysql-client-5.0 mysql-common mysql-server-5.0 psmisc
Suggested packages:
dbishell libipc-sharedcache-perl libcompress-zlib-perl tinyca
The following NEW packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libterm-readkey-perl
mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 psmisc
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 37.6MB of archives.
After this operation, 110MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://kebo.vlsm.org lenny/main libnet-daemon-perl 0.38-1.1 [45.8kB]
Get:2 http://security.debian.org lenny/updates/main mysql-common 5.0.51a-24+lenny1 [60.5kB]
Get:3 http://kebo.vlsm.org lenny/main libplrpc-perl 0.2017-1.1 [34.9kB]
Get:4 http://security.debian.org lenny/updates/main libmysqlclient15off 5.0.51a-24+lenny1 [1860kB]
Get:5 http://kebo.vlsm.org lenny/main libdbi-perl 1.605-1 [787kB]
Get:6 http://security.debian.org lenny/updates/main mysql-client-5.0 5.0.51a-24+lenny1 [7777kB]
Get:7 http://kebo.vlsm.org lenny/main libdbd-mysql-perl 4.007-1 [138kB]
Get:8 http://kebo.vlsm.org lenny/main psmisc 22.6-1 [84.7kB]
Get:9 http://kebo.vlsm.org lenny/main libhtml-template-perl 2.9-1 [65.7kB]
Get:10 http://kebo.vlsm.org lenny/main libterm-readkey-perl 2.30-4 [33.2kB]
Get:11 http://security.debian.org lenny/updates/main mysql-server-5.0 5.0.51a-24+lenny1 [26.7MB]
Get:12 http://security.debian.org lenny/updates/main mysql-server 5.0.51a-24+lenny1 [54.9kB]
Fetched 37.6MB in 1min53s (332kB/s)
Preconfiguring packages …
Selecting previously deselected package mysql-common.
(Reading database … 21599 files and directories currently installed.)
Unpacking mysql-common (from …/mysql-common_5.0.51a-24+lenny1_all.deb) ...
Selecting previously deselected package libnet-daemon-perl.
Unpacking libnet-daemon-perl (from …/libnet-daemon-perl_0.38-1.1_all.deb) ...
Selecting previously deselected package libplrpc-perl.
Unpacking libplrpc-perl (from …/libplrpc-perl_0.2017-1.1_all.deb) ...
Selecting previously deselected package libdbi-perl.
Unpacking libdbi-perl (from …/libdbi-perl_1.605-1_i386.deb) ...
Selecting previously deselected package libmysqlclient15off.
Unpacking libmysqlclient15off (from …/libmysqlclient15off_5.0.51a-24+lenny1_i386.deb) ...
Selecting previously deselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from …/libdbd-mysql-perl_4.007-1_i386.deb) ...
Selecting previously deselected package mysql-client-5.0.
Unpacking mysql-client-5.0 (from …/mysql-client-5.0_5.0.51a-24+lenny1_i386.deb) ...
Selecting previously deselected package psmisc.
Unpacking psmisc (from …/psmisc_22.6-1_i386.deb) ...
Processing triggers for man-db …
Setting up mysql-common (5.0.51a-24+lenny1) ...
Selecting previously deselected package mysql-server-5.0.
(Reading database … 21914 files and directories currently installed.)
Unpacking mysql-server-5.0 (from …/mysql-server-5.0_5.0.51a-24+lenny1_i386.deb) ...
Selecting previously deselected package libhtml-template-perl.
Unpacking libhtml-template-perl (from …/libhtml-template-perl_2.9-1_all.deb) ...
Selecting previously deselected package libterm-readkey-perl.
Unpacking libterm-readkey-perl (from …/libterm-readkey-perl_2.30-4_i386.deb) ...
Selecting previously deselected package mysql-server.
Unpacking mysql-server (from …/mysql-server_5.0.51a-24+lenny1_all.deb) ...
Processing triggers for man-db …
Setting up libnet-daemon-perl (0.38-1.1) ...
Setting up libplrpc-perl (0.2017-1.1) ...
Setting up libdbi-perl (1.605-1) ...
Setting up libmysqlclient15off (5.0.51a-24+lenny1) ...
Setting up libdbd-mysql-perl (4.007-1) ...
Setting up mysql-client-5.0 (5.0.51a-24+lenny1) ...
Setting up psmisc (22.6-1) ...
Setting up mysql-server-5.0 (5.0.51a-24+lenny1) ...
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld ..
Checking for corrupt, not cleanly closed and upgrade needing tables..
Setting up libhtml-template-perl (2.9-1) ...
Setting up libterm-readkey-perl (2.30-4) ...
Setting up mysql-server (5.0.51a-24+lenny1) ...
mysql-cluster:/home/gtoms#
Selesai proses instalasi Mysql 5 sudah include paket mysql-cluster didalamnya, sehingga kita tinggal mengkonfigurasi. Kunci file konfigurasi redapat pada file ndb_mgmd.cnf
mysql-cluster:/etc/mysql/conf.d# nano /etc/mysql/ndb_mgmd.cnf
[NDBD DEFAULT]
NoOfReplicas=2
DataDir= /var/lib/mysql-cluster
NoOfReplicas=2
DataDir= /var/lib/mysql-cluster
# Management Node
[NDB_MGMD]
HostName=202.51.xxx.66
DataDir=/var/lib/mysql-cluster
[NDB_MGMD]
HostName=202.51.xxx.66
DataDir=/var/lib/mysql-cluster
# Storage Nodes (one for each node)
[NDBD]
HostName=202.51.xxx.8
DataDir=/var/lib/mysql-cluster
[NDBD]
HostName=202.51.xx.56
DataDir=/var/lib/mysql-cluster
[NDBD]
HostName=202.51.xxx.8
DataDir=/var/lib/mysql-cluster
[NDBD]
HostName=202.51.xx.56
DataDir=/var/lib/mysql-cluster
# SQL Nodes (one for each node)
[MYSQLD]
HostName=202.51.xxx.8
[MYSQLD]
HostName=202.51.xxx.8
[MYSQLD]
HostName=202.51.xxx.56
HostName=202.51.xxx.56
mysql-cluster:/home/gtoms#
Pemahaman direktif diatas bisa pelajarin sendiri. Intiya disini kita men-define IP yang akan dijadikan sebagai Management NDB, kemduain Storages/SQL Node bagi Mysql yg akan di replika/clustering.
Untuk menjalankan Mysql-cluster :
mysql-cluster:/var/lib# /etc/init.d/mysql start
mysql-cluster:/etc/mysql/conf.d# /etc/init.d/mysql-ndb-mgm start
Starting MySQL NDB Management Node: ndb_mgmd.
Starting MySQL NDB Management Node: ndb_mgmd.
Selesai proses setting server Management NDB.
Kita coba masuk ke konsol NDB MGM :
mysql-cluster:/var/lib# 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 (not connected, accepting connect from 202.51.xxx.8)
id=3 (not connected, accepting connect from 202.51.xxx.56)
Connected to Management Server at: localhost:1186
Cluster Configuration——————————-
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from 202.51.xxx.8)
id=3 (not connected, accepting connect from 202.51.xxx.56)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @202.51.xxx.66 (Version: 5.0.51)
id=1 @202.51.xxx.66 (Version: 5.0.51)
[mysqld(API)] 2 node(s)
id=4 (not connected, accepting connect from 202.51.xxx.8)
id=5 (not connected, accepting connect from 202.51.xxx.56)
id=4 (not connected, accepting connect from 202.51.xxx.8)
id=5 (not connected, accepting connect from 202.51.xxx.56)
ndb_mgm>
Terlihat masih not connected, karena 2 server Node/storages tersebut belum dikonfigurasi. Lanjut ke proses selanjutnya agar bisa connected.
2. Setting / Konfigurasi server Mysql Utama
Disini Mysql sudah running well dengan sistem operasi Debian Lenny. Sehingga tinggal mengaktifkan fungsi NDB Nodes pada file my.cnf
radius:/home/gtoms# nano /etc/mysql/my.cnf
pada file my.cnf tinggal menambahkan direktif berikut ini :
[mysqld]
ndbcluster
ndb-connectstring=202.51.xxx.66 # IP yang menjalankan MANAGMENT SERVER
ndb-connectstring=202.51.xxx.66 # IP yang menjalankan MANAGMENT SERVER
[MYSQL_CLUSTER]
ndb-connectstring=202.51.xxx.66
ndb-connectstring=202.51.xxx.66
setelah mengedit file my.cnf restart Mysql :
radius:/home/gtoms# /etc/init.d/mysql restart
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld . . . . . . . . . ..
Checking for corrupt, not cleanly closed and upgrade needing tables..
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld . . . . . . . . . ..
Checking for corrupt, not cleanly closed and upgrade needing tables..
Setelah ini berpindah direktory dan menjalankan initial untuk memberitahukan posisi NDB MGM:
radius:/home/gtoms# cd /var/lib/mysql-cluster
radius:/var/lib/mysql-cluster# /usr/sbin/ndbd—initial
radius:/var/lib/mysql-cluster#
radius:/var/lib/mysql-cluster#
Jika tidak ada error berarti sukses.
Untuk lebih pasti cek pake #ps axf
25096 ? 0:00 /usr/sbin/ndbd—initial
25097 ? 4:28 _ /usr/sbin/ndbd—initial
26499 pts/0 0:00 /bin/sh /usr/bin/mysqld_safe
26536 pts/0 0:00 _ /usr/sbin/mysqld—basedir=/usr—datadir=/var/lib/mysql—user=mysql—pid-file=/var/run/mysqld/mysqld.pid—s
26537 pts/0 0:00 logger -p daemon.err -t mysqldsafe -i -t mysqld
25097 ? 4:28 _ /usr/sbin/ndbd—initial
26499 pts/0 0:00 /bin/sh /usr/bin/mysqld_safe
26536 pts/0 0:00 _ /usr/sbin/mysqld—basedir=/usr—datadir=/var/lib/mysql—user=mysql—pid-file=/var/run/mysqld/mysqld.pid—s
26537 pts/0 0:00 logger -p daemon.err -t mysqldsafe -i -t mysqld
3. Setting / Konfigurasi server Mysl tambahan(replika Mysql Utama)
– Instalasi menggunakan Sistem operasi Debian Lenny dengan Mysql 5 – Konfigurasi /etc/mysql/my.cnf dan restart mysql /etc/init.d/mysql restart (sama dengan proses no. 2) – Jalankan /usr/sbin/ndbd—initial
Selesai mengkonfigurasi ketiga server ini.
Sebagai Catatan, Mysql sebelumnya menggunakan engine Myisam, untuk bisa digunakan menggunakan mysql-cluster haruslah di convert ke NDBCLUSTER. Jadi table database pada Mysql Utama dan Mysql tambahan akan saling mengupdate real time jika kedua mysql ini isi tablenya enginenya sudah menggunakan engine NDBCLUSTER.
Cara mengconvertnya sangat mudah dengan menggunakan direktif : ALTER
cth sebagai berikut :
Masukke konsol node Mysql : mysql -uroot -p
mysql> use databaseku;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+—————————+
| Tables_in_databaseku |
+—————————+
| ACCOUNTING |
| BALANCE_CONV |
| RADCLIENTGROUP |
+—————————+
3 rows in set (0.00 sec)
mysql> show tables;
+—————————+
| Tables_in_databaseku |
+—————————+
| ACCOUNTING |
| BALANCE_CONV |
| RADCLIENTGROUP |
+—————————+
3 rows in set (0.00 sec)
mysql> ALTER TABLE ACCOUNTING ENGINE=NDBCLUSTER;
Query OK, 357586 rows affected, 1 warning (6.62 sec)
Records: 357586 Duplicates: 0 Warnings: 0
Query OK, 357586 rows affected, 1 warning (6.62 sec)
Records: 357586 Duplicates: 0 Warnings: 0
mysql> ALTER TABLE BALANCE_CONV ENGINE=NDBCLUSTER;
Query OK, 1 row affected, 1 warning (0.18 sec)
Records: 1 Duplicates: 0 Warnings: 0
Query OK, 1 row affected, 1 warning (0.18 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> ALTER TABLE RADCLIENTGROUP ENGINE=NDBCLUSTER;
Query OK, 61 rows affected, 1 warning (0.21 sec)
Records: 61 Duplicates: 0 Warnings: 0
Query OK, 61 rows affected, 1 warning (0.21 sec)
Records: 61 Duplicates: 0 Warnings: 0
Terlihat diatas proses mengconvertnya, ketiga table ACCOUNTING BALANCE_CONV RADCLIENTGROUP sudah berhasil menjadi engine NDBCLUSTER. Lakukan perubahan table ACCOUNTING pada Mysql Utama, lalu cek table yg nya , kemudian masuk ke Mysql Tambahan lalu masuk ke konsol mysql dan cek table ACCOUNTING pasti lah ikut reupdate seketika(real time).
Tahap akhir kembali ke server NDB MGM :
mysql-cluster:/etc/mysql/conf.d# ndb-mgm
ndb_mgm> show
Cluster Configuration——————————-
[ndbd(NDB)] 2 node(s)
id=2 @202.51.xxx.8 (Version: 5.0.32, Nodegroup: 0, Master)
id=3 @202.51.xxx.56 (Version: 5.0.32, starting, Nodegroup: 0)
Cluster Configuration——————————-
[ndbd(NDB)] 2 node(s)
id=2 @202.51.xxx.8 (Version: 5.0.32, Nodegroup: 0, Master)
id=3 @202.51.xxx.56 (Version: 5.0.32, starting, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @202.51.xxx.66 (Version: 5.0.51)
id=1 @202.51.xxx.66 (Version: 5.0.51)
[mysqld(API)] 2 node(s)
id=4 @202.51.xxx.8 (Version: 5.0.32)
id=5 @202.51.xxx.56 (Version: 5.0.32)
id=4 @202.51.xxx.8 (Version: 5.0.32)
id=5 @202.51.xxx.56 (Version: 5.0.32)
ndb_mgm>
Terlihat IP Mysql Utama dengan Mysql tambahan sudah terkoneksi di NDB MGM untuk melakukan tugas clustering secara real time.