【MySQL】MySQL NDB Cluster安装
- 管理节点:管理节点通过对配置文件conifg.ini的维护来对其他节点进行管理。该文件可以用来配置有多少副本需要维护、在数据节点上为数据和索引分配多少内存、数据节点的位置、数据节点上保存数据的磁盘的位置,SQL节点的位置信息等,管理节点只能有一个。
- SQL节点:SQL节点可以理解为应用程序和数据节点的一个桥梁,应用程序不能直接访问数据节点,只能先访问SQL节点,然后SQL节点再去访问数据节点来返回数据,Cluster中可以有多个SQL节点,通过每个SQL节点查询到的数据都是一致的,一般来说,SQL节点越多,分配到每个SQL节点的负载就越小,系统的整体性能就越好;
- 数据节点:数据节点用来存放数据,可有多个数据节点。
管理节点Mgmd:10.24.32.180
SQL节点Mysqld1:10.24.32.181
SQL节点Mysqld2:10.24.32.182
数据节点Ndbd1:10.24.32.183
数据节点Ndbd2:10.24.32.184
[root@strong /]# ll /u01/
total 873104
-rw-r--r--. 1 root root 894037512 Mar 6 13:26 mysql-cluster-gpl-7.5.9-linux-glibc2.12-x86_64.tar.gz
[root@strong /]#
[root@strong ~]# grep mysql /etc/passwd
[root@strong ~]# grep mysql /etc/group
[root@strong ~]# groupadd mysql
[root@strong ~]# useradd -g mysql -s /bin/false mysql
[root@strong ~]#
[root@strong local]# tar zxvf /u01/mysql-cluster-gpl-7.5.9-linux-glibc2.12-x86_64.tar.gz
[root@strong local]# ln -s mysql-cluster-gpl-7.5.9-linux-glibc2.12-x86_64/ mysql
[root@strong local]#
[root@strong local]# cd mysql
[root@strong mysql]# ./bin/mysqld --initialize --user=mysql
2018-03-06T11:04:27.469235Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-06T11:04:28.202258Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-03-06T11:04:28.291271Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-03-06T11:04:28.360238Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 238f3d44-212e-11e8-a946-000c298da433.
2018-03-06T11:04:28.365955Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-03-06T11:04:28.371758Z 1 [Note] A temporary password is generated for root@localhost: 9gidWnDuEo_:
[root@strong mysql]# cp support-files/mysql.server /etc/init.d/mysql.server
[root@strong mysql]# service mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/strong.mysql.com.err'.
..... SUCCESS!
[root@strong mysql]# ./bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.21-ndb-7.5.9-cluster-gplCopyright (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 'root';
Query OK, 0 rows affected (0.00 sec)mysql>
[root@strong u01]# tar zxvf mysql-cluster-gpl-7.5.9-linux-glibc2.12-x86_64.tar.gz
[root@strong u01]# cp mysql-cluster-gpl-7.5.9-linux-glibc2.12-x86_64/bin/ndbd /usr/local/bin/ndbd
[root@strong u01]# cp mysql-cluster-gpl-7.5.9-linux-glibc2.12-x86_64/bin/ndbmtd /usr/local/bin/ndbmtd
[root@strong u01]# ll /usr/local/bin/
total 38280
-rwxr-xr-x. 1 root root 39197765 Mar 6 19:38 ndbd
-rwxr-xr-x. 1 root root 0 Mar 6 19:39 ndbmtd
[root@strong u01]#
[root@strong local]# scp mysql-cluster-gpl-7.5.9-linux-glibc2.12-x86_64/bin/ndb_mgm* root@10.24.32.180:/usr/local/bin/
The authenticity of host '10.24.32.180 (10.24.32.180)' can't be established.
ECDSA key fingerprint is 5b:97:d1:f5:8b:84:a8:ac:9b:bf:b2:b4:0d:71:92:a5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.24.32.180' (ECDSA) to the list of known hosts.
root@10.24.32.180's password:
ndb_mgm 100% 7940KB 7.8MB/s 00:00
ndb_mgmd 100% 17MB 17.3MB/s 00:00
[root@strong local]#
- 连接串ndb-connectstring:告诉节点到哪里查找到管理节点信息;
- 存储引擎信息:ndbcluster。
[root@strong ~]# vi /etc/my.cnf
[mysqld]ndbcluster #run NDB storage engine[mysql_cluster]ndb-connectstring=10.24.32.180 #location of management server
[root@strong local]# mkdir mysql
[root@strong local]# cd mysql/
[root@strong mysql]# mkdir mysql-cluster
[root@strong mysql-cluster]# vi config.ini
[ndbd default]#Opitions affecting ndbd processes on all nodes:NoOfReplicas=1 #Number of replicas[ndb_mgmd]HostName=10.24.32.180 #Hostname or IP address of MGM node
DataDir=/var/lib/mysql-cluster #Dir for MGM node log files[ndbd]HostName=10.24.32.183
NodeId=2
DataDir=/u01[ndbd]HostName=10.24.32.184
NodeId=3
DataDir=/u01[mysqld]HostName=10.24.32.181[mysqld]HostName=10.24.32.182
[root@strong mysql-cluster]# ndb_mgmd -f ./config.ini
MySQL Cluster Management Server mysql-5.7.21 ndb-7.5.9
[root@strong mysql-cluster]# ps aux |grep ndb_mgmd
root 8155 2.5 0.6 504480 3380 ? Ssl 20:48 0:00 ndb_mgmd -f ./config.ini
root 8166 13.0 0.1 112632 968 pts/0 S+ 20:48 0:00 grep --color=auto ndb_mgmd
[root@strong mysql-cluster]#
[root@strong local]# ndbd
2018-03-06 20:51:40 [ndbd] INFO -- Angel connected to '10.24.32.180:1186'
2018-03-06 20:51:40 [ndbd] INFO -- Angel allocated nodeid: 2
[root@strong ~]# service mysql.server start
Starting MySQL........................................................................................................................................... SUCCESS!
[root@strong mysql-cluster]# 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 @10.24.32.183 (mysql-5.7.21 ndb-7.5.9, Nodegroup: 0, *)
id=3 @10.24.32.184 (mysql-5.7.21 ndb-7.5.9, Nodegroup: 1)[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.24.32.180 (mysql-5.7.21 ndb-7.5.9)[mysqld(API)] 2 node(s)
id=4 @10.24.32.181 (mysql-5.7.21 ndb-7.5.9)
id=5 @10.24.32.182 (mysql-5.7.21 ndb-7.5.9)ndb_mgm>
1)集群的管理服务端口是1186;
Connected to Management Server at: localhost:1186
2)集群的数据节点有2个;
[ndbd(NDB)] 2 node(s)
id=2 @10.24.32.183 (mysql-5.7.21 ndb-7.5.9, Nodegroup: 0, *)
id=3 @10.24.32.184 (mysql-5.7.21 ndb-7.5.9, Nodegroup: 1)
3)管理节点有一个;
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.24.32.180 (mysql-5.7.21 ndb-7.5.9)
4)SQL节点有2个,且处于连接状态;
[mysqld(API)] 2 node(s)
id=4 @10.24.32.181 (mysql-5.7.21 ndb-7.5.9)
id=5 @10.24.32.182 (mysql-5.7.21 ndb-7.5.9)
--在任一SQL节点(本例用10.24.32.181)的test库创建测试表t_cluster,设置存储引擎为NDB:
mysql> create table t_cluster(id int,name varchar(100),cdate datetime default now()) engine=NDB;
Query OK, 0 rows affected (0.42 sec)mysql> insert into t_cluster(id,name) values(1,'Alen'),(2,'Cluster Test');
Query OK, 2 rows affected (0.10 sec)
Records: 2 Duplicates: 0 Warnings: 0mysql> select *from t_cluster;
+------+--------------+---------------------+
| id | name | cdate |
+------+--------------+---------------------+
| 1 | Alen | 2018-03-06 23:07:50 |
| 2 | Cluster Test | 2018-03-06 23:07:50 |
+------+--------------+---------------------+
2 rows in set (0.03 sec)mysql>
--在另一SQL节点(本例用10.24.32.182)的test库查询表t_cluster,结果如下:
mysql> select *from t_cluster;
+------+--------------+---------------------+
| id | name | cdate |
+------+--------------+---------------------+
| 1 | Alen | 2018-03-06 23:07:50 |
| 2 | Cluster Test | 2018-03-06 23:07:50 |
+------+--------------+---------------------+
2 rows in set (0.02 sec)mysql>
--如上,两个SQL节点查询到的数据是一致的。
--在SQL节点10.24.32.181将表t_cluster的存储引擎改为MyISAM,再次插入测试:
mysql> alter table t_cluster engine=myisam;
Query OK, 2 rows affected (0.66 sec)
Records: 2 Duplicates: 0 Warnings: 0mysql> insert into t_cluster(id,name) values(3,'MyISAM Test');
Query OK, 1 row affected (0.03 sec)mysql> select *from t_cluster;
+------+--------------+---------------------+
| id | name | cdate |
+------+--------------+---------------------+
| 2 | Cluster Test | 2018-03-06 23:07:50 |
| 1 | Alen | 2018-03-06 23:07:50 |
| 3 | MyISAM Test | 2018-03-06 23:15:02 |
+------+--------------+---------------------+
3 rows in set (0.00 sec)mysql>
--在SQL节点10.24.32.182再次查询表t_cluster,可以发现,表无法查询,结果如下:
mysql> select *from t_cluster;
ERROR 1412 (HY000): Table definition has changed, please retry transaction
mysql>
--在SQL节点10.24.32.181将表t_cluster的存储引擎改为NDB:
mysql> alter table t_cluster engine=ndb;
Query OK, 3 rows affected (0.32 sec)
Records: 3 Duplicates: 0 Warnings: 0mysql>
--在SQL节点10.24.32.182再次查询,结果如下:
mysql> select *from t_cluster;
+------+--------------+---------------------+
| id | name | cdate |
+------+--------------+---------------------+
| 3 | MyISAM Test | 2018-03-06 23:15:02 |
| 1 | Alen | 2018-03-06 23:07:50 |
| 2 | Cluster Test | 2018-03-06 23:07:50 |
+------+--------------+---------------------+
3 rows in set (0.01 sec)mysql>
--显然,表t_cluster的数据再次同步到了数据节点,所有SQL节点又都可以正常查询数据。
--将SQL节点10.24.32.181的MySQL服务停止:
[root@strong mysql]# mysqladmin -uroot -p shutdown
Enter password:
--查看CLuster的状态,可以发现SQL节点10.24.32.181已经断开,另一SQL节点10.24.32.182仍然正常连接:
[root@strong mysql-cluster]# 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 @10.24.32.183 (mysql-5.7.21 ndb-7.5.9, Nodegroup: 0, *)
id=3 @10.24.32.184 (mysql-5.7.21 ndb-7.5.9, Nodegroup: 1)[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.24.32.180 (mysql-5.7.21 ndb-7.5.9)[mysqld(API)] 2 node(s)
id=4 (not connected, accepting connect from 10.24.32.181)
id=5 @10.24.32.182 (mysql-5.7.21 ndb-7.5.9)ndb_mgm>
--从节点10.24.32.182查看t_cluster表,结果如下,显然,SQL节点的单点故障并没有引起数据的查询故障,对于应用来说,需要改变的就是将以前对故障节点的访问改为对非故障节点的访问:
mysql> select *from t_cluster;
+------+--------------+---------------------+
| id | name | cdate |
+------+--------------+---------------------+
| 2 | Cluster Test | 2018-03-06 23:07:50 |
| 3 | MyISAM Test | 2018-03-06 23:15:02 |
| 1 | Alen | 2018-03-06 23:07:50 |
+------+--------------+---------------------+
3 rows in set (0.00 sec)
--管理节点10.24.32.180的[ndbd default]组中的noofreplicas参数为1,将数据节点10.24.32.183的NDB进程停止:
[root@strong u01]# ps -ef |grep ndbd
root 8253 1 0 20:51 ? 00:00:01 ndbd
root 8254 8253 3 20:51 ? 00:03:36 ndbd
root 8515 8336 0 22:48 pts/1 00:00:00 grep --color=auto ndbd
[root@strong u01]# kill 8254 8253
--查看集群状态:
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from 10.24.32.183)
id=3 (not connected, accepting connect from 10.24.32.184)[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.24.32.180 (mysql-5.7.21 ndb-7.5.9)[mysqld(API)] 2 node(s)
id=4 (not connected, accepting connect from 10.24.32.181)
id=5 (not connected, accepting connect from 10.24.32.182)
--在任一SQL节点(10.24.32.181)查询表t_cluster,结果如下:
mysql> select *from t_cluster;
ERROR 1296 (HY000): Got error 4009 'Cluster Failure' from NDBCLUSTER
mysql>
--将noofreplicas参数改为2,按照前面的步骤重启集群:
NoOfReplicas=2
--停止数据节点10.24.32.183的NDB进程:
[root@strong ~]# ps aux |grep ndbd
root 1322 0.0 0.0 28584 128 ? Ss 01:22 0:00 ndbd --initial
root 1323 1.8 56.6 1136400 281004 ? Sl 01:22 0:04 ndbd --initial
root 1382 0.0 0.1 112632 964 pts/0 S+ 01:26 0:00 grep --color=auto ndbd
[root@strong ~]# kill 1323
[root@strong ~]# ps aux |grep ndbd
root 1386 0.0 0.1 112632 964 pts/0 R+ 01:26 0:00 grep --color=auto ndbd
[root@strong ~]#
--查看集群状态:
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from 10.24.32.183)
id=3 @10.24.32.184 (mysql-5.7.21 ndb-7.5.9, Nodegroup: 0, *)[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.24.32.180 (mysql-5.7.21 ndb-7.5.9)[mysqld(API)] 2 node(s)
id=4 @10.24.32.181 (mysql-5.7.21 ndb-7.5.9)
id=5 @10.24.32.182 (mysql-5.7.21 ndb-7.5.9)ndb_mgm>
--再次从任一SQL节点10.24.32.181查询,结果如下:
mysql> select *from t_cluster;
+------+--------------+---------------------+
| id | name | cdate |
+------+--------------+---------------------+
| 1 | Alen | 2018-03-07 01:40:04 |
| 3 | MyISAM Test | 2018-03-07 01:40:19 |
| 2 | Cluster Test | 2018-03-07 01:40:04 |
+------+--------------+---------------------+
3 rows in set (0.01 sec)
[root@strong mysql-cluster]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> shutdown
Connected to Management Server at: localhost:1186
Node 2: Cluster shutdown initiated
Node 3: Cluster shutdown initiated
Node 3: Node shutdown completed.
3 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.
Node 2: Node shutdown completed.
ndb_mgm>
【MySQL】MySQL NDB Cluster安装相关推荐
- APT安装MySQL NDB Cluster
提醒 MySQL APT库支持在Debian和Ubuntu系统上安装MySQL NDB Cluster.因为Ubuntu 20.04或更高版本不支持mysql-cluster-community-au ...
- mysql cluster 安装NDB二进制版本
2019独角兽企业重金招聘Python工程师标准>>> mysql cluster 基于NDB CLUSTER存储引擎的完整的分布式数据库系统.MYSQL CLUSTER是一个sha ...
- MySQL Cluster安装
管理节点:192.168.10.243 Data节点1:192.168.10.244 Data节点2:192.168.10.245 SQL节点1:192.168.30.244 SQL节点2:192.1 ...
- mysql cluster自动安装_MySQL Cluster 安装
下载软件包: [root@mysql1 paul]# wget http://cdn.mysql.com/Downloads/MySQL-Cluster-7.2/mysql-cluster-gpl-7 ...
- MySQL高可用架构InnoDB Cluster (和NDB Cluster是两码事)
MySQL的高可用架构无论是社区还是官方,一直在技术上进行探索,这么多年提出了多种解决方案,比如MMM, MHA, NDB Cluster, Galera Cluster, InnoDB Cluste ...
- mysql设置success信息_【原创】MySQL Cluster安装部署(Success)
参考:http://www.cnblogs.com/zhoulf/archive/2013/01/30/2883207.html 安装要求 安装环境:centos6.3(X64) 软件名称 :mysq ...
- MySQL NDB Cluster部署方案与实践
MySQL Cluster集群 一.概述 MySQL Cluster是MySQL适用于分布式计算环境的高实用.高冗余版本.他采用了NDB Cluster存储引擎,允许在一个Cluster中运行多个 ...
- mysql NDB的安装配置使用示例
1.到mysql网站下载mysql cluster版本 http://www.mysql.com/downloads/cluster/ 下载到/home/weijianzhongwj/software ...
- mysql cluster安装配置_mysql cluster (mysql 集群)安装配置方案
一.准备 1.准备服务器 计划建立有5个节点的MySQL CLuster体系,需要用到5台服务器,但是我们做实验时没有这么多机器,可以只用2台,我就是一台本机,一台虚拟机搭建了有5个节点的MySQL ...
最新文章
- Spline interpolation and Savitzki-Golay smoothing
- Oracle导出空表解决办法
- 关于rms,打开文档的时候提示您没有权限打开文档,因为您的权限已过期
- grep awk sed 实例
- 还不知道 Redis 分布式锁的背后原理?还不赶快学习一下
- 京东共聚黑山县三方合力-农民丰收节·万祥军:谋定智慧农业
- [easyui] 在iframe中操作父窗口的组件
- 图论--一般带花树匹配
- JS,JQuery杂谈
- eclipse 增加php 版本号,扩充eclipse php的代码提示功能
- 开源搜索引擎solr4.0+tomcat7实现中文分词
- php 编译 iconv错误,php编译错误:configure: error: Please reinstall the iconv library.
- 阔别七载,阿里港交所这对“初恋”再牵手
- CALLBACKS IN C++ USING TEMPLATE FUNCTORS
- 语言专升本必背代码_广东省 2021 年普通高等学校专升本招生学科门类与专业基础课对应表...
- BZOJ.4832.[Lydsy1704月赛]抵制克苏恩(期望DP)
- Spring源码之事务(二)
- eeprom和编程器固件 k2_瞎鸡儿折腾之K2/K2P刷机,刷入第三方固件,傻吊教程!
- linux查看内存是ddr3,linux查看具体内存信息
- java method方法_Java Method getDeclaringClass()方法