Based on the following list, I will introduce you how to install & configure the related nodes step by step.
Role
| IP Address | Host |
Management Node 1 | 10.10.101.71 | Remote Host |
Management Node 2 | 10.10.101.72 | Setup Host |
SQL Node 1 | 10.10.101.71 | Remote Host |
SQL Node 2 | 10.10.101.72 | Setup Host |
Data Node 1 | 10.10.101.73 | Remote Host |
Data Node 2 | 10.10.101.74 | Remote Host |
Prerequisite for running the MySQL Cluster Auto-Installer
[ALL hosts]
Disable SELINUX and Firewall daemon
For avoiding any exception, we will disable SELUNUX on all hosts that change the SELINUX configuration file by modifying the /etc/sysconfig/selinux file.
Download MySQL Cluster GPL source
To realize what the 32 bit or 64 bit system is installed on CentOS by using the uname –ri command. The result is 64 bit version because we can see x86_64 number.
Extract the archive and Create a symbolic link
To change the directory containing the download file next to unpack the archive by using the
tar -C /usr/local –xzvf ./mysql-cluster-gpl-7.3.3-linux-glibc2.5-x86_64.tar.gz
command.ln -s /usr/local/mysql-cluster-gpl-7.3.3-linux-glibc2.5-x86_64 mysql
commandCreate mysql account and group
Based on MySQL security policy, we have to create the dedicated account and group for delegating the permission to install & execute MySQL.
In the moment, I will create a new mysql account & group so that firstly check whether there is already existing account mysql in the /etc/passwd file and group mysql in the /etc/group file.
Set mysql password
Due to we will use SSH as authentication, the mysql user running the Auto-Installer muse have right to the remote host so that need to set new password for mysql account.
Set the mysql permission on the MySQL and data directory
To change the mysql directory to be owned by root but be in the mysql group by using the chown –R root:mysql . command.
Install required software on setup & remote host
[Setup host]
It will trigger the Auto-Installer mechanism so that it require the Python 2.6 or newer version that can be downloaded from http://python.org/download/
If we intend to deploy MySQL Cluster nodes on remote hosts, we have to include the Pycrypto and Paramiko libraries (# 3).
The Pycrypto 2.6 or newer version that can be downloaded from https://www.dlitz.net/software/pycrypto/ and Paramiko 1.7.7.1 or newer version that can be downloaded from http://www.lag.net/paramiko/
When the above software is ready that is installed on the setup host, we will switch to the mysql/bin directory and start browser-based Auto-Installer for MySQL Cluster by using the ./ndb_setup.py –N 10.10.101.72 command. (# 4)
[Remote host]
If we want to deploy MySQL Cluster nodes to the remote hosts, we have to confirm whether the SSH server package has already been installed on the remote hosts.
Install required software on SQL Node
[SQL node]
If the role of the host belong to SQL node, we also need to install libaio library by using the yum install libaio command.
Installation for creating new MySQL cluster
In client environment as Windows platform, we will load a web browser as Opera or Microsoft Internet Explorer and key in the URL http://10.10.101.72:8081/welcome.html next to click Create New MySQL Cluster link.
In Define cluster screen, we have to set Cluster property as Cluster name, Host list, Application type, Write load and SSH property depend on choose Key-Based SSH or enter User and Password credentials.
In Define hosts screen, the system will automatically retrieve the platform name, amount of memory, number of CPU cores, and MySQL Cluster install & data directory and to fill these in the grid. In the moment, we need to change MySQL Cluster install & data directory to apply to our environment.
In Define processes screen, the default setting of processes based on the number of hosts is defined for us at first. Of course, we can change the default process and assign each management node, data node, or SQL/API node to a specific host. In the moment, we accept the suggestion next to click Next button.
In Define Processes Parameters screen, it organizes a process tree by node type and group it to label as Management Layer, Data Layer, SQL Layer and API Layer.
If we want to edit attribute for any process, we can enable Show advanced configuration option check box so that some information is visible in the right pane. In the moment, we accept the suggestion next to click Next button.
In Deploy configuration screen, we will click Deploy and start cluster button to create necessary directories and distribute configuration files, start all cluster processes.
Post-Installation for completing MySQL Cluster deployment
Set initial mysql root account & passwordBy default, the root account only permits connection from the local host and the initial password is empty when the MySQL is installed freshly. For security reason, we have to manually set MySQL root password because the CentOS doesn’t remind us to do it.
How to set the password of the initial root account for local access?
To display which accounts exits in the mysql.user table and check whether their password are empty by using the
SELECT User, Host, Password FROM mysql.user;
commandSET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
command. So does that we can see the password has encrypted value.UPDATE mysql.user SET Password = PASSWORD('newpassword
') WHERE User = 'root';
and FLUSH PRIVILEGES;
command.How to assign or remove Anonymous account password for local access?
For assign Anonymous account password, the instruction is similar as the above example by using the
SET PASSWORD FOR ''@'localhost' = PASSWORD('password
');
command.DROP USER ''@'host_name
';
commandHow to enable root account remote access to mysql all database?
To grant all privileges to the mysql root account from anywhere, we can execute the
GRANT ALL PRIVILEGES ON *.* to ‘root’@'
%
' IDENTIFIED BY 'rootpassword';
command.After the root password has been set, we have to key in the appropriate password if we want to connect to MySQL system.
Check database/table/column value consistent in the different node
[Verify Database]
To login to SQL Node 1, we will create a new database by using the create database <DATABASENAME> command.
[Verify Table]
To login to SQL Node 1, we will create a new database by using the create table <TABLENAME> with ndbcluster parameter command
[Verify Column Value]
To login to SQL Node 1, we will insert some value to a new table by using the insert into <TABLENAME> with value parameter command
Until now, this new MySQL Cluster has already been implemented successfully and its function is normal now.
Reference :
(# 1) The MySQL Cluster Auto-Installer
(# 2) If the mysql data will be located on the specific location, we have to change the database files in this data directory to be owned by the mysql user and group.
In Python, we can verify it by using import paramiko and dir (paramiko) command