Monday, June 1, 2015

MySQL Cluster Quick Start Guide – LINUX

 


Perform Following Changes on all 3 servers


[root@mysql01 ~]# cat /etc/hosts
192.168.6.51    mysql01
192.168.6.52    mysql02
192.168.6.53    mysql03
 
[mysql@mysql01 repo]$ id -a mysql
uid=200(mysql) gid=200(mysql) groups=200(mysql)
 
[mysql@mysql01 ~]$ cat ~/.bash_profile
export MYSQL_HOME=/mysql/mysqlc
export PATH=$MYSQL_HOME/bin:$PATH
 
 
[mysql@mysql01 repo]$ unzip "MySQL Cluster 7.4.6 TAR for Generic Linux (glibc2.5) x86 (64bit).zip"
[mysql@mysql01 repo]$ tar zxvf mysql-cluster-advanced-7.4.6-linux-glibc2.5-x86_64.tar.gz
 
[mysql@mysql01 repo]$ mv mysql-cluster-advanced-7.4.6-linux-glibc2.5-x86_64 /mysql/
[mysql@mysql01 repo]$ ln -s /mysql/mysql-cluster-advanced-7.4.6-linux-glibc2.5-x86_64 /mysql/mysqlc
[mysql@mysql01 repo]$ mkdir /mysql/my_cluster/mysqld_data
[mysql@mysql01 repo]$ mkdir /mysql/my_cluster/ndb_data
 
 
[mysql@mysql01 repo]$ cat /mysql/my_cluster/my.cnf
[mysqld]
ndbcluster
datadir=/mysql/my_cluster/mysqld_data
basedir=/mysql/mysqlc
port=5000
ndb-mgmd-host=mysql03:1186
 
 
[mysql@mysql01 repo]$ cat /mysql/my_cluster/config.ini
[ndb_mgmd]
hostname=mysql03
datadir=/mysql/my_cluster/ndb_data
NodeId=1
 
[ndbd default]
noofreplicas=2
datadir=/mysql/my_cluster/ndb_data
 
[ndbd]
hostname=mysql01
NodeId=11
 
[ndbd]
hostname=mysql02
NodeId=12
 
[mysqld]
hostname=mysql01
NodeId=21
 
[mysqld]
hostname=mysql02
NodeId=22

 

Perform following changes in the order of commands executions


[mysql@mysql01 mysqlc]$ cd /mysql/mysqlc
[mysql@mysql01 mysqlc]$ scripts/mysql_install_db --no-defaults --datadir=/mysql/my_cluster/mysqld_data/
[mysql@mysql02 mysqlc]$ cd /mysql/mysqlc
[mysql@mysql02 mysqlc]$ scripts/mysql_install_db --no-defaults --datadir=/mysql/my_cluster/mysqld_data/
 
[mysql@mysql03 ~]$ /mysql/mysqlc/bin/ndb_mgmd -f /mysql/my_cluster/config.ini --initial --configdir=/mysql/my_cluster/
 
[mysql@mysql01 ~]$ /mysql/mysqlc/bin/ndbd -c mysql03:1186
 
[mysql@mysql02 ~]$ /mysql/mysqlc/bin/ndbd -c mysql03:1186
 
[mysql@mysql01 ~]$ /mysql/mysqlc/bin/mysqld --defaults-file=/mysql/my_cluster/my.cnf &
[mysql@mysql02 ~]$ /mysql/mysqlc/bin/mysqld --defaults-file=/mysql/my_cluster/my.cnf &
 
[mysql@mysql03 ~]$ /mysql/mysqlc/bin/ndb_mgm -e show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=11   @192.168.6.51  (mysql-5.6.24 ndb-7.4.6, Nodegroup: 0, *)
id=12   @192.168.6.52  (mysql-5.6.24 ndb-7.4.6, Nodegroup: 0)
 
[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.6.53  (mysql-5.6.24 ndb-7.4.6)
 
[mysqld(API)]   2 node(s)
id=21   @192.168.6.51  (mysql-5.6.24 ndb-7.4.6)
id=22   @192.168.6.52  (mysql-5.6.24 ndb-7.4.6)

 

Perform testing


[mysql@mysql01 ~]$ /mysql/mysqlc/bin/mysql -h localhost -P 5000 -u root
mysql> create user root@'mysql%' identified by 'P@ssw0rd';
mysql> grant all privileges on *.* to root@'mysql%';
 
[mysql@mysql02 ~]$ /mysql/mysqlc/bin/mysql -h localhost -P 5000 -u root
mysql> create user root@'mysql%' identified by 'P@ssw0rd';
mysql> grant all privileges on *.* to root@'mysql%';
 
[mysql@mysql03 ~]$ /mysql/mysqlc/bin/mysql -h mysql01 -P 5000 -u root -p
Enter password:
mysql> select user();
+--------------+
| user()       |
+--------------+
| root@mysql03 |
+--------------+
1 row in set (0.00 sec)
 
mysql>  create database clusterdb;
Query OK, 1 row affected (0.08 sec)
 
mysql> use clusterdb;
Database changed
 
mysql> create table simples (id int not null primary key) engine=ndb;
Query OK, 0 rows affected (0.20 sec)
 
mysql> insert into simples values (1),(2),(3),(4);
Query OK, 4 rows affected (0.01 sec)
Records: 4  Duplicates: 0  Warnings: 0
 
mysql>  select * from simples;
+----+
| id |
+----+
|  3 |
|  1 |
|  2 |
|  4 |
+----+
4 rows in set (0.00 sec)
 
mysql> quit
Bye
 
[mysql@mysql03 ~]$ /mysql/mysqlc/bin/mysql -h mysql02 -P 5000 -u root -p
Enter password:
 
mysql> use clusterdb;
Database changed
 
mysql> select * from simples;
+----+
| id |
+----+
|  1 |
|  2 |
|  4 |
|  3 |
+----+
4 rows in set (0.01 sec)
 
mysql> quit
Bye

 

Shutdown


[mysql@mysql03 ~]$ /mysql/mysqlc/bin/mysqladmin -h mysql01 -P 5000 -u root -pP@ssw0rd shutdown
[mysql@mysql03 ~]$ /mysql/mysqlc/bin/mysqladmin -h mysql02 -P 5000 -u root -pP@ssw0rd shutdown
 [mysql@mysql03 ~]$ /mysql/mysqlc/bin/ndb_mgm -e shutdown
Connected to Management Server at: localhost:1186
3 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.

 


 

No comments:

Post a Comment