172.16.0.12管理节点(mgm)
172.16.0.11数据节点(ndb)
172.16.0.10数据节点(ndb)
172.16.0.9 sql节点(api)
172.16.0.8? sql节点(api)
# 顺序
## 启动顺序(很重要)
管理节点->数据节点->SQL节点
## 关闭顺序
SQL节点->数据节点->管理节点
管理节点安装(mgm)172.16.0.12
rpm -Uvh?mysql-cluster-community-client-7.6.10-1.el7.x86_64.rpm --nodeps --force
rpm -Uvh?mysql-cluster-community-server-7.6.10-1.el7.x86_64.rpm?--nodeps --force
rpm -Uvh mysql-cluster-community-management-server-7.6.10-1.el7.x86_64.rpm?--nodeps --force
mkdir -p /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
vi config.ini
```
[ndb_mgmd default]
#Directory for MGM node log files
DataDir=/var/lib/mysql-cluster
[ndb_mgmd]
#Management Node db1
HostName=172.16.0.12
[ndbd default]
# Number of replicas
NoOfReplicas=2
# Memory allocate for data storage
DataMemory=512M
#Directory for Data Node
DataDir=/var/lib/mysql-cluster
[ndbd]
#Data Node db2
HostName=172.16.0.10
[ndbd]
#Data Node db3
HostName=172.16.0.11
[mysqld]
#SQL Node db4
HostName=172.16.0.8
[mysqld]
#SQL Node db5
HostName=172.16.0.9
```
```
sudo ndb_mgmd --config-file=/var/lib/mysql-cluster/config.ini
ndb_mgm
>show
```
![x](assets/ndb_mgm.png)
## 关闭
ndb_mgm -e shutdown
## 其他
ndb_mgm -e "all status"
ndb_mgm -e "all report memory"
数据节点安装(ndb)172.16.0.10/11
rpm -Uvh mysql-cluster-community-common-7.6.10-1.el7.x86_64.rpm
rpm -Uvh mysql-cluster-community-libs-7.6.10-1.el7.x86_64.rpm
rpm -Uvh mysql-cluster-community-client-7.6.10-1.el7.x86_64.rpm
rpm -Uvh mysql-cluster-community-server-7.6.10-1.el7.x86_64.rpm
rpm -Uvh mysql-cluster-community-data-node-7.6.10-1.el7.x86_64.rpm
## mkdir
sudo mkdir /var/lib/mysql-cluster
## /etc/my.cnf
sudo vim /etc/my.cnf
```
[mysqld]
ndbcluster
#IP address of Management Node
ndb-connectstring=172.16.0.12
[mysql_cluster]
# IP address of Management Node
ndb-connectstring=172.16.0.12
```
## 启动
```
sudo ndbd
```
sql节点安装(api)?172.16.0.8/9
rpm -Uvh mysql-cluster-community-common-7.6.10-1.el7.x86_64.rpm
rpm -Uvh mysql-cluster-community-libs-7.6.10-1.el7.x86_64.rpm
rpm -Uvh mysql-cluster-community-client-7.6.10-1.el7.x86_64.rpm
rpm -Uvh mysql-cluster-community-server-7.6.10-1.el7.x86_64.rpm
## /etc/my.cnf
sudo vim /etc/my.cnf
```
[mysqld]
explicit_defaults_for_timestamp=true
ndbcluster
# IP address for server management node
ndb-connectstring=172.16.0.12
# Define default Storage Engine used by MySQL
default_storage_engine=ndbcluster
#port=4406
datadir=/home/mysql/mysql_data_dir
#
#
[mysql_cluster]
ndb-connectstring=172.16.0.12
```
## 查看占用
sudo netstat -tunlp | grep 3306
## 初始化
```
sudo /usr/sbin/mysqld --initialize-insecure --datadir=/home/mysql/mysql_data_dir --user=root
```
## 启动
```
sudo /usr/sbin/mysqld --user=root
```
测试
mgm节点