MySQL Cluster 实验记录

来源:互联网 发布:建筑节能行业数据 编辑:程序博客网 时间:2024/04/20 07:05

MySQL Cluster 实验记录

一、理解MySQL Cluster节点

MySQL Cluster按照节点类型可以分为3种类型的节点,分别是管理节点、SQL节点、数据节点。所有的这些节点构成了一个完整的MySQL集群
体系结构。事实上,数据保存在NDB存储服务器的存储引擎中,表结构则保存在MySQL服务器中,应用程序通过MySQL服务器访问数据,而集群管理
服务器则通过管理工具ndb_mgmd来管理NDM存储服务器。
下面先了解一下MySQL Cluster3种不同类型的节点。

1,管理节点

管理节点主要是用来对其他节点进行管理的。通常通过配置config.ini文件来配置集群中有多少需要维护的副本,配置每个数据节点上为数据
和索引分配多少内存、IP地址,以及在每个数据节点上保存数据的磁盘路径。
管理节点通常管理Cluster配置文件和Cluster日志。Cluster中的每个节点从管理服务器检索配置信息,并请求确定管理服务器所在位置的方式。
如果节点内出现新的事件时,节点将这类事件的信息传输到管理服务器,将这类信息写入到Cluster日志中。
一般在MySQL Cluster中至少需要一个管理节点,另外值得注意的是,因为数据节点和SQL节点在启动前需要读取Cluster的配置信息,所以通常
管理节点是最先启动的。

2,SQL节点

SQL节点简单的讲就是mysqld服务器,应用不能直接访问数据节点,只能通过SQL节点访问数据节点来返回数据。任何一个节点都是连接到所有的
存储节点的,所以当任何一个存储节点发生故障的时候,SQL节点都可以把请求转移到另外一个存储节点执行。通常来说,SQL节点越多越好,SQL节点
越多,分配到每个SQL节点的负载就越小,系统的整体性能就越好。

3,数据节点

数据节点用来存放Cluster里面的数据,MySQL Cluster在各个数据节点之间复制数据,任何一个节点发生故障,始终会有另外的数据节点存储数据。
通常这3种逻辑不通的节点分布在不通的计算机上面。集群最少有3台计算机。为了保证能正常维护整个集群服务,通常将管理节点放在一个独立的主机上。

二、搭建步骤

集群环境说明
参考资料 http://blog.csdn.net/zhao8464160/article/details/37764547
h30101.bj.cn     192.168.30.101  (管理节点)
h30102.bj.cn     192.168.30.102  (SQL节点)
h30103.bj.cn     192.168.30.103  (SQL节点)
h30104.bj.cn     192.168.30.104  (数据节点)
h30104.bj.cn     192.168.30.105  (数据节点)



1,在安装Cluster之前需要将MySQL Server卸载掉

[root@h30101 ~]# rpm -qa|grep -i mysql
mysql-devel-5.1.71-1.el6.x86_64
mysql-5.1.71-1.el6.x86_64
mysql-libs-5.1.71-1.el6.x86_64
[root@h30101 ~]# yum -y remove mysql-libs  mysql-devel mysql
[root@h30101 ~]# userdel -r mysql
[root@h30101 ~]#rm -rf /etc/my.cnf
[root@h30102 yum.repos.d]# find / -name mysql
//这里的5台机器都要这样做。

2,添加mysql用户

[root@h30105 ~]# groupadd mysql
[root@h30105 ~]# useradd -g mysql mysql
//这里的5台机器都要这样做。

3,安装mysql-cluster 

