相关链接:
在 CentOS 1804 中 使用 yum 安装 MySQL 5.7 最新版
在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)
在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)
在 Ubuntu 中安装 MySQL5.7.20(任意版本)
CentOS 6/7 安装 MySQL 8.0.11 (或任意版)
MySQL 5.7 最新版 使用 yum 安装 MySQL NDB Cluster 7.5 最新版 集群
MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明
MySQL 集群 MySQL NDB Cluster 7.6.** 与 MySQL 5.7.** 对应版本说明
MySQL 5.7.20 (或指定版本) 与 MySQL NDB Cluster 7.6.4 (或指定版本) 集群
说明:
- 一共四台服务器:
- 管理节点:192.168.113.151
- MySQL节点:192.168.113.152
- 数据节点A:192.168.113.153
- 数据节点B:192.168.113.154
- 在管理节点、MySQL节点、数据节点A、数据节点B执行操作:
- 为MySQL NDB Cluster添加MySQL Yum存储库:
mkdir -p /data/mysql cd /data/mysql/ wget https://repo.mysql.com/mysql57-community-release-el7.rpm rpm -Uvh mysql57-community-release-el7.rpm yum update mysql57-community-release
- 选择MySQL NDB集群子库:
yum -y install yum-utils yum-config-manager --enable mysql57-community yum-config-manager --enable mysql-cluster-7.5-community
- 为MySQL NDB Cluster添加MySQL Yum存储库:
-
安装MySQL NDB集群:
- 在管理节点执行操作:
yum -y install mysql-cluster-community-management-server
- 在MySQL节点执行操作:
手动安装依赖perl-Class-MethodMaker(此依赖CentOS中不存在,无法自动找到,使用的是epel el7 x86_64):
安装SQL节点的组件:wget https://mirrors.aliyun.com/epel/7/x86_64/Packages/p/perl-Class-MethodMaker-2.20-1.el7.x86_64.rpm yum -y install perl-Class-MethodMaker-2.20-1.el7.x86_64.rpm
开启数据库:yum -y install mysql-cluster-community-server
已默认打开开机自启。systemctl start mysqld.service
查看root默认密码:
初次登录修改密码:[root@CentOS-1804-MySQL-2 ~]# grep 'temporary password' /var/log/mysqld.log 2018-10-20T01:05:54.185926Z 1 [Note] A temporary password is generated for root@localhost: #zwtljlax8EX
下面已显示 MySQL 版本为 5.7.23,MySQL NDB Cluster版本为7.5.11。
设置远程连接密码:[root@CentOS-1804-MySQL-2 ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.23-ndb-7.5.11-cluster-gpl Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; Query OK, 0 rows affected (0.00 sec)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Abc,123.456+';
打开3306端口:firewall-cmd --zone=public --add-port=3306/tcp --permanent systemctl restart firewalld.service firewall-cmd --list-ports
- 在数据节点A、数据节点B执行操作:
yum -y install mysql-cluster-community-data-node
- 在管理节点执行操作:
- NDB集群的初始配置:
- 在MySQL节点、数据节点A、数据节点B执行操作:
添加以下内容:vim /etc/my.cnf
[mysqld] # Options for mysqld process: ndbcluster # run NDB storage engine [mysql_cluster] # Options for NDB Cluster processes: ndb-connectstring=192.168.113.151 # location of management server
- 在管理节点执行操作:
添加以下内容:mkdir /var/lib/mysql-cluster cd /var/lib/mysql-cluster vim 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=192.168.113.151 # 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=192.168.113.153 # 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=192.168.113.154 # 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=192.168.113.152 # Hostname or IP address # (additional mysqld connections can be # specified for this node for various # purposes such as running ndb_restore)
在MySQL NDB Cluster 7.6中不建议使用IndexMemory,否则会报以下错误:WARNING -- at line 6: [DB] IndexMemory is deprecated, use Number bytes on each ndbd(DB) node allocated for storing indexes instead
- 在MySQL节点、数据节点A、数据节点B执行操作:
-
NDB集群的初始启动:
-
在管理节点执行操作:
打开端口1186:firewall-cmd --zone=public --add-port=1186/tcp --permanent systemctl restart firewalld.service firewall-cmd --list-ports
首次启动:
[root@CentOS-1804-MySQL-1 mysql-cluster]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini MySQL Cluster Management Server mysql-5.7.23 ndb-7.5.11 2018-10-20 09:23:01 [MgmtSrvr] INFO -- The default config directory '/usr/mysql-cluster' does not exist. Trying to create it... 2018-10-20 09:23:01 [MgmtSrvr] INFO -- Sucessfully created config directory
之后启动:
ndb_mgmd
-
在数据节点A、数据节点B执行操作:
创建目录:mkdir -p /usr/local/mysql/data
在数据节点A执行操作:
[root@CentOS-1804-MySQL-3 ~]# ndbd 2018-10-20 09:26:26 [ndbd] INFO -- Angel connected to '192.168.113.151:1186' 2018-10-20 09:26:26 [ndbd] INFO -- Angel allocated nodeid: 2
在数据节点B执行操作:
[root@CentOS-1804-MySQL-4 ~]# ndbd 2018-10-20 09:26:46 [ndbd] INFO -- Angel connected to '192.168.113.151:1186' 2018-10-20 09:26:46 [ndbd] INFO -- Angel allocated nodeid: 3
- 在MySQL节点执行操作:
上面显示内容已说明配置成功。[root@CentOS-1804-MySQL-2 ~]# ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> SHOW Connected to Management Server at: 192.168.113.151:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @192.168.113.153 (mysql-5.7.23 ndb-7.5.11, starting, Nodegroup: 0) id=3 @192.168.113.154 (mysql-5.7.23 ndb-7.5.11, starting, Nodegroup: 0) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.113.151 (mysql-5.7.23 ndb-7.5.11) [mysqld(API)] 1 node(s) id=4 (not connected, accepting connect from 192.168.113.152) ndb_mgm>
-
相关链接:
在 CentOS 1804 中 使用 yum 安装 MySQL 5.7 最新版
在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)
在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)
在 Ubuntu 中安装 MySQL5.7.20(任意版本)
CentOS 6/7 安装 MySQL 8.0.11 (或任意版)
MySQL 5.7 最新版 使用 yum 安装 MySQL NDB Cluster 7.5 最新版 集群
MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明