程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> PHP進修散記 2012_01_07(MySQL)

PHP進修散記 2012_01_07(MySQL)

編輯:MySQL綜合教程

PHP進修散記 2012_01_07(MySQL)。本站提示廣大學習愛好者:(PHP進修散記 2012_01_07(MySQL))文章只能為提供參考,不一定能成為您想要的結果。以下是PHP進修散記 2012_01_07(MySQL)正文


1、在治理節點長進行備份。
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節點的數據。
DROP DATABASE TEST_CLUSTER;
、封閉MYSQLD辦事器。
[root@localhost bin]# service mysqld stop
Shutting down MySQL... SUCCESS!
3、從新次序啟動一切節點。
[root@localhost mysql]# /usr/local/mysql/ndb_mgmd -f /etc/config.ini
[root@localhost data]# /usr/local/mysql/bin/ndbd --initial
我發明假如不帶這個 --initial選項的話,恢復會掉敗。
[root@localhost bin]# service mysqld start
Starting MySQL SUCCESS!
4、在NDBD節點長進行恢復。(每一個節點都得履行一次,由於數據疏散在兩個節點上)
第一個節點:
[root@localhost BACKUP]# /usr/local/mysql/bin/ndb_restore -n3 -b4 -r -m --backup_path=/usr/local/mysql/data/BACKUP/BACKUP-4/
-r開關是記載聚集。
-m是元數據。就是表和庫的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
第二個節點:
[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、檢查一下有無數據,為了平安起見。
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
rows in set (0.00 sec)
沒有恢復的數據庫?
MYSQL如今必需從新樹立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 法式如今還只能停止完整備份。
[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節點長進行恢復的時刻有一個要留意的成績。
由於NDBD節點以 --initial 方法啟動的時刻不會主動刪除undo 和 data 文件(即保留到磁盤上的表數據),所以到手動在每一個NDBD節點長進行RM操作:

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

然後開端備份。
在MASTER上備份的時刻要加 -m 開關。
在SLAVE上要加-d 並且不要-m開關。

詳細步調以下:
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 開關的意思即:
-d, --no-restore-disk-objects
Dont restore disk objects (tablespace/logfilegroups etc)
既疏忽表空間和分組空間

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved