- 论坛徽章:
- 0
|
官方指南里面的online backup of mysql cluster 讲到使用ndb_mgm这个management node的客户端进行备份,使用ndb_restore做恢复。比较复杂。
另外可以使用mysqldump进行备份,这个可以参考下面的。
Using mysqldump for Backups
Another way you can make backups is by using a tool called mysqldump. If you have been using MySQL with other storage engines, this tool should be familiar to you. Using mysqldump
to back up non-cluster objects, such as triggers and stored procedures,
works exactly the same as with non-clustered databases. Quite commonly
when doing this, you should use the --no-data flag with mysqldump
to ensure that you aren't backing up clustered data. If you want to use
it to back up clustered data, you need to follow a few special
restrictions related to using it with MySQL Cluster. The special
restrictions exist because MySQL Cluster doesn't have a repeatable read
isolation level and doesn't support distributed table locking (the two methods used by mysqldump for making consistent backups). Generally, you use mysqldump only if you needed to restore the data into a different system (that is, not into MySQL Cluster).
If you want to back up data with mysqldump in order for mysqldump to get a consistent view of the data, you need to enter single-user
mode before making the backup (or otherwise ensure that no one else is
going to be changing data while you're making the backup). This allows mysqldump
to get a consistent view of the data to backup. However, this will not
be an online backup because users will be denied access to the cluster
while this is continuing.
After you enter single-user mode, you can make a backup as you normally would. There are many different options you can use with mysqldump to change the format and other parameters. We recommend that you take a look at the output of mysqldump --help and at the webpage for mysqldump
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
), which includes many examples. You should make sure to use one of the backup methods that lock the tables first, such as the --lock-tables option or the --master-data option. With mysqldump, you can choose what pieces to back up as well, whereas the native hot backup tool always does all the data for all tables. (
The following is an example of a mysqldump command to back up the world database data while in single-user mode:
shell> mysqldump -u root -p --lock-tables world > backup-world.sql
Single-User Mode
Single-user mode allows you to lock down a cluster
so that it is accessible only to a single MySQL server (or similar
connection to the cluster). All other servers give an error when
someone tries to access one of the tables stored in the cluster.
To enter single-user mode, you issue the command ENTER SINGLE USER MODE #, where #
is the node ID of the node you want to allow to communicate with the
cluster. Entering this mode can take a brief time to complete; you can
see when you have entered single-user mode by using the ALL STATUS command or the SHOW command. When you are done with the mode, you can use the command EXIT SINGLE USER MODE to resume normal operation.
The following is an example of a session:
ndb_mgm> ENTER SINGLE USER MODE 4
Entering single user mode
Access will be granted for API node 4 only.
Use ALL STATUS to see when single user mode has been entered.
ndb_mgm> ALL STATUS
Node 2: single user mode (Version 5.0.13)
Node 3: single user mode (Version 5.0.13)
ndb_mgm> SHOW
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @127.0.0.1 (Version: 5.0.13, single user mode, Nodegroup: 0)
id=3 @127.0.0.1 (Version: 5.0.13, single user mode, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @127.0.0.1 (Version: 5.0.13)
[mysqld(API)] 2 node(s)
id=4 @127.0.0.1 (Version: 5.0.13)
id=5 (not connected, accepting connect from any host)
ndb_mgm> EXIT SINGLE USER MODE
Exiting single user mode in progress.
Use ALL STATUS to see when single user mode has been exited.
ndb_mgm> ALL STATUS
Node 2: started (Version 5.0.13)
Node 3: started (Version 5.0.13)
Single-user mode is useful for a few different things. First, it is somewhat like mysqldump,
as mentioned previously. Second, it is useful when you're restoring a
backup into MySQL Cluster. When you restore a backup (either from mysqldump
or by using the hot backup method), you should normally enter
single-user mode. In this way, restoring a backup is not a hot
operation. Finally, there are some maintenance tasks for which you
generally want to enter single-user mode as well. This includes tasks
such as ALTER TABLE, which need to be synchronized across all the MySQL servers.
The following is a typical example of the usage of this mode in order to ensure you make a consistent backup of the world database:
shell> ndb_mgm -e "ENTER SINGLE USER MODE 4";sleep 10;mysqldump -u root -p --lock-tables world > backup-world.sql;
ndb_mgm -e "EXIT SINGLE USER MODE";
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/74751/showart_1678964.html |
|