最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

mysql ndb集群備份數(shù)據(jù)庫和還原數(shù)據(jù)庫的方法

 更新時間:2011年12月17日 01:49:32   作者:  
中午剛剛弄明白了MYSQL集群的備份與恢復(fù)。寫下來,以后就不用為這個問題浪費時間了

1、在管理節(jié)點上進行備份。
ndb_mgm> start backup nowait
ndb_mgm> Node 3: Backup 4 started from node 1
Node 3: Backup 4 started from node 1 completed
StartGCP: 43010 StopGCP: 43013
#Records: 2138 #LogRecords: 0
Data: 53068 bytes Log: 0 bytes

ndb_mgm> shutdown
Node 3: Cluster shutdown initiated
Node 4: Cluster shutdown initiated
Node 4: Node shutdown completed.
Node 3: Node shutdown completed.
NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.
ndb_mgm> exit
2、刪掉SQL節(jié)點的數(shù)據(jù)。
DROP DATABASE TEST_CLUSTER;
、關(guān)閉MYSQLD服務(wù)器。
[root@localhost bin]# service mysqld stop
Shutting down MySQL... SUCCESS!
3、重新順序啟動所有節(jié)點。
[root@localhost mysql]# /usr/local/mysql/ndb_mgmd -f /etc/config.ini
[root@localhost data]# /usr/local/mysql/bin/ndbd --initial
我發(fā)現(xiàn)如果不帶這個 --initial選項的話,恢復(fù)會失敗。
[root@localhost bin]# service mysqld start
Starting MySQL SUCCESS!
4、在NDBD節(jié)點上進行恢復(fù)。(每個節(jié)點都得執(zhí)行一次,因為數(shù)據(jù)分散在兩個節(jié)點上)
第一個節(jié)點:
[root@localhost BACKUP]# /usr/local/mysql/bin/ndb_restore -n3 -b4 -r -m --backup_path=/usr/local/mysql/data/BACKUP/BACKUP-4/
-r開關(guān)是記錄集合。
-m是元數(shù)據(jù)。就是表和庫的SCHEMA。
Nodeid = 3
Backup Id = 4
backup path = /usr/local/mysql/data/BACKUP/BACKUP-4/
Ndb version in backup files: Version 5.1.21
Connected to ndb!!
Successfully restored table `test_cluster/def/lk4_test`
...
Successfully created index `PRIMARY` on `lk4_test`
...
_____________________________________________________
Processing data in table: test_cluster/def/lk4_test54) fragment 1
_____________________________________________________
...
Restored 37 tuples and 0 log entries

NDBT_ProgramExit: 0 - OK
第二個節(jié)點:
[root@localhost BACKUP-1]# /usr/local/mysql/bin/ndb_restore -n4 -b4 -r --backup_path=/usr/local/mysql/data/BACKUP/BACKUP-4/
Nodeid = 4
Backup Id = 4
backup path = /usr/local/mysql/data/BACKUP/BACKUP-4/
Ndb version in backup files: Version 5.1.21
Connected to ndb!!
_____________________________________________________
Processing data in table: sys/def/NDB$EVENTS_0(1) fragment 1
_____________________________________________________
Processing data in table: mysql/def/ndb_apply_status(4) fragment 1
_____________________________________________________
Processing data in table: mysql/def/NDB$BLOB_2_3(3) fragment 1
_____________________________________________________
Processing data in table: test/def/t11(5) fragment 1
_____________________________________________________
Processing data in table: sys/def/SYSTAB_0(0) fragment 1
_____________________________________________________
Processing data in table: mysql/def/ndb_schema(2) fragment 1
Restored 2 tuples and 0 log entries

NDBT_ProgramExit: 0 - OK

這里完成。
5、查看一下有沒有數(shù)據(jù),為了安全起見。
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
rows in set (0.00 sec)
沒有恢復(fù)的數(shù)據(jù)庫?
MYSQL現(xiàn)在必須重新建立SCHEMA。

mysql> create database test_cluster;
Query OK, 1 row affected (0.33 sec)

