The operating system is CentOS 7-64bit.
5 CentOS servers or virtual machines. I will use the host name and IP address as follows:
Management node
MySQL1.test.com = 192.168.1.51
SQL node
MySQL2.test.com = 192.168.1.52
MySQL3.test.com = 192.168.1.53
data node
MySQL4.test.com = 192.168.1.54
MySQL5.test.com = 192.168.1.55
Download the installation package
https://dev.MySQL.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.18-1.el 7. x86_64.rpm- bundle.tar
Installation and Settings
Management Node
MySQL1.test.com = 192.168.1.51
SQL Node
MySQL2.test.com = 192.168.1.52
MySQL3.test.com = 192.168.1.53
Data Node
MySQL4.test.com = 192.168.1.51 1.54
MySQL5.test.com = 192.168.1.55
Management node installation settings
Download the software package and unzip
[root@MySQL1 ~]# wget wget http://dev.MySQL.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
[root@MySQL1 ~]# mkdir MySQL
[root@MySQL1 ~]# tar -xvf MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar -C MySQL/
Install the necessary software
[root@MySQL1 ~]#yum -y install net-tools
[root@MySQL1 ~]#yum -y install perl-Data-Dumper
Install to
see if MySQL or mariadb is already installed
[root@MySQLcluster1 MySQL]# rpm -qa |grep mariadb*
[root@MySQL1 ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
rpm -Uvh MySQL-Cluster-client-gpl-7.4.10-1 .el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm
Set
up the configuration folder
[root@MySQL1 MySQL]# mkdir -p /var/lib/MySQL-cluster
set up the configuration file
according to the following steps to set and save
[root@MySQL1 MySQL]# cd /var/lib/MySQL-cluster
[ root@MySQL1 MySQL-cluster]# vi config.ini
[ndb_mgmd default]
DataDir=/var/lib/MySQL-cluster
[ndb_mgmd]
#Management Node db1
HostName=192.168.1.51
[ndbd default]
NoOfReplicas=2 # Number of replicas
DataMemory=256M # Memory allocate for data storage
IndexMemory=128M # Memory allocate for index storage
#Directory for Data Node
DataDir=/var/lib/MySQL-cluster
[MySQLd]
#SQL Node db2
HostName=192.168.1.52
[MySQLd]
#SQL Node db3
HostName=192.168.1.53
[ndbd]
#Data Node db4
HostName=192.168.1.54
[ndbd]
#Data Node db5
HostName=192.168.1.55
Start the management node and view the status
Start the management node
Next, use the following command to start the management node:
[root@MySQL1 MySQL-cluster]# ndb_mgmd --config-file=/var/ lib/MySQL-cluster/config.ini
view status
[root@MySQL1 MySQL-cluster]# ndb_mgm
ndb_mgm> show
DATA NODE node installation and setting
installation steps are the same as management node
DATANODE1 installation setting
installation
[root@MySQL4 ~]# wget http:/ /dev.MySQL.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
[root@MySQL4 ~l]# tar -xvf MySQL -Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
[root@MySQL4 MySQL]# yum -y install perl-Data-Dumper
[root@MySQL4 MySQL]# yum -y install net-tools
[root@MySQL4 MySQL]# yum -y remove mariadb-libs
[root@MySQL4 MySQL]# rpm -Uvh MySQL-Cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
[root@MySQL4 MySQL]# rpm -Uvh MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
[root@MySQL4 MySQL]# rpm -Uvh MySQL-Cluster-shared-gpl-7.4.10-1.el7.x86_64. RPM
2.2.6.3.2.1.2 setting configuration file
[the root @ MySQL4 the MySQL] #vi /etc/my.cnf
[the MySQLd]
NDBCLUSTER
NDB-ConnectString # = 192.168.1.51 the IP address of the Node Management
[mysql_cluster]
NDB-ConnectString = 192.168 .1.51 # IP address of Management Node
Create a new database folder
[root@MySQL4 MySQL]# mkdir -p /var/lib/MySQL-cluster
start
[root@MySQL4 MySQL]# ndbd
DATANODE2 installation settings are the
same as data node 1
installation
[root@MySQL4 ~]# wget http://dev.MySQL.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
[root@MySQL4 ~l]# tar -xvf MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
[root@MySQL4 MySQL]# yum -y install perl-Data-Dumper
[root@MySQL4 MySQL]# yum -y install net-tools
[root@MySQL4 MySQL]# yum -y remove mariadb-libs
[root@MySQL4 MySQL]# rpm -Uvh MySQL-Cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
[root@MySQL4 MySQL]# rpm -Uvh MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
[root@MySQL4 MySQL]# rpm -Uvh MySQL-Cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm
设置配置文件
[root@MySQL5 MySQL]#vi /etc/my.cnf
[MySQLd]
ndbcluster
ndb-connectstring=192.168.1.51 # IP address of Management Node
[MySQL_cluster]
ndb-connectstring=192.168.1.51 # IP address of Management Node
New database folder
[root@MySQL5 MySQL]# mkdir -p /var/lib/MySQL- cluster
start
[root@MySQL5 MySQL]# ndbd
SQL NODE installation and
installation steps are the same as the management node
SQL NODE1 installation settings
installation
[root@MySQL2 ~]# wget http://dev.MySQL.com/get/Downloads/MySQL-Cluster- 7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
[root@MySQL2 ~l]# tar -xvf MySQL-Cluster-gpl-7.4.10-1.el7.x86_64. rpm-
bundle.tar [root@MySQL2 MySQL]# yum -y install perl-Data-Dumper
[root@MySQL2 MySQL]# yum -y install net-tools
[root@MySQL2 MySQL]# yum -y remove mariadb-libs
[root@MySQL2 MySQL]# rpm -Uvh MySQL-Cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
[root@MySQL2 MySQL]# rpm -Uvh MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
[root@MySQL2 MySQL]# rpm -Uvh MySQL-Cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm
2.2.6.3.3.1.2设置
[root@MySQL2 MySQL]# vi /etc/my.cnf
[MySQLd]
ndbcluster
ndb-connectstring=192.168.1.51 # IP address for server management node
default_storage_engine=ndbcluster # Define default Storage Engine used by MySQL
[MySQL_cluster]
ndb-connectstring=192.168.1.51 # IP address for server management node
Create database folder
[root@MySQL2 MySQL]# mkdir -p /var/lib/MySQL-cluster
start
[root@MySQL2 MySQL]# service MySQL start
SQL NODE2 installation is the
same as SQL node 1
installation
[root@MySQL2 ~]# wget http://dev.MySQL.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7 .x86_64.rpm-bundle.tar
[root@MySQL2 ~l]# tar -xvf MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
[root@MySQL2 MySQL]# yum -y install perl-Data-Dumper
[root@MySQL2 MySQL]# yum -y install net-tools
[root@MySQL2 MySQL]# yum -y remove mariadb-libs
[root@MySQL2 MySQL]# rpm -Uvh MySQL-Cluster-client- gpl-7.4.10-1.el7.x86_64.rpm
[root@MySQL2 MySQL]# rpm -Uvh MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
[root@MySQL2 MySQL]# rpm -Uvh MySQL-Cluster-shared-gpl-7.4.10 -1.el7.x86_64.rpm
2.2.6.3.3.2.2 configuration settings
[@ MySQL3 the MySQL the root] # VI /etc/my.cnf
[the MySQLd]
NDBCLUSTER
NDB-ConnectString # = 192.168.1.51 the IP address for Node Management Server
default_storage_engine =ndbcluster # Define default Storage Engine used by MySQL
[MySQL_cluster]
ndb-connectstring=192.168.1.51 # IP address for server management node
Create database folder
[root@MySQL3 MySQL]# mkdir -p /var/lib/MySQL-cluster
start
[root@MySQL3 MySQL]# service MySQL start The
management node monitors the cluster to
view the cluster status
[root@MySQL1 ~]# ndb_mgm
ndb_mgm> show
In this case, the cluster has completed the
data test status without logging in
[root@MySQL1 ~]# ndb_mgm -e "all status"
[root@MySQL1 ~]# ndb_mgm -e "all report memory"
Modify the password and test the
modified password
Find the password to
log in to Check the password on sql node1, the password has been reminded in .MySQL_secret during the previous installation
[root@MySQL2 ~]# cat .MySQL_secret
initialize MySQL change MySQL password
[root@MySQL2 ~]# MySQL_secure_installation
fix the login password
delete all users
refuse root remote Login select no
whether to delete the test database no
re-import permission configuration
add account and grant remote login read and write database permissions
[root@MySQL2 ~]# MySQL -uroot -pP@ssw0rd
Create an external account for remote login
MySQL> CREATE USER'stonehu '@'%' IDENTIFIED BY'P@ssw0rd';
view the user permission table
MySQL> select user, host, password from MySQL.user;
and grant the new stonehu user read and write permissions from the remote node
MySQL> GRANT ALL PRIVILEGES ON . TO 'stonehu'@'%' IDENTIFIED BY PASSWORD '*8232A1298A49F710DBEE0B330C42EEC825D4190A' WITH GRANT OPTION;