ITPub博客

首页 > Linux操作系统 > Linux操作系统 > MySQL NDB 安装的安装,配置与测试

MySQL NDB 安装的安装,配置与测试

原创 Linux操作系统 作者:hegenhua 时间:2011-05-03 13:30:51 0 删除 编辑

MySQL NDB 安装
   一,前言
      Mysql NDB集群安装方法说简单也简单,说复杂也能说复杂.
      之所以说简单,那是针对已经会配置的人来说的,现在回想起来,如果有正确的方法论的指导,配起来是相当的简单的.
      之所以说复杂,那是针对还不会配置的人来说,在我摸索出来如何配置之前,我参考了网上很多的技术文档,按照他们的方法来进行配置,但是直到配置成功,前前后后总共花了我3天时间,
      外加熬了一个夜才配起来.所以,如果是mysql高手看到我的这个文档里描述的一些在你们看起来简单,甚至是弱智的问题,请不要拍砖,请给我掌声,请鼓励我,并请指导我,因为新人需要的是
      鼓励,而不是砖头,谢谢!:)
     
  二,配置中碰到的问题,经验总结以及尚存的疑问
     这里先说下我在配置中碰到的问题吧.
     A,配置之前,请一定要获取到正确的mysql版本,一定要获取到mysql支持cluster的版本,我因为开头获取到的版本不支持NDB,因此老是找不到ndbd这个程序,这个问题卡了我好久.
        我download了mysql-cluster-gpl-7.1.10.tar.gz,
                    mysql-cluster-gpl-7.1.9a.tar.gz,
                    MySQL-Cluster-gpl-server-7.1.10-1.rhel5.x86_64.rpm
        在我的服务器按照网上前辈们发出的技术帖子,参考mysql官方文档均没有配置成功,原因一直都是在数据接点找不到ndbd这个程序.
        直到2011年5月1号凌晨3:00,我在经过反思后,在mysql网站下载了linux-Generic下面的
        mysql-cluster-gpl-7.1.10-linux-x86_64-glibc23.tar.gz
        版本,然后在我的mysql节点和数据节点后,才配置成功.
       
        这中间失败过不止5次,我都快绝望了.在经过再一次尝试后,终于成功了.
        我想这里不止是我成功的配置了mysql NDB,更大的收获是,在经过若干次失败后,我能够成功说服自己,让自己再试一次,然后终于成功,我想这个收获可能远比学会配置mysql ndb这个事情本身
        重要得多.
       
        坚持就是胜利!
        
       
     B, 配置之前,需要先从理论上好好系统把握一下mysql ndb的配置方法,这样可以少走很多弯路.
    
    
  
   三,尚存的疑问
      我目前还不清楚为什么我用
      mysql-cluster-gpl-7.1.10.tar.gz,
      mysql-cluster-gpl-7.1.9a.tar.gz,
      MySQL-Cluster-gpl-server-7.1.10-1.rhel5.x86_64.rpm
    这三个版本均无法找到ndbd这个程序,有高手知道烦请直到一下,非常感谢!
   
   
   
   四,配置前的规划
      管理节点IP:  192.168.133.98   节点ID: id=1
      NDB数据节点1: 192.168.133.101   节点ID: id=2
      NDB数据节点2: 192.168.133.102   节点ID: id=3
      mysql节点1:  192.168.133.62   节点ID: id=4
      mysql节点2:  192.168.133.100   节点ID: id=5
     
      OS:Centos 5.4 64位,4GB内存,5台都是虚拟机,都是运行在Vmware vsphere上的.
      [root@localhost ndbdatabase]# uname -a
      [root@localhost ndbdatabase] #:Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

      以下是管理节点config.ini文件的内容(文件存放在/var/lib/mysql-cluster目录下):
      
        [NDBD DEFAULT]
    NoOfReplicas=2
    DataMemory=100M
    IndexMemory=100M
    
    [TCP DEFAULT]
    portnumber=2202
    
    #管理节点
    [NDB_MGMD]
    id=1
    hostname=192.168.133.98
    datadir=/var/lib/mysql-cluster
    
    
    #第一个ndbd节点
    [NDBD]
    id=2
    hostname=192.168.133.101
    datadir=/usr/local/mysql/ndbdata
    
    #第二个ndbd节点
    [NDBD]
    id=3
    hostname=192.168.133.102
    datadir=/usr/local/mysql/ndbdata
    
    
    #SQL node
    
    [mysqld]
    id=4
    hostname=192.168.133.62
    
    [mysqld]
    id=5
    hostname=192.168.133.100


   五,开始安装
       A,安装数据节点与mysql节点,以下操作重复4次,在除管理节点以外的其他的节点上执行:
        #groupadd mysql
        #useradd –g mysql mysql
        #tar zxvf mysql-cluster-gpl-7.1.10-linux-x86_64-glibc23.tar.gz
        #chown mysql:mysql  mysql-cluster-gpl-7.1.10-linux-x86_64-glibc23
        #cd  mysql-cluster-gpl-7.1.10-linux-x86_64-glibc23
        #mv * /usr/local/mysql

   上述命令先创建mysql组和mysql用户,并且把MySQL分配到MySQL组,然后将安装文件解压,把它放置到/usr/local/mysql目录。

     
      配置
      配置管理节点[192.168.133.98]:
      创建以下文件/var/lib/mysql-cluster/config.ini,并在其中添加如下内容:
        [NDBD DEFAULT]
    NoOfReplicas=2
    DataMemory=100M
    IndexMemory=100M
    
    [TCP DEFAULT]
    portnumber=2202
    
    #管理节点
    [NDB_MGMD]
    id=1
    hostname=192.168.133.98
    datadir=/var/lib/mysql-cluster
    
    
    #第一个ndbd节点
    [NDBD]
    id=2
    hostname=192.168.133.101
    datadir=/usr/local/mysql/ndbdata
    
    #第二个ndbd节点
    [NDBD]
    id=3
    hostname=192.168.133.102
    datadir=/usr/local/mysql/ndbdata
    
    
    #SQL node
    
    [mysqld]
    id=4
    hostname=192.168.133.62
    
    [mysqld]
    id=5
    hostname=192.168.133.100
