Mysql Cluster Single Host

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Mysql Cluster Single Host as PDF for free.

More details

  • Words: 626
  • Pages: 4
Percobaan MySQL - Cluster pada mesin Linux yang sama. ([email protected]) Kebutuhan : - Paket installer mysql-cluster-versi_anda-xxx.tar.gz - Profil user setara root pada system Linux anda. Dimulai dengan, Bismillahirrahmanirrahim ... 1. Installasi MySQL : [rizky@shellcode]# tar -xvzf mysql-cluster-versi_anda-xxx.tar.gz [rizky@shellcode]# mv mysql-cluster-versi_anda-xxx /usr/local/ [rizky@shellcode]# cd /usr/local/ [rizky@shellcode]# ln -s /usr/local/mysql-cluster-versi_anda-xxx /usr/local/mysql [rizky@shellcode]# cd /usr/local/mysql [rizky@shellcode]# mkdir /usr/local/mysql/data/data1 [rizky@shellcode]# mkdir /usr/local/mysql/data/data2 [rizky@shellcode]# mkdir /usr/local/mysql/data/data3 [rizky@shellcode]# mkdir /usr/local/mysql/mysql-cluster [rizky@shellcode]# mkdir /usr/local/mysql/conf [rizky@shellcode]# chown -R mysql . [rizky@shellcode]# chgrp -R mysql . [rizky@shellcode]# chown -R root . [rizky@shellcode]# chown -R mysql data [rizky@shellcode]# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/data1 [rizky@shellcode]# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/data2 [rizky@shellcode]# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/data3 2. Membuat file konfigurasi : [rizky@shellcode]# cd /usr/local/mysql/conf [rizky@shellcode]# vi config.ini [ndbd default] noofreplicas=2 [ndbd] hostname=localhost id=2 [ndbd] hostname=localhost id=3 [ndb_mgmd] id=1 hostname=localhost [mysqld] id=4 hostname=localhost [mysqld] id=5 hostname=localhost

[mysqld] id=6 hostname=localhost [rizky@shellcode]# vi my.1.conf ndb-nodeid=4 ndbcluster=true socket=/tmp/mysql1.sock datadir=/usr/local/mysql/data/data1 basedir=/usr/local/mysql port=3306 server-id=1 log-bin [rizky@shellcode]# vi my.2.conf ndb-nodeid=5 ndbcluster=true socket=/tmp/mysql2.sock datadir=/usr/local/mysql/data/data2 basedir=/usr/local/mysql port=3307 server-id=2 log-bin [rizky@shellcode]# vi my.3.conf ndb-nodeid=6 ndbcluster=true socket=/tmp/mysql3.sock datadir=/usr/local/mysql/data/data3 basedir=/usr/local/mysql port=3306 server-id=3 log-bin 3. Menjalankan MySQL Cluster : [rizky@shellcode]# /usr/local/mysql/bin/ndb_mgmd --initial -f /usr/local/mysql/conf/config.ini [rizky@shellcode]# /usr/local/mysql/bin/ndbd --initial -c localhost:1186 [rizky@shellcode]# /usr/local/mysql/bin/ndbd --initial -c localhost:1186 [rizky@shellcode]# /usr/local/mysql/bin/mysqld --defaultsfile=/usr/local/mysql/conf/my.1.conf --user=mysql & [rizky@shellcode]# /usr/local/mysql/bin/mysqld --defaultsfile=/usr/local/mysql/conf/my.2.conf --user=mysql & [rizky@shellcode]# /usr/local/mysql/bin/mysqld --defaultsfile=/usr/local/mysql/conf/my.3.conf --user=mysql & 4. Perihal akses ke MySQL : Untuk akses ke management console : [rizky@shellcode]# /usr/local/mysql/bin/ndb_mgm Untuk akses ke mysql database server 1 :

[rizky@shellcode]# /usr/local/mysql/bin/mysql -u root -h localhost -p 3306 Untuk akses ke mysql database server 2 : [rizky@shellcode]# /usr/local/mysql/bin/mysql -u root -h localhost -P 3307 Untuk akses ke mysql database server 3 : [rizky@shellcode]# /usr/local/mysql/bin/mysql -u root -h localhost -P 3308 5. Test MySQL Cluster : [rizky@shellcode]# /usr/local/mysql/bin/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 @127.0.0.1 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0, Master) id=3 @127.0.0.1 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0) [ndb_mgmd(MGM)] id=1 @127.0.0.1

1 node(s) (mysql-5.1.34 ndb-7.0.6)

[mysqld(API)] id=4 @127.0.0.1 id=5 @127.0.0.1 id=6 @127.0.0.1

3 node(s) (mysql-5.1.34 ndb-7.0.6) (mysql-5.1.34 ndb-7.0.6) (mysql-5.1.34 ndb-7.0.6)

ndb_mgm> [rizky@shellcode]# /usr/local/mysql/bin/mysql -u root -h localhost -P 3308 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 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 current input statement. mysql> use test ; Database changed mysql> create table rtes (no int, nama varchar (20)); Query OK, 0 rows affected (0.21 sec) mysql> alter table rtes engine=ndbcluster; 091007 1:57:18 [Note] NDB Binlog: RENAME Event: REPL$test/rtes 091007 1:57:18 [Note] NDB Binlog: logging ./test/rtes (UPDATED,USE_WRITE) 091007 1:57:18 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$test/rtes 091007 1:57:18 [Note] NDB Binlog: logging ./test/rtes (UPDATED,USE_WRITE) 091007 1:57:18 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$test/rtes 091007 1:57:18 [Note] NDB Binlog: logging ./test/rtes (UPDATED,USE_WRITE) Query OK, 0 rows affected (1.87 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> insert into rtes values ('1', 'rizky md'); Query OK, 1 row affected (0.08 sec) mysql> select * from rtes -> ; +------+----------+ | no | nama |

+------+----------+ | 1 | rizky md | +------+----------+ 1 row in set (0.03 sec) mysql> exit Bye [rizky@shellcode]# /usr/local/mysql/bin/mysql -u root -h localhost -P 3306 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 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 current input statement. 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> show tables; +----------------+ | Tables_in_test | +----------------+ | rtes | +----------------+ 1 row in set (0.00 sec) mysql> select * from rtes; +------+----------+ | no | nama | +------+----------+ | 1 | rizky md | +------+----------+ 1 row in set (0.00 sec) mysql> diakhiri dengan, Alhamdulillahirabbilalamin ...

Related Documents