[root@h30101 Packages]# yum -y install lrzsz (这里不是必须的,为了上传文件)
[root@h30101 src]# cd /usr/local/src/
[root@h30101 src]# ll
total 321836
-rw-r--r-- 1 root root 329555009 Aug 12 16:53 mysql-cluster-gpl-7.2.15-linux2.6-x86_64.tar.gz
[root@h30101 src]# scp mysql-cluster-gpl-7.2.15-linux2.6-x86_64.tar.gz root@192.168.30.102:/usr/local/src/
[root@h30101 src]# tar -zxf mysql-cluster-gpl-7.2.15-linux2.6-x86_64.tar.gz 
[root@h30101 src]# mv mysql-cluster-gpl-7.2.15-linux2.6-x86_64 ../mysql
[root@h30101 src]# cd ../
[root@h30101 local]# chown -R mysql.mysql mysql/
[root@h30101 local]# cd mysql/
[root@h30101 mysql]# ./scripts/mysql_install_db --user=mysql
[root@h30101 mysql]# cp support-files/my-medium.cnf  /etc/my.cnf
[root@h30101 mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server
[root@h30101 mysql]# chmod o+x /etc/init.d/mysql.server
[root@h30101 mysql]# /etc/init.d/mysql.server start //简单的测试一下,之后的先不要启动
Starting MySQL... SUCCESS! 
[root@h30101 mysql]# 
[root@h30101 src]# mysql 
-bash: mysql: command not found
[root@h30101 src]# //需要添加环境变量
[root@h30101 src]# tail -2 /etc/profile
PATH=$PATH:/usr/local/mysql/bin
export PATH

[root@h30101 ~]# mysql //简单的测试一下,之后的先不要启动
mysql> show variables like '%ndb%';
+----------------------+----------+
| Variable_name        | Value    |
+----------------------+----------+
| have_ndbcluster      | DISABLED |
| ndbinfo_database     | ndbinfo  |
| ndbinfo_max_bytes    | 0        |
| ndbinfo_max_rows     | 10       |
| ndbinfo_offline      | OFF      |
| ndbinfo_show_hidden  | OFF      |
| ndbinfo_table_prefix | ndb$     |
| ndbinfo_version      | 459279   |
+----------------------+----------
//这里的5台机器都要这样做。

4,集群配置

(1) 管理节点配置

[root@h30101 local]# cd /usr/local/mysql/bin/
[root@h30101 bin]# cp ./ndb_m
ndb_mgm        ndb_mgmd       ndb_move_data  
[root@h30101 bin]# cp ./ndb_mgm* /usr/local/bin/
[root@h30101 local]# cd /var/lib/
[root@h30101 lib]# mkdir mysql-cluster
[root@h30101 lib]# cd mysql-cluster/
[root@h30101 mysql-cluster]# touch config.ini
[root@h30101 support-files]# pwd //注意,这里是配置文件的模板
/usr/local/mysql/support-files
[root@h30101 mysql-cluster]# cp /usr/local/mysql/support-files/config.medium.ini /var/lib/mysql-cluster/config.ini
[root@h30101 support-files]# cd /var/lib/mysql-cluster/
*******解释如下***
配置文件参数NoOfReplicas=2
简单解释
节点a,b
数据1,2


假如NoOfReplicas=1


则1存在a上,2存在b上
只要a或者b down掉,数据就不完整了,少了我们的数据1或者2


假如NoOfReplicas=2
则1存在a上,2的一个备份也存在a上
2存在b上,1的一个备份也存在b上
任何一个a或者b down掉,数据都是完整的

[root@h30101 mysql-cluster]# cat config.ini 
# MySQL NDB Cluster Medium Sample Configuration File
[NDBD DEFAULT]
NoOfReplicas=2


# Data Memory, Index Memory, and String Memory


DataMemory=300M
IndexMemory=30M
BackupMemory=64M


# Transaction Parameters


MaxNoOfConcurrentOperations=100000
MaxNoOfLocalOperations=100000


# Buffering and Logging


RedoBuffer=16M


# Logging and Checkpointing


NoOfFragmentLogFiles=200


# Metadata Objects


MaxNoOfAttributes=500
MaxNoOfTables=100


# Scans and Buffering


MaxNoOfConcurrentScans=100


[NDB_MGMD]
NodeId=1
HostName=192.168.30.101
ArbitrationRank=1
DataDir=/var/lib/mysql-cluster  


[mysqld]
NodeId=2
HostName=192.168.30.102 


[mysqld]
NodeId=3
HostName=192.168.30.103 


[NDBD]
NodeId=4
HostName=192.168.30.104
datadir=/usr/local/mysql/data




[NDBD]
NodeId=5
HostName=192.168.30.105
datadir=/usr/local/mysql/data



#必须有空的mysqld节点,不然数据节点断开后启动有报错  
[mysqld]
NodeId=6
[mysqld]
NodeId=7
[root@h30101 mysql-cluster]# 
管理节点通过config.ini文件配置来管理节点、SQL节点和数据节点的信息,通常最关心这三类节点的配置。分别定义如下:
[NDB DEFAULT]:表示每个数据节点的默认配置,在具体的每个节点[NDBD]中不用再写这些选项。
[NDB_MGMD]:表示配置管理节点的信息。
[NDBD]:表示每个数据节点的配置信息,可以配置多个数据节点信息。
[mysqld]:表示SQL节点的配置信息,可有多个,此节点的个数说明了用来连接数据节点的SQL节点总数

(2) 配置SQL节点和数据节点

SQL节点和数据节点的配置比较简单,只需要在MySQL Server上的配置文件(my.cnf)中添加如下内容即可:
sql节点:
[root@h30102 data]# cat /etc/my.cnf 
[MYSQL_CLUSTER]  
ndb-connectstring=192.168.30.101


# The MySQL server
[mysqld]
character_set_server=utf8
#运行NDB存储引擎
ndbcluster
#指定管理节点
ndb-connectstring=192.168.30.101
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M


datadir=/usr/local/mysql/data
user=mysql
server-id       = 102


#以下为mysql 主主模式的配置文件  
# 忽略mysql数据库复制  
binlog-ignore-db=mysql  
# 每次增长2  
auto-increment-increment = 2  
# 设置自动增长的字段的偏移量,即初始值为2  
auto-increment-offset = 1  


#skip-networking


# Replication Master Server (default)
log-bin=mysql-bin


# binary logging format - mixed recommended
binlog_format=mixed


# required unique id between 1 and 2^32 - 1
[mysqldump]
quick
max_allowed_packet = 16M


[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates


[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M


[mysqlhotcopy]
interactive-timeout
[root@h30102 data]# 
把这个修改后的可以替换到103和104、105上,注意备份一下。

(5),管理MySQL Cluster

mysql集群的启动顺序为:管理节点->数据节点->SQL节点
mysql集群的关闭顺序为,管理节点->数据节点->SQL节点


Cluster启动:
[root@h30101 mysql-cluster]# ndb_mgmd  --config-file /var/lib/mysql-cluster/config.ini  --initial
MySQL Cluster Management Server mysql-5.5.35 ndb-7.2.15
[root@h30101 mysql-cluster]# !ps
ps -ef|grep ndb
root      3088     1  0 22:53 ?        00:00:00 ndb_mgmd --config-file /var/lib/mysql-cluster/config.ini --initial
root      3099  2459  0 22:53 pts/1    00:00:00 grep ndb
[root@h30101 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=4 (not connected, accepting connect from 192.168.30.104)
id=5 (not connected, accepting connect from 192.168.30.105)


[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.30.101  (mysql-5.5.35 ndb-7.2.15)


[mysqld(API)]   4 node(s)
id=2 (not connected, accepting connect from 192.168.30.102)
id=3 (not connected, accepting connect from 192.168.30.103)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)


证明已经启动了。

# cd /usr/local/mysql/bin  
# cp ./ndb_mgm /usr/local/bin/  
# cp ./ndb_mgmd /usr/local/bin/  


备注:    管理节点只要ndb_mgm和ndb_mgmd两个文件和一个配置文件即可。
                因此把这三个文件复制到那里,那里就是管理节点了。
                ndb_mgmd是mysql cluster管理服务器,ndb_mgm是客户端管理工具。
备注:命令行中的ndb_mgmd是mysql cluster的管理服务器,后面的-f表示后面的参数是启动的参数配置文件。
如果在启动后过了几天又添加了一个数据节点,这时修改了配置文件启动时就必须加上--initial参数,不然添加的节点不会作用在mysql cluster中。

启动数据节点:104和105
[root@h30104 ~]# ndbd --initial
Unable to connect with connect string: nodeid=0,192.168.30.101:1186
Retrying every 5 seconds. Attempts left: 12 11 10 9 8
原因是修改了默认配置的端口号了
[root@h30104 ~]# ndbd --initial
2015-01-03 23:02:03 [ndbd] INFO     -- Angel connected to '192.168.30.101:1186'
2015-01-03 23:02:03 [ndbd] INFO     -- Angel allocated nodeid: 4
[root@h30104 ~]# 
[root@h30105 ~]# ndbd --initial
2015-01-03 23:02:53 [ndbd] INFO     -- Angel connected to '192.168.30.101:1186'
2015-01-03 23:02:53 [ndbd] INFO     -- Angel allocated nodeid: 5
[root@h30105 ~]# 
[root@h30102 data]# /etc/init.d/mysql.server start
Starting MySQL... SUCCESS! 
[root@h30103 data]# /etc/init.d/mysql.server start
Starting MySQL... SUCCESS! 


ndb_mgm> show 
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=4    @192.168.30.104  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0, *)
id=5    @192.168.30.105  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0)


[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.30.101  (mysql-5.5.35 ndb-7.2.15)


[mysqld(API)]   4 node(s)
id=2    @192.168.30.102  (mysql-5.5.35 ndb-7.2.15)
id=3    @192.168.30.103  (mysql-5.5.35 ndb-7.2.15)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)


ndb_mgm> 


(6),测试Cluster

登录sql节点,例如:102或者103。(这里是登录102)
mysql_102>create database test_db default charset=utf8;
Query OK, 1 row affected (0.04 sec)


mysql_102>use test_db;
Database changed
mysql_102>create table t1 (id int,name varchar(15)) engine=ndb;
Query OK, 0 rows affected (0.65 sec)


mysql_102>insert into t1(id,name) values(1,'北京市');
Query OK, 1 row affected (0.00 sec)


mysql_102>insert into t1(id,name) values(2,'天津市');
Query OK, 1 row affected (0.00 sec)


mysql_102>select * from t1;
+------+-----------+
| id   | name      |
+------+-----------+
|    1 | 北京市    |
|    2 | 天津市    |
+------+-----------+
2 rows in set (0.00 sec)


mysql_102>
登录103验证:
mysql_103>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| ndbinfo            |
| performance_schema |
| test               |
| test_db            |
+--------------------+
6 rows in set (0.00 sec)


mysql_103>use test_db;
Database changed
mysql_103>show tables;
+-------------------+
| Tables_in_test_db |
+-------------------+
| t1                |
+-------------------+
1 row in set (0.02 sec)


mysql_103>select * from t1;
+------+-----------+
| id   | name      |
+------+-----------+
|    2 | 天津市    |
|    1 | 北京市    |
+------+-----------+
2 rows in set (0.03 sec)


mysql_103>
注意,集群环境不会同步除了ndb引擎外的其他表。

故障测试


(1) 停止102上的mysqld
[root@h30102 data]# /etc/init.d/mysql.server stop
Shutting down MySQL.. SUCCESS! 
[root@h30102 data]# 
[root@h30102 data]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show 
Connected to Management Server at: 192.168.30.101:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=4    @192.168.30.104  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0, *)
id=5    @192.168.30.105  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0)