mysql> use test_cluster;
Database changed
mysql> show tables;
+------------------------------+
| Tables_in_test_cluster |
+------------------------------+
| lk4_test |
| ... |
+------------------------------+
rows in set (0.11 sec)

mysql> select * from cs_comment;
Empty set (0.00 sec)

不過MYSQL的backup 程序現(xiàn)在還只能進行完全備份。
[root@localhost BACKUP]# du -h
K ./BACKUP-2
K ./BACKUP-6
K ./BACKUP-4
K ./BACKUP-3
K ./BACKUP-1
K ./BACKUP-5
K .
6、在NDBD節(jié)點上進行恢復(fù)的時候有一個要注意的問題。
因為NDBD節(jié)點以 --initial 方式啟動的時候不會自動刪除undo 和 data 文件(即保存到磁盤上的表數(shù)據(jù)),所以得手動在每個NDBD節(jié)點上進行RM操作:

[root@node239 ndb_6_fs]# rm -rf *.dat

然后開始備份。
在MASTER上備份的時候要加 -m 開關(guān)。
在SLAVE上要加-d 而且不要-m開關(guān)。

具體步驟如下:
MASTER :

[root@localhost ndb_3_fs]# /usr/local/mysql/bin/ndb_restore -n3 -b1 -r -m --backup_path=/usr/local/mysql/data/BACKUP/BACKUP-1/
Nodeid = 3
Backup Id = 1
backup path = /usr/local/mysql/data/BACKUP/BACKUP-1/
Ndb version in backup files: Version 5.1.21
Connected to ndb!!
Creating logfile group: lg_1...done
Creating tablespace: ts_1...done
Creating datafile "data_1.dat"...done
Creating undofile "undo_1.dat"...done
Successfully restored table `test/def/t11`
Successfully restored table event REPL$test/t11
_____________________________________________________
Processing data in table: sys/def/NDB$EVENTS_0(1) fragment 0
_____________________________________________________
Processing data in table: mysql/def/NDB$BLOB_2_3(3) fragment 0
_____________________________________________________
Processing data in table: sys/def/SYSTAB_0(0) fragment 0
_____________________________________________________
Processing data in table: mysql/def/ndb_schema(2) fragment 0
_____________________________________________________
Processing data in table: mysql/def/ndb_apply_status(4) fragment 0
_____________________________________________________
Processing data in table: test/def/t11(10) fragment 0
Restored 26 tuples and 0 log entries

NDBT_ProgramExit: 0 - OK

其他的SLAVE上的操作:

[root@node239 ndb_6_fs]# /usr/local/mysql/bin/ndb_restore -n6 -b1 -r -d --backup_path=/usr/local/mysql/data/BACKUP/BACKUP-1/
Nodeid = 6
Backup Id = 1
backup path = /usr/local/mysql/data/BACKUP/BACKUP-1/
Ndb version in backup files: Version 5.1.21
Connected to ndb!!
_____________________________________________________
Processing data in table: sys/def/NDB$EVENTS_0(1) fragment 3
_____________________________________________________
Processing data in table: mysql/def/NDB$BLOB_2_3(3) fragment 3
_____________________________________________________
Processing data in table: sys/def/SYSTAB_0(0) fragment 3
_____________________________________________________
Processing data in table: mysql/def/ndb_schema(2) fragment 3
_____________________________________________________
Processing data in table: mysql/def/ndb_apply_status(4) fragment 3
_____________________________________________________
Processing data in table: test/def/t11(10) fragment 3
Restored 20 tuples and 0 log entries

NDBT_ProgramExit: 0 - OK


-d 開關(guān)的意思即:
-d, --no-restore-disk-objects
Dont restore disk objects (tablespace/logfilegroups etc)
既忽略表空間和分組空間

