单点故障测试

管理节点:对于冗余管理节点,不需要配置,只要管理工具及配置文件放在另外的主机上就可以了。
数据节点:一般至少会配置两台数据节点
SQL节点:一般至少会配置两台SQL节点

一、 SQL节点发生单点故障测试

1、将SQL节点1的mysql服务停止

[root@rac2 bin]# ./mysqladmin shutdown
090724 07:29:27 mysqld_safe mysqld from pid file /home/mysql/mysql/data/rac2.pid ended
[1]+ Done ./bin/mysqld_safe (wd: /home/mysql/mysql)
(wd now: /home/mysql/mysql/bin)

2、查看cluster状态

ndb_mgm> show
Cluster Configuration
———————
[ndbd(NDB)] 2 node(s)
id=2 @192.168.205.235 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0, Master)
id=3 @192.168.205.231 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.205.240 (mysql-5.1.34 ndb-7.0.6)

[mysqld(API)] 2 node(s)
id=4 (not connected, accepting connect from 192.168.205.233)
id=5 @192.168.205.239 (mysql-5.1.34 ndb-7.0.6)

id=4的SQL节点已经断开

3、在SQL节点2上查询

mysql> select * from xiyan;
+——+
| id |
+——+
| 3 |
| 1 |
| 2 |
+——+
3 rows in set (0.01 sec)

小节:一个SQL节点出现故障,并不会影响应用对数据库的操作。

二、 数据节点单点故障

因为我在配置config.ini时,配置了NoOfReplicas=2,可以在数据节点会保存两份一样的数据,所以一个数据节点出现故障,并不会影响应用。

1、 使用数据节点1故障

[root@dg data]# ps -ef|grep ndb
root 28862 1 0 07:46 ? 00:00:00 ndbd
root 28863 28862 2 07:46 ? 00:00:37 ndbd
root 28929 28806 0 08:07 pts/1 00:00:00 grep ndb
[root@dg data]# kill -9 28863

查看管理节点

ndb_mgm> show
Cluster Configuration
———————
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from 192.168.205.235)
id=3 @192.168.205.231 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0, Master)

[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.205.240 (mysql-5.1.34 ndb-7.0.6)

[mysqld(API)] 2 node(s)
id=4 @192.168.205.233 (mysql-5.1.34 ndb-7.0.6)
id=5 @192.168.205.239 (mysql-5.1.34 ndb-7.0.6)

id=2的数据节点断开了

2、 在两个SQL节点上查询

mysql> select * from xiyan;
+——+
| id |
+——+
| 2 |
| 3 |
| 1 |
+——+
3 rows in set (0.00 sec)

都能够正常查询

注意:如果NoOfReplicas=1的话,两个数据节点只会保存一份数据,所以一个节点出现故障,那么应用就不能正常访问了。
小结:所以一般情况下,我们也要对数据节点进行冗余。

觉得文章有用?立即: 和朋友一起 共学习 共进步!

猜想失败,您看看下面的文章有用吗?

2 thoughts on “单点故障测试

  1. 你好,我也配置了NoOfReplicas=2 。可是一kill掉一个数据节点,就会报错:Node 2: Forced node shutdown completed. Occured during startphase 1. Caused by error 2353: ‘Insufficent nodes for system restart(Restart error). Temporary error, restart node’ 而且所有数据节点和SQL节点都会断开连接,请问你有遇到过这样的问题吗?谢谢……

  2. 我也遇到相同的问题
    Node 2: Forced node shutdown completed. Occured during startphase 1. Caused by error 2353: ‘Insufficent nodes for system restart(Restart error). Temporary error, restart node’
    当我将这个参数由一改成二时,发现后面的SQL节点都启不了,ndbd也只能启一个。一启就报上面的错。

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>