[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.30.101  (mysql-5.5.35 ndb-7.2.15)


[mysqld(API)]   4 node(s)
id=2 (not connected, accepting connect from 192.168.30.102)
id=3    @192.168.30.103  (mysql-5.5.35 ndb-7.2.15)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)


ndb_mgm> 
这里显示102已经无法连接了。
登录103查看数据是否还在?
mysql_103>show tables;
+-------------------+
| Tables_in_test_db |
+-------------------+
| t1                |
+-------------------+
1 row in set (0.00 sec)


mysql_103>select * from t1;
+------+-----------+
| id   | name      |
+------+-----------+
|    2 | 天津市    |
|    1 | 北京市    |
+------+-----------+
2 rows in set (0.00 sec)


mysql_103>


Cluster的关闭操作
[root@h30105 ~]# ndb_mgm -e shutdown
Connected to Management Server at: 192.168.30.101:1186
3 NDB Cluster node(s) have shutdown.
Disconnecting to
最后关闭sql节点
[root@h30102 data]# /etc/init.d/mysql.server stop
[root@h30103 data]# /etc/init.d/mysql.server stop

二、cluster的维护简介

[root@h30101 ~]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show 
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=4    @192.168.30.104  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0, *)
id=5    @192.168.30.105  (mysql-5.5.35 ndb-7.2.15, Nodegroup: 0)


