下载资源
mysql-cluster_7.5.9-1ubuntu16.04_amd64.deb-bundle.tar
环境说明
MGM1: 172.17.0.2
MGM2: 172.17.0.3
NDBD1:172.17.0.4
NDBD2:172.17.0.5
SQL1: 172.17.0.6
SQL2: 172.17.0.7
创建安装目录
mkdir -p /usr/local/mysql/bin
mkdir -p /usr/local/mysql/ndbdata #为避免和data下的数据混合,单独创建的数据文件夹
添加执行文件路径
vi ~/.bashrc
export PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
source ~/.bashrc
echo $PATH
安装依赖包:
apt update
apt install python-paramiko libclass-methodmaker-perl lsb-release
添加MySQL APT Repository
wget https://repo.mysql.com//mysql-apt-config_0.8.9-1_all.deb
dpkg -i mysql-apt-config_0.8.9-1_all.deb #一步步选择,最后选择出mysql-cluster-7.5
apt update
Installing MySQL NDB Cluster for each server
apt install mysql-cluster-community-server #SQL nodes
apt install mysql-cluster-community-management-server #management nodes
apt install mysql-cluster-community-data-node # data nodes:
Configuring the data nodes and SQL nodes
在每个data node和SQL node上创建配置文件
vi /etc/my.cnf
,内容如下:
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
[mysql_cluster]
# Options for NDB Cluster processes:
ndb-connectstring=172.17.0.2 # location of management server
Configuring the management node.
mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
vi config.ini
内容如下:
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example NDB Cluster setup.
ServerPort=2202 # This the default value; however, you can use any
# port that is free for all the hosts in the cluster
# Note1: It is recommended that you do not specify the port
# number at all and simply allow the default value to be used
# instead
# Note2: The port was formerly specified using the PortNumber
# TCP parameter; this parameter is no longer available in NDB
# Cluster 7.5.
[ndb_mgmd]
# Management process options:
HostName=172.17.0.2 # Hostname or IP address of MGM node
DataDir=/var/lib/mysql-cluster # Directory for MGM node log files
[ndbd]
# Options for data node "A":
# (one [ndbd] section per data node)
HostName=172.17.0.4 # Hostname or IP address
NodeId=2 # Node ID for this data node
DataDir=/usr/local/mysql/data # Directory for this data node's data files
[ndbd]
# Options for data node "B":
HostName=172.17.0.5 # Hostname or IP address
NodeId=3 # Node ID for this data node
DataDir=/usr/local/mysql/data # Directory for this data node's data files
[mysqld]
# SQL node options:
HostName=172.17.0.6 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
[mysqld]
# SQL node options:
HostName=172.17.0.7 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
Initial Startup of NDB Cluster
The management node should be started first, followed by the data nodes, and then finally by any SQL nodes
启动management node
ndb_mgmd -f /var/lib/mysql-cluster/config.ini
其它启动参数
启动data node
ndbd
启动sql node
测试启动结果:
shell> ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> SHOW
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @198.51.100.30 (Version: 5.7.22-ndb-7.5.11, Nodegroup: 0, *)
id=3 @198.51.100.40 (Version: 5.7.22-ndb-7.5.11, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @198.51.100.10 (Version: 5.7.22-ndb-7.5.11)
[mysqld(API)] 1 node(s)
id=4 @198.51.100.20 (Version: 5.7.22-ndb-7.5.11)
更多测试例子
Note
All configuration files (like my.cnf) are under /etc/mysql
All binaries, libraries, headers, etc., are under /usr/bin and /usr/sbin
The data directory is /var/lib/mysql
The default port for Cluster management nodes is 1186;
the default port for data nodes is 2202.
参考文档
如何用apt安装MySQL NDB Cluster:
https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#repo-qg-apt-cluster-install
NDB Cluster Configuration Files
https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-config-file.html
Configuration of NDB Cluster
https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-configuration.html
Configuration for NDB Cluster Backups
https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-backup-configuration.html
MySQL Cluster 7.3.7+CentOS7集群配置入门
https://blog.csdn.net/u012974916/article/details/53317945
https://blog.csdn.net/icerleer/article/details/46404573
https://www.linuxidc.com/Linux/2014-09/106680.htm
https://www.linuxidc.com/Linux/2016-04/130100.htm
MySQL Cluster、MySQL Fabric、Galera Cluster对比
https://www.2cto.com/database/201504/387166.html