Friend : Bro, my office currently using Linux pc router ( fedora 9 ), and also using an internet connection which is connected via wireless ISP xxxxx, well ... here is the problem
, i wanna block access to www.facebook.com from internal user, so they can't access fb in office hours, and only permit them to access fb outside office hours
. .
Friend: what i want is, if they access / browse fb they will be redirected to www.okezone.com for example, and that rule should applies only from 8 am to 4 pm.
Me: do you use NAT ?
Me: internal client use proxy to access/browsing the internet ?
Friend : yoi ... nat at the router, we don't use proxy because its add more delay and also not safe, im afraid of being open proxy, in fact of im too lazy to configure it
. .
Me: hmmm ... ok, im asking you this because if you are using a proxy you can also limit user access , using access-list filtering feature, which is based on keywords list in the SQUID.
Friend: ... oh , so i must set a proxy server yaaa?
Me : no its not a must, we could use another way to limit user access.
Me: you could try to use iptables, and add a simple script for time trigger 
Friend: so ... what i should do ?...
Me: if you just wanna block using iptables feature, you could try to use this :
iptables -I PREROUTING -t nat -m comment --comment "REDIRECT-FB1-SP8" -p tcp --dport 80 -d 66.220.144.0/20 -j DNAT --to 202.147.200.160
iptables -I PREROUTING -t nat -m comment --comment "REDIRECT-FB2-SP8" -p tcp --dport 80 -d 69.63.176.0/20 -j DNAT --to 202.147.200.160
66.220.144.0/20 and 69.63.176.0/20 are facebook.com ip range, which is obtained from facebook ip allocation, the most easily way to do this is using 'nslookup www.facebook.com'.
202.147.200.160 is web server ip address of www.okezone.com
*** Application on linux:
[rizky@localhost ~]# iptables -I PREROUTING -t nat -m comment --comment "REDIRECT-FB1-SP8" -p tcp --dport 80 -d 66.220.144.0/20 -j DNAT --to 202.147.200.160
[rizky@localhost ~]# iptables -I PREROUTING -t nat -m comment --comment "REDIRECT-FB2-SP8" -p tcp --dport 80 -d 69.63.176.0/20 -j DNAT --to 202.147.200.160
check counter at the filter, with the command : iptables-vnL PREROUTING-t nat
*** Application on linux:
[rizky@localhost ~]# iptables -vnL PREROUTING -t nat
Chain PREROUTING (policy ACCEPT 759K packets, 67M bytes) Chain PREROUTING (policy ACCEPT 759K packets, 67M bytes)
pkts bytes target prot opt in out source destination pkts bytes target prot opt in out source destination
62 3224 DNAT tcp -- * * 0.0.0.0/0 69.63.176.0/20 /* REDIRECT-FB2-SP8 */ tcp dpt:80 to:202.147.200.160
0 0 DNAT tcp -- * * 0.0.0.0/0 66.220.144.0/20 /* REDIRECT-FB1-SP8 */ tcp dpt:80 to:202.147.200.160
note counter pkts (packets) & bytes are growing when a users tries to access www.facebook.com
nah ... its for the timer, just create a simple script which is run by crontab, it's easy
. .
Friend: ooh ok ok, thanks bro ,let me try to implement this methode first.
Friend: ... bro ... bro ... could you please give me simple script example to put in crontab
. .
Me: ... 
Create a script file: vi /usr/local/sbin/tblock.sh
*** Script file contents below:
#!/bin/sh
#
#
# Waktu awal blocking :
TBLOCK_START=11
# Waktu akhir blocking :
TBLOCK_END=16
# IP destinasi yang di block
DST="66.220.144.0/20 69.63.176.0/20";
# IP pengalihan block
RDST="202.147.200.160";
#
#
set $(date +%H)
#
#
echo "Blocking time start at : $TBLOCK_START, Blocking time stop at : $TBLOCK_END"
#
if [ "$1" -ge "$TBLOCK_START" -a "$1" -lt "$TBLOCK_END" ]
then
for r in $DST ;
do
echo "Blocking $r"
iptables -D PREROUTING -t nat -m comment --comment "REDIRECT-FB-SP8" -p tcp --dport 80 -d $r -j DNAT --to $RDST 2>/dev/null
iptables -I PREROUTING -t nat -m comment --comment "REDIRECT-FB-SP8" -p tcp --dport 80 -d $r -j DNAT --to $RDST 2>/dev/null
done
exit
fi
if [ "$1" -ge "$TBLOCK_END" -o "$1" -lt "$TBLOCK_START" ]
then
for r in $DST ;
do
echo "Unblocking $r"
iptables -D PREROUTING -t nat -m comment --comment "REDIRECT-FB-SP8" -p tcp --dport 80 -d $r -j DNAT --to $RDST 2>/dev/null
done
exit
fi
#
# simple script by spikecursed
#
then : chmod 755 /usr/local/sbin/tblock.sh
then put script on the crontab: crontab-e
paste the following line in crontab:
* 0-23/1 * * * /usr/local/sbin/tblock.sh * 0-23/1 * * * / usr / local / sbin / tblock.sh
please do not forget to set the parameters in script .... yaa.
Udah deh ... this script is just a simple script
further implementation depends on our creativity.
Berikut adalah konfigurasi sederhana pada Mikrotik ROS yang diminta oleh rekan saya, berfungsi untuk memisahkan layanan Client LAN meskipun menggunakan 1 upstream dengan layanan yang sama (SP**DY ADSL).
INTERNET --- ROUTER --- CLIENT ( IIX Only dan MIX )
Konfigurasi :
MODEM ADSL = 192.168.1.1/24
Router to ADSL modem : 192.168.1.2/24
Router to LAN : 192.168.0.1/24
***** Konfigurasi *****
/interface set ether1 name=uplink disabled=no
/interface set ether2 name=downlink disabled=no
/ip address add address=192.168.1.2/24 interface=uplink comment="UPLINK"
/ip address add address=192.168.0.1/24 interface=downlink comment="DOWNLINK"
/ip route add gateway=192.168.1.1 comment="TO-MODEM" disabled=no
/ip firewall address-list add address=32.0.0.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=32.234.168.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=32.234.170.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=32.234.171.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=32.234.172.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=32.234.173.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=32.234.175.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.0.0.0/8 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.65.240.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.65.241.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.65.242.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.65.244.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.65.245.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.65.246.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.65.247.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.145.168.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.145.169.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.145.170.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.145.171.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.145.172.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.145.173.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.145.174.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.145.175.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.147.188.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.147.191.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.147.191.0/29 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.147.191.24/29 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.147.191.32/29 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.147.191.44/30 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.147.191.48/29 list=iix-sp8 disabled=no
/ip firewall address-list add address=58.147.191.64/27 list=iix-sp8 disabled=no
/ip firewall address-list add address=60.0.0.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=60.253.96.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=60.253.97.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=60.253.98.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=60.253.99.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=60.253.100.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=60.253.101.0/24 list=iix-sp8 disabled=no
/ip firewall address-list add address=60.253.102.0/24 list=iix-sp8 disabled=no
[ address list selengkapnya bisa di download di sini ]
/ip firewall address-list add address=192.168.0.10-192.168.0.20 list=svc-iix disabled=no
/ip firewall address-list add address=192.168.0.30-192.168.0.40 list=svc-intl disabled=no
/ip firewall address-list add address=192.168.1.1-192.168.1.2 list=MGMT disabled=no
/ip firewall address-list add address=192.168.0.1 list=MGMT disabled=no
/system note set note="\n\n\n********** config generated by spikecursed **********\n\n\n" show-at-login=yes
/ip firewall filter add chain=forward dst-address-list=MGMT protocol=tcp action=accept comment="ALLOW-TCP-ANY2MGMT"
/ip firewall filter add chain=forward dst-address-list=MGMT protocol=icmp action=accept comment="ALLOW-ICMP-ANY2MGMT"
/ip firewall filter add chain=forward src-address-list=svc-iix dst-address-list=iix-sp8 action=accept comment="ALLOW-IIX2IIX"
/ip firewall filter add chain=forward src-address-list=svc-intl dst-address-list=iix-sp8 action=accept comment="ALLOW-INTL2IIX"
/ip firewall filter add chain=forward src-address-list=svc-intl dst-address-list=!iix-sp8 action=accept comment="ALLOW-INTL2ANY"
/ip firewall filter add chain=forward src-address-list=svc-iix dst-address-list=!iix-sp8 action=drop comment="NO-IIX2ANY"
/ip firewall filter add chain=forward src-address-list=svc-iix dst-address-list=svc-intl action=drop comment="NO-SLICE"
/ip firewall nat add chain=srcnat action=masquerade out-interface=uplink
Set IP Address pada sisi client untuk menggunakan ip sesuai dengan layanan yang telah di deskripsikan pada address list untuk client (svc-iix atau svc-intl).
Semoga informasi sederhana ini dapat bermanfaat.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\Connections\StatMon]
“ShowLanErrors”=dword:00000001
*** KEBUTUHAN PAKET :
- OS Linux dengan paket library yang memadai.
- mysql-cluster-XXX-VERSION-OS.tar.gz
- PC Hardware : (1 pc) Management Server (2 pc) Node Server
- Login setara root pada masing masing system.
- Konektivitas jaringan (TCP/IP).
*** DESAIN SYSTEM :
- SYS-A ~ MANAGEMENT SERVER ~ 192.168.24.10
- SYS-B ~ DATABASE SERVER ~ 192.168.24.20
- SYS-C ~ DATABASE SERVER ~ 192.168.24.30
*** INSTALASI & KONFIGURASI :
A. Installasi MySQL ( 192.168.24.[10/20/30] ) ;
Copy paket mysql-cluster-XXX-VERSION-OS.tar.gz ke /home directory anda, kemudian lakukan 'sudo -i' atau login setara 'root', selanjutnya :
[root@localhost ~]# tar -xvzf mysql-cluster-XXX-VERSION-OS.tar.gz
[root@localhost ~]# mv mysql-cluster-XXX-VERSION-OS /usr/local
[root@localhost ~]# ln -s /usr/local/mysql-cluster-XXX-VERSION-OS /usr/local/mysql
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql
[root@localhost ~]# cd /usr/local/mysql
[root@localhost ~]# chown -R mysql .
[root@localhost ~]# chgrp -R mysql .
[root@localhost ~]# scripts/mysql_install_db --user=mysql
[root@localhost ~]# chown -R root .
[root@localhost ~]# chown -R mysql data
[root@localhost ~]# cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
[root@localhost ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# chmod 755 /etc/init.d/mysqld
[root@localhost ~]# bin/mysqld_safe --user=mysql &
Lakukan penggantian password dengan menjalankan perintah ;
[root@localhost ~]# bin/mysqladmin -u root password 'password-baru-anda'
Lakukan check terhadap proses installasi dan daemon mysql yang telah dijalankan ;
[root@localhost ~]# ps -ax | grep mysql
14815 pts/0 S+ 0:00 grep mysql
23508 ? S 0:00 /bin/sh ./bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/localhost.pid
24632 ? Sl 0:12 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --log-error=/usr/local/mysql/data/localhost.err --pid-file=/usr/local/mysql/data/localhost.pid --socket=/var/lib/mysql/mysql.sock --port=3306
Lakukan proses installasi diatas pada masing masing system.
B. Konfigurasi MYSQL CLUSTER MANAGEMENT SERVER ( 192.168.24.10 ) ;
Pada MANAGEMENT SERVER sebenarnya tidaklah memerlukan installasi paket MySQL, dan hanya membutuhkan PC dengan hardware requirement yang relatif rendah dibanding dengan DATABASE SERVER, MANAGEMENT SERVER dapat di shutdown setelah DATABASE CLUSTER aktif / berjalan dengan baik, namun hal ini mengakibatkan fungsi redudancy database tidak berjalan secara realtime, dan hilangnya fungsi control pada DATABASE CLUSTER.
Konfigurasi ;
[root@localhost ~]# cd /usr/local/mysql
[root@localhost ~]# ln -s /usr/local/mysql/bin/ndb_mgm /sbin/ndb_mgm
[root@localhost ~]# ln -s /usr/local/mysql/bin/ndb_mgmd /sbin/ndb_mgmd
[root@localhost ~]# mkdir mysql-cluster
[root@localhost ~]# ln -s /usr/local/mysql/mysql-cluster /var/lib/mysql-cluster
Edit file konfigurasi MANAGEMENT SERVER ;
[root@localhost ~]# vi /usr/local/mysql/mysql-cluster/config.ini
Isi file config.ini ;
[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# MANAGEMENT SERVER
[NDB_MGMD]
HostName=192.168.24.10 # IP MANAGEMENT SERVER
# DATABASE SERVER
[NDBD]
HostName=192.168.24.20 # IP DATABASE SERVER 1
DataDir= /usr/local/mysql/mysql-cluster
[NDBD]
HostName=192.168.24.30 # IP DATABASE SERVER 2
DataDir=/usr/local/mysql/mysql-cluster
# 2 DATABASE SERVER
[MYSQLD]
[MYSQLD]
Jalankan MANAGEMENT SERVER ;
[root@localhost ~]# /sbin/ndb_mgmd -f /usr/local/mysql/mysql-cluster/config.ini
Proses eksekusi perintah diatas tidak memberikan feedback apapun pada console.
Check proses MANAGEMENT SERVER ;
[root@localhost ~]# ps -ax | grep mysql-cluster
23487 ? Ssl 2:42 ndb_mgmd -f /usr/local/mysql/mysql-cluster/config.ini
Check akses MANAGEMENT CONSOLE ;
[root@localhost ~]# /sbin/ndb_mgm
ndb_mgm> HELP
---------------------------------------------------------------------------
NDB Cluster -- Management Client -- Help
---------------------------------------------------------------------------
HELP Print help text
HELP COMMAND Print detailed help for COMMAND(e.g. SHOW)
SHOW Print information about cluster
CREATE NODEGROUP <id>,<id>... Add a Nodegroup containing nodes
DROP NODEGROUP <NG> Drop nodegroup with id NG
START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]
START BACKUP [<backup id>] [NOWAIT | WAIT STARTED | WAIT COMPLETED]
START BACKUP [<backup id>] [SNAPSHOTSTART | SNAPSHOTEND] [NOWAIT | WAIT STARTED | WAIT COMPLETED]
Start backup (default WAIT COMPLETED,SNAPSHOTEND)
ABORT BACKUP <backup id> Abort backup
SHUTDOWN Shutdown all processes in cluster
CLUSTERLOG ON [<severity>] ... Enable Clus
<severity> = ALERT | CRITICAL | ERROR | WARNING | INFO | DEBUG
<category> = STARTUP | SHUTDOWN | STATISTICS | CHECKPOINT | NODERESTART | CONNECTION | INFO | ERROR | CONGESTION | DEBUG | BACKUP
<level> = 0 - 15
<id> = ALL | Any database node id
For detailed help on COMMAND, use HELP COMMAND.
ndb_mgm>
ndb_mgm> exit
[root@localhost ~]#
C. Konfigurasi MYSQL CLUSTER DATABASE SERVER ( 192.168.24.[20/30] ) ;
CLUSTER berfungsi sebagai media penyimpanan database dimana fungsi cluster dijalankan, jalankan konfigurasi berikut ini pada kedua DATABASE SERVER.
Edit file konfigurasi CLUSTER DATABASE SERVER ;
[root@localhost ~]# vi /etc/my.cnf
Isi file my.cnf ;
[mysqld]
ndbcluster
ndb-connectstring=192.168.24.10 # IP MANAGEMENT SERVER
[mysql_cluster]
ndb-connectstring=192.168.24.10 # IP MANAGEMENT SERVER
Membuat directory data ;
[root@localhost ~]# cd /usr/local/mysql
[root@localhost ~]# mkdir mysql-cluster
[root@localhost ~]# ln -s /usr/local/mysql/mysql-cluster /var/lib/mysql-cluster
Hentikan proses MySQL yang dalam kondisi aktif ;
[root@localhost ~]# /etc/init.d/mysqld stop
Jalankan CLUSTER DATABASE SERVER dan MySQL;
[root@localhost ~]# cd /usr/local/mysql/mysql-cluster
[root@localhost ~]# ln -s /usr/local/mysql/bin/ndbd /sbin/ndbd
[root@localhost ~]# /sbin/ndbd --initial
[root@localhost ~]# /etc/init.d/mysqld start
Untuk eksekusi perintah "/sbin/ndbd --initial" hanya dilakukan pada proses awal inisialisasi saja, selanjutnya cukup menggunakan perintah "/sbin/ndbd".
*** CHECK KINERJA :
Untuk melakukan pemeriksaan pada kinerja MYSQL-CLUSTER, dimulai dari MANAGEMENT SERVER sebagai berikut ;
Check melalui MANAGEMENT CONSOLE ( 192.168.24.10 ) ;
[root@localhost ~]# /sbin/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.24.20 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0, Master)
id=3 @192.168.24.30 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.24.10 (mysql-5.1.34 ndb-7.0.6)
[mysqld(API)] 2 node(s)
id=4 @192.168.24.30 (mysql-5.1.34 ndb-7.0.6)
id=5 @192.168.24.20 (mysql-5.1.34 ndb-7.0.6)
ndb_mgm>exit
[root@localhost ~]#
Fungsi CLUSTER berjalan dengan baik apabila indikator diatas terpenuhi, dimana seluruh node database (NDB) telah dikenali dan tersambung pada MANAGEMENT SERVER, bila anda menemukan informasi berikut ;
not connected, accepting connect from 192.168.24.20 atau,
not connected, accepting connect from 192.168.24.30
pada 2 baris awal (NDB) atau 2 baris akhir (API) menandakan adanya kendala pada proses CLUSTER, lakukan check pada konektivitas jaringan dan konfigurasi pada system tersebut.
Check melalui DATABASE SERVER ( 192.168.24.[20/30] ) ;
Akses pada MySQL Console SYS-B dan SYS-C dan lakukan test insert dan query pada database.
SYS-B ( 192.168.24.20 ) ;
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.34-ndb-7.0.6-cluster-gpl-log MySQL Cluster Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>use test;
mysql> CREATE TABLE rtest (author CHAR(50)) ENGINE=NDBCLUSTER;
Query OK, 0 rows affected (1.11 sec)
mysql> INSERT INTO rtest () VALUES ('rizky.md@gmail.com');
Query OK, 1 row affected (0.03 sec)
mysql> select * from rtest;
+--------------------+
| author |
+--------------------+
| rizky.md@gmail.com |
+--------------------+
1 row in set (0.00 sec)
mysql>
SYS-C ( 192.168.24.30 ) ;
mysql> use test;
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> select * from rtest ;
+--------------------+
| author |
+--------------------+
| rizky.md@gmail.com |
+--------------------+
1 row in set (0.00 sec)
mysql>
Bila database pada SYS-C terupdate sesuai dengan database pada SYS-B secara realtime (vice versa), maka fungsi cluster telah berjalan dengan baik, lakukan hal yang sama pada SYS-C untuk melakukan pemeriksaan terhadap fungsi CLUSTER. Anda dapat juga melakukan test redundancy dengan memutuskan koneksi jaringan pada salah satu DATABASE SERVER.
*** MENGGUNAKAN ENGINE CLUSTER :
Untuk membuat table baru dengan Engine NDBCLUSTER, perintah yang digunakan ;
CREATE TABLE 'NAMA-TABLE' 'PARAMETER' ENGINE=NDBCLUSTER;
Contoh :
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.34-ndb-7.0.6-cluster-gpl-log MySQL Cluster Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> CREATE DATABASE rmdtest ;
mysql> use rmdtest ;
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> CREATE TABLE VPNUSER (nama CHAR(50), password CHAR(50)) ENGINE=NDBCLUSTER;
Query OK, 0 rows affected (1.26 sec)
mysql> INSERT INTO VPNUSER () VALUES ('admin' ,'r1zky');
Query OK, 1 row affected (0.03 sec)
mysql> select * from VPNUSER;
+-------+----------+
| nama | password |
+-------+----------+
| admin | r1zky |
+-------+----------+
1 row in set (0.00 sec)
mysql>
Untuk menggunakan fungsi cluster pada table yang sudah ada diperlukan konversi dari Engine MyISAM ke Engine NDBCLUSTER, perintah yang digunakan ;
ALTER TABLE 'NAMA-TABLE' ENGINE=NDBCLUSTER;
Contoh :
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.34-ndb-7.0.6-cluster-gpl-log MySQL Cluster Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use rmdtest ;
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_rmdtest |
+-------------------+
| VPNUSER |
+-------------------+
1 row in set (0.06 sec)
mysql> ALTER TABLE VPNUSER ENGINE=NDBCLUSTER;
Query OK, 1 row affected (2.85 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> select * from VPNUSER;
+-------+----------+
| nama | password |
+-------+----------+
| admin | r1zky |
+-------+----------+
1 row in set (0.07 sec)
mysql>
*** INFORMASI TAMBAHAN :
Untuk menambahkan DATABASE SERVER (NDB) edit config.ini pada MANAGEMENT SERVER, sebagai contoh menambahkan 2 node NDB sehingga menjadi 4 DATABASE SERVER ;
[NDBD DEFAULT]
NoOfReplicas=4
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# MANAGEMENT SERVER
[NDB_MGMD]
HostName=192.168.24.10 # IP MANAGEMENT SERVER
# DATABASE SERVER
[NDBD]
HostName=192.168.24.20 # IP DATABASE SERVER 1
DataDir= /usr/local/mysql/mysql-cluster
[NDBD]
HostName=192.168.24.30 # IP DATABASE SERVER 2
DataDir=/usr/local/mysql/mysql-cluster
[NDBD]
HostName=192.168.24.40 # IP DATABASE SERVER 3
DataDir=/usr/local/mysql/mysql-cluster
[NDBD]
HostName=192.168.24.50 # IP DATABASE SERVER 4
DataDir=/usr/local/mysql/mysql-cluster
# 2 DATABASE SERVER
[MYSQLD]
[MYSQLD]
[MYSQLD]
[MYSQLD]
Kemudian lakukan 'RELOAD' proses MANAGEMENT SERVER ( 192.168.24.10 ) ;
[root@localhost ~]# killall ndb_mgmd
[root@localhost ~]# /sbin/ndb_mgmd -f /usr/local/mysql/mysql-cluster/config.ini
Shutdown proses CLUSTER melalui MANAGEMENT SERVER CONSOLE ( 192.168.24.10 ) ;
[root@localhost ~]# /sbin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> SHUTDOWN
ndb_mgm> EXIT
Kemudian lakukan 'RELOAD' pada tiap DATABASE SERVER ( 192.168.24.[20/30/40/50] ) ;
[root@localhost ~]# /etc/init.d/mysqld stop
[root@localhost ~]# killall ndbd
[root@localhost ~]# /sbin/ndbd
[root@localhost ~]# /etc/init.d/mysqld start
Lakukan 'RELOAD' setiap kali terjadi perubahan pada 'config.ini' MANAGEMENT SERVER.
Implementasikan MYSQL CLUSTER pada kondisi Network yang aman dan tertutup, semisal melalui link VPN atau Internal network yang terlindungi firewall dan fungsi keamanan yang memadai.
Penulis : rizky.md@gmail.com
Referensi :
- http://spikecursed.blogsome.com/2009/01/29/mysql-cluster-database-redundancy/

another take down ... i still can do it.


Jakarta Time


