[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.30.101  (mysql-5.5.35 ndb-7.2.15)


[mysqld(API)]   4 node(s)
id=2    @192.168.30.102  (mysql-5.5.35 ndb-7.2.15)
id=3    @192.168.30.103  (mysql-5.5.35 ndb-7.2.15)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)


ndb_mgm> help


cluster的集群日志
[root@h30101 mysql-cluster]# cd /var/lib/mysql-cluster/
[root@h30101 mysql-cluster]# ls
config.ini  ndb_1_cluster.log  ndb_1_out.log  ndb_1.pid
[root@h30101 mysql-cluster]# 
ndb_mgm> clusterlog info
Severities enabled: INFO WARNING ERROR CRITICAL ALERT 
ndb_mgm> clusterlog off
Cluster logging is disabled
ndb_mgm> clusterlog on
Cluster logging is enabled.


cluster备份包含三部分:
metadata(元数据):所有数据库表的定义;
table records(表记录):执行备份时实际保存在数据库表中的数据。
transaction log(事务日志):指明如何以及何时将数据保存在数据库中的连续记录。
ndb_mgm> start backup
Waiting for completed, this may take several minutes
Node 4: Backup 1 started from node 1
Node 4: Backup 1 started from node 1 completed
 StartGCP: 851 StopGCP: 854
 #Records: 2063 #LogRecords: 0
 Data: 52148 bytes Log: 0 bytes