在这个文件里,我们分别给四个节点分配了ID,这有利于更好的管理和区分各个节点。当然,要是不指定,MySQL也会动态分配一个。上述几个Datadir如果还不存在的需要手动创建。用mkdir –p命令即可。


     
配置数据节点[192.168.133.101, 192.168.133.102]:

创建/etc/my.cnf文件,内容如下

# Options for mysqld process:

[mysqld]

Datadir=/usr/local/mysql/ndbdata


[mysql_cluster]
ndb-connectstring  = 192.168.133.98

 


配置SQL节点[192.168.133.62,192.168.133.100]

创建/etc/my.cnf文件,内容如下

# Options for mysqld process:

[mysqld]

ndbcluster                      # run NDB storage engine

NDB-connectstring=192.168.133.98  # location of management server


# Options for ndbd process:

[mysql_cluster]

NDB-connectstring=192.168.133.98  # location of management server
 


[root@ndba bin]./scripts/mysql_install_db --user=mysql --basedir=/u02/mysql/ --ldata=/u02/mysql/var/

Installing MySQL system tables...

OK

Filling help tables...

OK

 

到这里,所有配置已经完成了。

 

 

启动
启动管节点[192.168.133.98]:

[root@localhost bin]# ./ndb_mgmd -f /var/lib/mysql-cluster/config.ini

[root@localhost bin]# ./ndb_mgm

-- NDB Cluster -- Management Client --

ndb_mgm> show

Connected to Management Server at: 192.168.133.98:1186

Cluster Configuration

---------------------

[ndbd(NDB)]     2 node(s)

id=2 (not connected, accepting connect from 192.168.133.101)

id=3 (not connected, accepting connect from 192.168.133.102)

 

[ndb_mgmd(MGM)] 1 node(s)

id=1    @192.168.133.98  (Version: 7.1.10)

 

[mysqld(API)]   1 node(s)

id=4 (not connected, accepting connect from 192.168.133.62)
id=5 (not connected, accepting connect from 192.168.133.100)
 

我们可以看到集群的状态都还没有启动,都是not connected状态。

 


启动数据节点[192.168.133.101, 192.168.133.102]:

[root@localhost ~]#cd /usr/local/mysql/bin

[root@localhost bin]#./ndbd
 


 

 

 

启动SQL节点[192.168.133.62,192.168.133.100]:

[root@localhost mysql]# ./bin/mysqld_safe &
 

 