相關(guān)文章

  • mysql數(shù)據(jù)表的基本操作之表結(jié)構(gòu)操作,字段操作實例分析

    mysql數(shù)據(jù)表的基本操作之表結(jié)構(gòu)操作,字段操作實例分析

    這篇文章主要介紹了mysql數(shù)據(jù)表的基本操作之表結(jié)構(gòu)操作,字段操作,結(jié)合實例形式分析了mysql表結(jié)構(gòu)操作,字段操作常見增刪改查實現(xiàn)技巧與操作注意事項,需要的朋友可以參考下
    2020-04-04
  • MySQL Like語句的使用方法

    MySQL Like語句的使用方法

    本文介紹一下關(guān)于MySQL查詢字符串中包含字符的記錄一些常用方法,這里包括有REGEXP、FIND_IN_SET、Like
    2013-11-11
  • MySQL數(shù)據(jù)庫遠(yuǎn)程連接很慢的解決方案

    MySQL數(shù)據(jù)庫遠(yuǎn)程連接很慢的解決方案

    本文給大家分享的是MySQL數(shù)據(jù)庫遠(yuǎn)程連接很慢的解決方法,簡單的說就是開啟skip-name-resolve,非常的簡單實用,有需要的小伙伴可以參考下
    2016-12-12
  • Mysql刪除數(shù)據(jù)以及數(shù)據(jù)表的方法實例

    Mysql刪除數(shù)據(jù)以及數(shù)據(jù)表的方法實例

    這篇文章主要給大家介紹了關(guān)于Mysql刪除數(shù)據(jù)以及數(shù)據(jù)表的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • MySQL之select in 子查詢優(yōu)化的實現(xiàn)

    MySQL之select in 子查詢優(yōu)化的實現(xiàn)

    這篇文章主要介紹了MySQL之select in 子查詢優(yōu)化的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • Windows下使用Cygwin編譯MySQL客戶端

    Windows下使用Cygwin編譯MySQL客戶端

    這篇文章主要介紹了Windows下使用Cygwin編譯MySQL客戶端,本文詳細(xì)的講解了編譯過程,需要的朋友可以參考下
    2015-04-04
  • MySQL中的JSON_CONTAINS函數(shù)舉例詳解

    MySQL中的JSON_CONTAINS函數(shù)舉例詳解

    這篇文章主要給大家介紹了關(guān)于MySQL中JSON_CONTAINS函數(shù)舉例詳解的相關(guān)資料,MySQL JSON_CONTAINS函數(shù)可用于判斷JSON數(shù)組中是否包含某個元素,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-12-12
  • Mysql排序和分頁(order by&limit)及存在的坑

    Mysql排序和分頁(order by&limit)及存在的坑

    這篇文章主要介紹了Mysql排序和分頁(order by&limit)及存在的坑,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • MYSQL錯誤:Can’t open file: ‘×××.MYI’ (errno: 145)修復(fù)方法

    MYSQL錯誤:Can’t open file: ‘×××.MYI’ (errno: 14

    這個錯誤是典型的mysql表受損造成的,解決的辦法就是修復(fù)表,這個問題也是mysql經(jīng)常容易出現(xiàn)的,mysql表和索引損壞的幾率很大,但是修復(fù)也很方便
    2011-01-01
  • MySQL用戶授權(quán)管理及白名單的實現(xiàn)

    MySQL用戶授權(quán)管理及白名單的實現(xiàn)

    MySQL作為一種常用的關(guān)系型數(shù)據(jù)庫管理系統(tǒng),在權(quán)限管理和用戶認(rèn)證方面提供了豐富的功能和方案,本文主要介紹了MySQL用戶授權(quán)管理及白名單的實現(xiàn),感興趣的可以了解一下
    2023-09-09

最新評論

班戈县| 扶风县| 富平县| 闽清县| 和田市| 乌审旗| 东城区| 永善县| 潢川县| 叶城县| 龙海市| 遂平县| 丰顺县| 涟源市| 宁陵县| 吕梁市| 大冶市| 紫金县| 甘肃省| 嘉峪关市| 赞皇县| 盘山县| 甘南县| 武胜县| 宜兰市| 彭泽县| 松江区| 子长县| 青岛市| 芮城县| 中山市| 邻水| 延津县| 江北区| 林甸县| 溆浦县| 房山区| 平罗县| 察哈| 南陵县| 海南省|