现在去104和105上验证是否已经备份
[root@h30105 ~]# ll /usr/local/mysql/data/
total 28732
drwxr-x--- 3 root  root      4096 Jan  4 00:37 BACKUP
[root@h30104 ~]# ll /usr/local/mysql/data/
total 28732
drwxr-x--- 3 root  root      4096 Jan  4 00:37 BACKUP
恢复测试
创建测试表
在103上执行
mysql> use test_db;
mysql> CREATE TABLE `t2` (
    ->   `id` int(11) DEFAULT NULL,
    ->   `name` varchar(15) DEFAULT NULL
    -> ) ENGINE=ndbcluster DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.56 sec)
mysql> insert into t2 select * from t1;
Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0


mysql> select * from t2;
+------+-----------+
| id   | name      |
+------+-----------+
|    2 | 天津市    |
|    1 | 北京市    |
+------+-----------+
2 rows in set (0.00 sec)


在102上确认一下
mysql> show tables;
+-------------------+
| Tables_in_test_db |
+-------------------+
| t1                |
| t2                |
+-------------------+
2 rows in set (0.00 sec)


mysql> select * from t2;
+------+-----------+
| id   | name      |
+------+-----------+
|    1 | 北京市    |
|    2 | 天津市    |
+------+-----------+
2 rows in set (0.00 sec)


mysql> 
在管理节点上执行备份
ndb_mgm> start backup
Waiting for completed, this may take several minutes
Node 4: Backup 2 started from node 1
Node 4: Backup 2 started from node 1 completed
 StartGCP: 1330 StopGCP: 1333
 #Records: 2069 #LogRecords: 0
 Data: 52920 bytes Log: 0 bytes
