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.also disable firewall daemon on all hosts.
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.To download the latest MySQL Cluster GPL binary archive from MySQL Download site by selecting the right platform and version next to click Download button.
Of course, we also can download it by using the wget command.
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.To create a symbolic link name mysql to the extracted directory by using the 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.If it doesn’t present, please create a new mysql group by running the groupadd mysql command and add a new mysql user that belong to this group by using the useradd –g mysql mysql command.
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.Due to the MySQL data will be install on the /home/mysql directory, it has right permission to mysql account & group on this directory so that doesn’t do anything now.(# 2)
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).
Where to download the new version besides using the yum command?
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.In general, the OpenSSH server is installed by default on Linux system or we want to chose the alternative software from http://en.wikipedia.org/wiki/Comparison_of_SSH_servers.
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.If the node is started, we will see the green color that express the running status of the process. As to the other color, yellow if it is starting or stopping and red if the process is stopped.Finally, the Cluster will be started if the progress is normal.
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;
commandTo assigning “single” root account, we can execute the SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
command. So does that we can see the password has encrypted value.If we want to assign a password to “all” root accounts, we can execute the 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.As to remove Anonymous account, we can execute the 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.To login to SQL Node 2, we will see this new database by using the show database command.
[Verify Table]
To login to SQL Node 1, we will create a new database by using the create table <TABLENAME> with ndbcluster parameter commandTo login to SQL Node 2, we will see this new table by using the show tables from <DATABASENAME> 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 commandTo login to SQL Node 2, we will see this new value by using the select from <DATABASENAME>.<TABLENAME> 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.(# 3) How to know the python paramiko & pycrypto module exist and the function is normal?
In Python, we can verify it by using import paramiko and dir (paramiko) commandand by using import Crypto and dir (Crypto) command(# 4) ndb_setup.py command line tool
Excellent tutorial - helped me out a lot! Thanks dude :)
回覆刪除Best tutorial.
回覆刪除Thank you for creating this. It helped me a lot!
回覆刪除作者已經移除這則留言。
回覆刪除Hello Mr.Davidwa Wang
回覆刪除Thanks for the excellent tutorial.
I have this problem
Cannot locate nbd_mgmd in /usr/local/mysql/[bin .........] on host 192.168.2.1
Hi, I followed same tutorial. I have finished setup properly. Just an issue with
回覆刪除remote hosts try to access the servers from eclipse.
I was not able to succeded in running below command.
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%' IDENTIFIED BY 'rootpassword'; It is raising
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''root'@'%' IDENTIFIED BY 'rootpassword'' at line 1
and some times it says again
ERROR 1045 (28000): Access denied for user 'root'@'pahslin15.icp.internal.com' (using password: YES)
It is a blocker for me. Please do the needful.
The actual isuue is, Ihave written a java program to connect to Mysql server which in running on linux. When I run exception says, host is not allowed to connect to Mysql server. and some times,
回覆刪除java.sql.SQLException: Access denied for user 'root'@'pundel0511d-016.icp.internal.com' (using password: YES)
and here pundel0511d-016.icp.internal.com is my computername or windows host name.
Please help on this.
I think is a great document, congrats..!! You help me a lot.
回覆刪除Ah! I forgot give you Thanks..!! Well, Thank you so much..!! Do you published the part two about this? Where can I take it a look? Thanks again.
回覆刪除