至此,所有节点已经启动完成,让我们来查看系统状态:

Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @192.168.133.101  (Version: 7.1.10, Nodegroup: 0, Master)
id=3    @192.168.133.102  (Version: 7.1.10, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.133.98  (Version: 7.1.10)

[mysqld(API)]   2 node(s)
id=4    @192.168.133.62  (Version: 7.1.10)
id=5    @192.168.133.100  (Version: 7.1.10)

 


测试:
   在192.168.133.62上执行以下命令:
   #mysql
   mysql>
   mysql> use ndbdatabase;
  Database changed
  mysql> create table test (id int) engine=ndb;
  Query OK, 0 rows affected (0.10 sec)
  
  mysql> show create table test\G;
  *************************** 1. row ***************************
         Table: test
  Create Table: CREATE TABLE `test` (
    `id` int(11) DEFAULT NULL
  ) ENGINE=ndbcluster DEFAULT CHARSET=latin1
  1 row in set (0.00 sec)
  
  ERROR:
  No query specified
  
  mysql> insert into test values(1);
  Query OK, 1 row affected (0.00 sec)
  
  mysql> select * from test;
  +------+
  | id   |
  +------+
  |    1 |
  +------+
  1 row in set (0.00 sec)
  
  mysql>

  
  
   在192.168.133.100上执行以下命令,验证以上操作:
  [root@localhost test]# mysql
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 4
  Server version: 5.1.51-ndb-7.1.10-log Source distribution
  
  Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  and you are welcome to modify and redistribute it under the GPL v2 license
  
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  
  mysql> show database;
  ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
  mysql> show databases;
  +--------------------+
  | Database           |
  +--------------------+
  | information_schema |
  | mysql              |
  | ndbdatabase        |
  | ndbinfo            |
  | test               |
  +--------------------+
  5 rows in set (0.01 sec)
  
  mysql> use ndbdatabase;
  Database changed
  mysql> show tables;
  +-----------------------+
  | Tables_in_ndbdatabase |
  +-----------------------+
  | test                  |
  +-----------------------+
  1 row in set (0.00 sec)
  
  mysql> show create table test\G;
  *************************** 1. row ***************************
         Table: test
  Create Table: CREATE TABLE `test` (
    `id` int(11) DEFAULT NULL
  ) ENGINE=ndbcluster DEFAULT CHARSET=latin1
  1 row in set (0.02 sec)
  
  ERROR:
  No query specified
  
  mysql> select * from test;
  +------+
  | id   |
  +------+
  |    1 |
  +------+
  1 row in set (0.01 sec)
  
  mysql>

验证表明,集群工作正常.

 

 

破坏性测试:
  1,关闭其中一个数据节点,验证结果表明,集群工作正常,
 
   以下操作在数据节点2[192.168.133.102]上执行,如下:
    [root@localhost bin]# ps -ef | grep ndbd
  root      7541     1  0 01:52 ?        00:00:00 ./ndbd –nodeid=3 –initial
  root      7542  7541  0 01:52 ?        00:02:39 ./ndbd –nodeid=3 –initial
  root      9931  3295  0 20:47 pts/1    00:00:00 grep ndbd
  [root@localhost bin]# kill 7541 7542
  [root@localhost bin]# ps -ef | grep ndbd
  root      9933  3295  0 20:47 pts/1    00:00:00 grep ndbd
  [root@localhost bin]# ifconfig
  eth0      Link encap:Ethernet  HWaddr 00:50:56:B8:00:13
            inet addr:192.168.133.102  Bcast:192.168.133.255  Mask:255.255.255.0
            inet6 addr: fe80::250:56ff:feb8:13/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:19511513 errors:0 dropped:0 overruns:0 frame.:0
            TX packets:19957492 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:1781288143 (1.6 GiB)  TX bytes:1899963551 (1.7 GiB)
            Base address:0x2000 Memory:d8920000-d8940000
           
           
  lo        Link encap:Local Loopback
            inet addr:127.0.0.1  Mask:255.0.0.0
            inet6 addr: ::1/128 Scope:Host
            UP LOOPBACK RUNNING  MTU:16436  Metric:1
            RX packets:597990 errors:0 dropped:0 overruns:0 frame.:0
            TX packets:597990 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:51521498 (49.1 MiB)  TX bytes:51521498 (49.1 MiB)
  
  [root@localhost bin]#


    去管理节点看集群的状态:
    ndb_mgm> show
  Cluster Configuration
  ---------------------
  [ndbd(NDB)]     2 node(s)
  id=2    @192.168.133.101  (Version: 7.1.10, Nodegroup: 0, Master)
  id=3 (not connected, accepting connect from 192.168.133.102)
  
  [ndb_mgmd(MGM)] 1 node(s)
  id=1    @192.168.133.98  (Version: 7.1.10)
  
  [mysqld(API)]   2 node(s)
  id=4    @192.168.133.62  (Version: 7.1.10)
  id=5    @192.168.133.100  (Version: 7.1.10)
  
    ndb_mgm>
 
 表明192.168.133.102上的数据节点确实当掉了.
 
    去mysql节点1[192.168.133.62]做如下操作:
    [root@localhost setup]# mysql
  [root@localhost setup]# ifconfig
  eth0      Link encap:Ethernet  HWaddr 00:50:56:B8:00:0F
            inet addr:192.168.133.62  Bcast:192.168.133.255  Mask:255.255.255.0
            inet6 addr: fe80::250:56ff:feb8:f/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:7603400 errors:0 dropped:0 overruns:0 frame.:0
            TX packets:4072260 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:684602777 (652.8 MiB)  TX bytes:402432650 (383.7 MiB)
            Base address:0x2000 Memory:d8920000-d8940000
  
  lo        Link encap:Local Loopback
            inet addr:127.0.0.1  Mask:255.0.0.0
            inet6 addr: ::1/128 Scope:Host
            UP LOOPBACK RUNNING  MTU:16436  Metric:1
            RX packets:203352 errors:0 dropped:0 overruns:0 frame.:0
            TX packets:203352 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:11961759 (11.4 MiB)  TX bytes:11961759 (11.4 MiB)
  
  [root@localhost setup]# mysql
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 9
  Server version: 5.1.51-ndb-7.1.10-log Source distribution
  
  Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  and you are welcome to modify and redistribute it under the GPL v2 license
  
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  
  mysql> show databases;
  +--------------------+
  | Database           |
  +--------------------+
  | information_schema |
  | mysql              |
  | ndbdatabase        |
  | ndbinfo            |
  | test               |
  +--------------------+
  5 rows in set (0.00 sec)
  
  mysql> use ndbdatabase;
  Database changed
  mysql> show tables;
  +-----------------------+
  | Tables_in_ndbdatabase |
  +-----------------------+
  | test                  |
  +-----------------------+
  1 row in set (0.01 sec)
  
  mysql> select * from test;
  +------+
  | id   |
  +------+
  |    1 |
  +------+
  1 row in set (0.00 sec)
  
  mysql>

以上操作表明在一个数据节点当机后,集群依然工作正常.

 

2,如果再关闭另一个数据节点,则集群将不能正常工作了,如下:
   去另一个数据节点做如下操作:
   [root@ndba bin]# ifconfig
  eth0      Link encap:Ethernet  HWaddr 00:50:56:B8:00:16
            inet addr:192.168.133.101  Bcast:192.168.133.255  Mask:255.255.255.0
            inet6 addr: fe80::250:56ff:feb8:16/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:18433176 errors:0 dropped:0 overruns:0 frame.:0
            TX packets:21062696 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:1667559676 (1.5 GiB)  TX bytes:2015791677 (1.8 GiB)
            Base address:0x2000 Memory:d8920000-d8940000
  
  lo        Link encap:Local Loopback
            inet addr:127.0.0.1  Mask:255.0.0.0
            inet6 addr: ::1/128 Scope:Host
            UP LOOPBACK RUNNING  MTU:16436  Metric:1
            RX packets:610836 errors:0 dropped:0 overruns:0 frame.:0
            TX packets:610836 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:56236290 (53.6 MiB)  TX bytes:56236290 (53.6 MiB)
  
  [root@ndba bin]# ps -ef | grep ndbd
  root      7370     1  0 01:52 ?        00:00:00 ./ndbd –nodeid=2 –initial
  root      7371  7370  0 01:52 ?        00:01:36 ./ndbd –nodeid=2 –initial
  root      9742  3211  0 20:54 pts/1    00:00:00 grep ndbd
  [root@ndba bin]# kill 7370 7371
  [root@ndba bin]# ps -ef | grep ndbd
  root      9744  3211  0 20:54 pts/1    00:00:00 grep ndbd
  [root@ndba bin]#

去管理节点看集群状态:
 Cluster Configuration
 ---------------------
 [ndbd(NDB)]     2 node(s)
 id=2 (not connected, accepting connect from 192.168.133.101)
 id=3 (not connected, accepting connect from 192.168.133.102)
 
 [ndb_mgmd(MGM)] 1 node(s)
 id=1    @192.168.133.98  (Version: 7.1.10)
 
 [mysqld(API)]   2 node(s)
 id=4 (not connected, accepting connect from 192.168.133.62)
 id=5 (not connected, accepting connect from 192.168.133.100)
 
 ndb_mgm>

集群的mysql节点与数据节点全部都显示not connected


去mysql节点查看集群是否能够正常工作:
[root@localhost test]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:56:B8:00:11
          inet addr:192.168.133.100  Bcast:192.168.133.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:feb8:11/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11708068 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:8176630 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:939146422 (895.6 MiB)  TX bytes:705601338 (672.9 MiB)
          Base address:0x2000 Memory:d8920000-d8940000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1217 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:1217 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1933787 (1.8 MiB)  TX bytes:1933787 (1.8 MiB)

[root@localhost test]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.51-ndb-7.1.10-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| ndbdatabase        |
| ndbinfo            |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql> use ndbdatabase;
Database changed
mysql> show tables;
+-----------------------+
| Tables_in_ndbdatabase |
+-----------------------+
| test                  |
+-----------------------+
1 row in set, 2 warnings (0.00 sec)

mysql> select * from test;
ERROR 1296 (HY000): Got error 157 'Unknown error code' from NDBCLUSTER
mysql>

最后一行做select时,表明集群无法正常工作.

 

以上操作后,启动任意数据节点,mysql节点将自动启动,集群开始恢复工作.

 

 

3,关闭管理节点,看集群是否能够正常工作.
  去管理节点:
   [root@localhost mysql-cluster]# ps -ef | grep ndb
  root     12700     1  0 May01 ?        00:00:39 ndb_mgmd -f /var/lib/mysql-cluster/config.ini
  root     18900  3634  0 21:04 pts/1    00:00:00 grep ndb
  [root@localhost mysql-cluster]# kill 12700
  [root@localhost mysql-cluster]# ps -ef | grep ndb
  root     18902  3634  0 21:04 pts/1    00:00:00 grep ndb
  [root@localhost mysql-cluster]# ifconfig
  eth0      Link encap:Ethernet  HWaddr 00:50:56:B8:00:0E
            inet addr:192.168.133.98  Bcast:192.168.133.255  Mask:255.255.255.0
            inet6 addr: fe80::250:56ff:feb8:e/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:3562687 errors:0 dropped:0 overruns:0 frame.:0
            TX packets:6545698 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:572011061 (545.5 MiB)  TX bytes:524607564 (500.3 MiB)
            Base address:0x2000 Memory:d8920000-d8940000
  
  lo        Link encap:Local Loopback
            inet addr:127.0.0.1  Mask:255.0.0.0
            inet6 addr: ::1/128 Scope:Host
            UP LOOPBACK RUNNING  MTU:16436  Metric:1
            RX packets:1006721 errors:0 dropped:0 overruns:0 frame.:0
            TX packets:1006721 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:60750223 (57.9 MiB)  TX bytes:60750223 (57.9 MiB)
  
  [root@localhost mysql-cluster]#

  去mysql节点1[192.168.133.62]:
  [root@localhost setup]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:56:B8:00:0F
          inet addr:192.168.133.62  Bcast:192.168.133.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:feb8:f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7609236 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:4076425 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:685061722 (653.3 MiB)  TX bytes:402808960 (384.1 MiB)
          Base address:0x2000 Memory:d8920000-d8940000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:203352 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:203352 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11961759 (11.4 MiB)  TX bytes:11961759 (11.4 MiB)

[root@localhost setup]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.1.51-ndb-7.1.10-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| ndbdatabase        |
| ndbinfo            |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql> use ndbdatabase;
Database changed
mysql> select * from test;
+------+
| id   |
+------+
|    1 |
+------+
1 row in set (0.05 sec)

mysql> insert into test values(2);
Query OK, 1 row affected (0.00 sec)

mysql> select * from test;
+------+
| id   |
+------+
|    2 |
|    1 |
+------+
2 rows in set (0.00 sec)

mysql>

 

去另一个mysql节点看是否可以看得到变化:
[root@localhost test]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:56:B8:00:11
          inet addr:192.168.133.100  Bcast:192.168.133.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:feb8:11/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11730179 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:8190412 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:941000768 (897.4 MiB)  TX bytes:706878499 (674.1 MiB)
          Base address:0x2000 Memory:d8920000-d8940000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1217 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:1217 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1933787 (1.8 MiB)  TX bytes:1933787 (1.8 MiB)

[root@localhost test]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.51-ndb-7.1.10-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| ndbdatabase        |
| ndbinfo            |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql> use ndbdatabase;
Database changed
mysql> select * from test;
+------+
| id   |
+------+
|    2 |
|    1 |
+------+
2 rows in set (0.00 sec)

mysql>


测试结果表明,管理节点关闭,集群依然工作正常.


启动管理节点:
ndb_mgmd -f /var/lib/mysql-cluster/config.ini

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/101629/viewspace-694325/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-02-17

  • 博文量
    24
  • 访问量
    54425