ndb_mgm> 
[root@h30105 ~]# ll /usr/local/mysql/data/BACKUP/
total 8
drwxr-x--- 2 root root 4096 Jan  4 00:37 BACKUP-1
drwxr-x--- 2 root root 4096 Jan  4 00:54 BACKUP-2
mysql> drop table t2;
Query OK, 0 rows affected (0.35 sec)


[root@h30105 ~]# 
在192.168.30.104数据节点上执行恢复
[root@h30104 BACKUP]# ndb_mgm -e shutdown 
[root@h30101 mysql-cluster]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini 
MySQL Cluster Management Server mysql-5.5.35 ndb-7.2.15
[root@h30104 BACKUP]# ndbd --initial
2015-01-04 01:07:18 [ndbd] INFO     -- Angel connected to '192.168.30.101:1186'
2015-01-04 01:07:18 [ndbd] INFO     -- Angel allocated nodeid: 4
[root@h30104 BACKUP]# 
[root@h30105 ~]# ndbd --initial
在所有数据节点上执行
[root@h30105 ~]# ndb_restore -b 2 -n 5 -c host=192.168.30.101:1186 -m -r /usr/local/mysql/data/BACKUP/BACKUP-2/
Backup Id = 2
Nodeid = 5
backup path = /usr/local/mysql/data/BACKUP/BACKUP-2/
Opening file '/usr/local/mysql/data/BACKUP/BACKUP-2/BACKUP-2.5.ctl'
File size 22712 bytes
Backup version in files: ndb-6.3.11 ndb version: mysql-5.5.35 ndb-7.2.15
Stop GCP of Backup: 1332
Connected to ndb!!
Successfully restored table `test_db/def/t1`
Successfully restored table event REPL$test_db/t1
Successfully restored table `test_db/def/t2`
Successfully restored table event REPL$test_db/t2
Opening file '/usr/local/mysql/data/BACKUP/BACKUP-2/BACKUP-2-0.5.Data'
File size 26284 bytes
_____________________________________________________
Processing data in table: mysql/def/NDB$BLOB_7_3(8) fragment 1
_____________________________________________________
Processing data in table: test_db/def/t1(10) fragment 1
_____________________________________________________
Processing data in table: test_db/def/t2(11) fragment 1
_____________________________________________________
Processing data in table: mysql/def/ndb_index_stat_sample(5) fragment 1
_____________________________________________________
Processing data in table: sys/def/NDB$EVENTS_0(3) fragment 1
_____________________________________________________
Processing data in table: mysql/def/ndb_apply_status(9) fragment 1
_____________________________________________________
Processing data in table: mysql/def/ndb_index_stat_head(4) fragment 1
_____________________________________________________
Processing data in table: sys/def/SYSTAB_0(2) fragment 1
_____________________________________________________
Processing data in table: mysql/def/ndb_schema(7) fragment 1
Opening file '/usr/local/mysql/data/BACKUP/BACKUP-2/BACKUP-2.5.log'
File size 52 bytes
Restored 2 tuples and 0 log entries


NDBT_ProgramExit: 0 - OK


[root@h30105 ~]# 
[root@h30104 BACKUP-2]# ndb_restore -b 2 -n 4 -c host=192.168.30.101:1186 -m -r /usr/local/mysql/data/BACKUP/BACKUP-2/
[root@h30104 BACKUP-2]# ndb_restore -b 2 -n 4 -c host=192.168.30.101:1186  -r /usr/local/mysql/data/BACKUP/BACKUP-2/


登录192.168.102上执行查看


mysql> show tables;
+-------------------+
| Tables_in_test_db |
+-------------------+
| t1                |
| t2                |
+-------------------+
2 rows in set (0.02 sec)


mysql> select * from t2;
+------+-----------+
| id   | name      |
+------+-----------+
|    1 | 北京市    |
|    2 | 天津市    |
+------+-----------+
2 rows in set (0.07 sec)
成功...









0 0
原创粉丝点击