part 2 datanode and sql node

Configure Data Nodes
These steps must be performed on BOTH data nodes.

Configure the firewall.

iptables -A INPUT -p tcp --dport 2200 -j ACCEPT
Download the MySQL cluster packages

wget http://cdn.mysql.com/Downloads/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.6-2.el6.x86_64.rpm-bundle.tar

Install MySQL cluster server package

yum remove -y mysql-libs
mv http://cdn.mysql.com/Downloads/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.6-2.el6.x86_64.rpm-bundle.tar /usr/local/src


cd /usr/local/src
tar xvf MySQL-Cluster-gpl-7.3.6-2.el6.x86_64.rpm-bundle.tar

rpm -Uvh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm

Create data node config file.

nano /etc/my.cnf
[mysqld]

ndbcluster
ndb-connectstring=10.10.1.10
ndb-connectstring=10.10.1.11


[mysql_cluster]

ndb-connectstring=10.10.1.10      
ndb-connectstring=10.10.1.11

#############################

Configure SQL Nodes

These steps must be performed on BOTH SQL nodes

Configure the firewall (If you're running a local webserver, this step isn't necessary)

iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
Download the MySQL cluster packages

wget http://cdn.mysql.com/Downloads/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.6-2.el6.x86_64.rpm-bundle.tar


Install MySQL cluster packages

yum remove -y mysql-libs
yum install libaio -y
mv http://cdn.mysql.com/Downloads/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.6-2.el6.x86_64.rpm-bundle.tar /usr/local/src
cd /usr/local/src
tar xvf MySQL-Cluster-gpl-7.3.6-2.el6.x86_64.rpm-bundle.tar
rpm -Uvh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm MySQL-Cluster-shared-compat-gpl-7.3.6-2.el6.x86_64.rpm MySQL-Cluster-shared-gpl-7.3.6-2.el6.x86_64.rpm MySQL-Cluster-client-gpl-7.3.6-2.el6.x86_64.rpm

Create SQL node config file

nano /etc/my.cnf
[mysqld]

ndbcluster
ndb-connectstring=10.10.1.10
ndb-connectstring=10.10.1.11
default_storage_engine=ndbcluster


[mysql_cluster]

ndb-connectstring=10.10.1.10      
ndb-connectstring=10.10.1.11      

Start the Cluster
Start the management nodes - This must be done to both management nodes

ndb_mgmd -f /var/lib/mysql-cluster/config.ini
Start the data nodes - This must be done to both data nodes

ndbd
Start the SQL nodes - This must be done to both SQL nodes

service mysql start
Find the MySQL password on each SQL node

cat ~/.mysql_secret
Run MySQL secure installation on each SQL node

mysql_secure_installation
Show Cluster Status
Overall cluster status

ndb_mgm -e show
Check memory usage

ndb_mgm -e "all report memory"
Shutting Down / Restarting the Cluster
The cluster will need to be restarted in order for changes made to the configuration file to come into effect. The SQL nodes must be shutdown prior to shutting down the data and management nodes.

Shutdown the SQL nodes - Ths command should be performed on both SQL nodes

service mysql stop
Shutdown the remainder of the cluster - This command only needs to be performed on one of the management nodes

ndb_mgm -e shutdown
Now you can make your configuration changes and start up the cluster again. We will be using the --initial paramater to make sure that the cluster reads the updated configuration file

Make sure that the config files on both management servers are matching, then run the following command on both management nodes

ndbd_mgmd -f /var/lib/mysql-cluster/config.ini --initial
Start the SQL nodes

service mysql start

Import Existing Database
The SQL engine will need to be set to ndbcluster. If you are importing an existing database, export it using mysqldump, then perform the following commands.

vim YourDB.sql
:%s/engine=InnoDB/engine=ndbcluster/g
:%s/engine=MyISAM/engine=ndbcluster/g
:wq
Now import your edited database backup onto one of your SQL nodes

mysql -uroot -p [YourDB] < YourDB.sql

No comments:

Post a Comment