说明: 我的os为rhel4 up4 , 总共有三台机器,一台为备份机ip为172.17.61.124,另外两台为db1(ip为172.17.61.125) 和db2(ip为172.17.61.126),实际上是将db1和db2上的数据库备份到备份机(*.*.*.124)上来
1:
下载zrm软件如图
2:在124上安装这两个rpm包。
[root@localhost zrm]# rpm -ivh MySQL-zrm-2.0-1.noarch.rpm
warning: MySQL-zrm-2.0-1.noarch.rpm: V3 DSA signature: NOKEY, key ID 3c5d1c92
Preparing... ########################################### [100%]
1:MySQL-zrm ########################################### [100%]
[root@localhost zrm]# rpm -ivh MySQL-zrm-client-2.0-1.noarch.rpm
warning: MySQL-zrm-client-2.0-1.noarch.rpm: V3 DSA signature: NOKEY, key ID 3c5d1c92
Preparing... ########################################### [100%]
1:MySQL-zrm-client ########################################### [100%]
Feb 23 2010 11:39:37: Reloading xinetd configuration...Reloading configuration: [ OK ]
zrm已经成功安装在server1上。
查看安装后的zrm如下:
[root@localhost etc]# cd /etc/mysql-zrm/
[root@localhost mysql-zrm]# ls
mysql-zrm.conf mysql-zrm-release mysql-zrm-reporter.conf RSS.header
如果安装失败,就要去安装perl-DBI* ,方法同上
成功安装后,可以通过一下命令来检测:
[root@localhost zrm]# rpm -qa | grep perl-DBI
perl-DBI-1.40-8
3:创建两个目录, DailyBackupDB1(用来备份db1上的数据)和DailyBackupDB2(用来备份db2上的数据),同时要修改这两个目录的权限为mysql,防止因权限不够,而不能写入!命令如下:
[root@localhost mysql-zrm]# mkdir /etc/mysql-zrm/DailyBackupDB1 [root@localhost mysql-zrm]# mkdir /etc/mysql-zrm/DailyBackupDB2 [root@localhost mysql-zrm]# ll total 32 drwxr-xr-x 2 root root 4096 Feb 23 11:44 DailyBackupDB1 drwxr-xr-x 2 root root 4096 Feb 23 11:44 DailyBackupDB2 -rwxrwx--- 1 mysql mysql 10936 Apr 8 2008 mysql-zrm.conf -rwxrwx--- 1 mysql mysql 46 Apr 8 2008 mysql-zrm-release -rwxrwx--- 1 mysql mysql 3083 Apr 8 2008 mysql-zrm-reporter.conf -rw-rw---- 1 mysql mysql 596 Apr 8 2008 RSS.header [root@localhost mysql-zrm]# chown -R mysql: DailyBackupDB1 [root@localhost mysql-zrm]# chown -R mysql: DailyBackupDB2 [root@localhost mysql-zrm]# ll total 32 drwxr-xr-x 2 mysql mysql 4096 Feb 23 11:44 DailyBackupDB1 drwxr-xr-x 2 mysql mysql 4096 Feb 23 11:44 DailyBackupDB2 -rwxrwx--- 1 mysql mysql 10936 Apr 8 2008 mysql-zrm.conf -rwxrwx--- 1 mysql mysql 46 Apr 8 2008 mysql-zrm-release -rwxrwx--- 1 mysql mysql 3083 Apr 8 2008 mysql-zrm-reporter.conf -rw-rw---- 1 mysql mysql 596 Apr 8 2008 RSS.header
|
4:复制mysql-zrm.conf到DailyBackupDB1中并修改 /etc/mysql-zrm/DailyBackupDB1/mysql-zrm.conf的内容:
[root@localhost DailyBackupDB1]# cat mysql-zrm.conf | grep -v ^# backup-level=1 ##0表示full backup,1表示增量备份,默认为0,我修改为1 backup-mode=logical snapshot-plugin="/usr/share/mysql-zrm/plugins/lvm-snapshot.pl" destination=/opt/backup/mysql ##备份文件存储的位置,默认为/var/lib/my-zrm, 我将其修改为/opt/backup/mysql,当然这几个目录必须存在! compress=1 ##紫色的部分是备份时加密相关的数据的设置! compress-plugin=/usr/bin/gzip encrypt=1 encrypt-plugin="/usr/share/mysql-zrm/plugins/encrypt.pl" decrypt-option="-d" databases=moviesmyisam ##指定需要备份的数据库的名称 user="backupuser" ##指定备份的用户 password="backupuser" ##指定备份用户对应的密码 host="db2.domain.com" ##数据库(moviesmyisam)所在机器名!
copy-plugin=/usr/share/mysql-zrm/plugins/socket-copy.pl
如果没有dns server , 必须在/etc/hosts中进行添加:
[root@localhost DailyBackupDB1]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 172.17.61.125 db1.domain.com ##添加部分 172.17.61.126 db2.domain.com 创建目录:
mkdir -p /opt/backup/mysql
chown -R mysql: /opt/backup
|
5:为了备份时能加密,创建包含passphrae的文件
[root@localhost DailyBackupDB1]# touch /etc/mysql-zrm/.passphrase [root@localhost DailyBackupDB1]# echo encrytpass > /etc/mysql-zrm/.passphrase [root@localhost DailyBackupDB1]# chmod 700 /etc/mysql-zrm/.passphrase [root@localhost DailyBackupDB1]# cat /etc/mysql-zrm/.passphrase #查看是否写入 encrytpass
|
6:为了使得加密正常,创建/root/.gnupg
[[root@localhost ~]# mkdir /root/.gnupg [root@localhost ~]# chmod 600 .gnupg/ [root@localhost ~]# cd .gnupg/ [root@localhost .gnupg]# ls [root@localhost .gnupg]# 此时文件夹为空。
但如果成功备份后,则就有新的文件生成:
[root@localhost .gnupg]# cd /root/.gnupg/ [root@localhost .gnupg]# ls pubring.gpg random_seed secring.gpg [root@localhost .gnupg]#
|
到此在124上的设置基本完成!
下面是db1上的相关设置:
7:[root@localhost home]# rpm -ivh MySQL-zrm-client-2.0-1.noarch.rpm
warning: MySQL-zrm-client-2.0-1.noarch.rpm: V3 DSA signature: NOKEY, key ID 3c5d1c92
Preparing... ########################################### [100%]
1:MySQL-zrm-client ########################################### [100%]
Feb 23 2010 12:16:40: Reloading xinetd configuration...Reloading configuration: [ OK ]
为了能使用机器名,添加ip和域名的对应。内容如下:
[root@localhost mysql]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
172.17.61.124 server1.domain.com ##如果不这样对应,ping不通域名
172.17.61.126 db2.domain.com
[root@localhost data]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.0.83-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.02 sec)
mysql> create database moviesmyisam; Query OK, 1 row affected (0.01 sec)
mysql> use moviesmyisam; Database changed mysql> create table person(id int ,name varchar(20)); Query OK, 0 rows affected (0.01 sec)
mysql> insert into person values(1,'zhang'); Query OK, 1 row affected (0.00 sec)
mysql> insert into person values(2,'li'); Query OK, 1 row affected (0.00 sec)
mysql> select * from person; +------+-------+ | id | name | +------+-------+ | 1 | zhang | | 2 | li | +------+-------+ 2 rows in set (0.00 sec)
mysql> grant lock tables,select,file,create,drop,index,shutdown,alter,insert,super,reload on *.* to 'backupuser'@'server1.domain.com' identified by 'backupuser'; mysql> flush privileges;
mysql> quit mysql> quit ##主要server1.domain.com这个必须在本机上能识别出来。
[root@* ~]# ping server1.domain.com #确保server1.domain.com能够被识别 PING server1.domain.com (172.17.61.124) 56(84) bytes of data. 64 bytes from server1.domain.com (172.17.61.124): icmp_seq=0 ttl=64 time=3.12 ms 64 bytes from server1.domain.com (172.17.61.124): icmp_seq=1 ttl=64 time=0.233 ms
来测试。
重启mysql
[root@localhost ~]# service mysqld restart Shutting down MySQL.. [ OK ] Starting MySQL. [ OK ] [root@localhost ~]#
|
下面是对db2上的设置
8:[root@localhost home]# rpm -ivh MySQL-zrm-client-2.0-1.noarch.rpm
warning: MySQL-zrm-client-2.0-1.noarch.rpm: V3 DSA signature: NOKEY, key ID 3c5d1c92
Preparing... ########################################### [100%]
1:MySQL-zrm-client ########################################### [100%]
Feb 23 2010 13:51:39: Reloading xinetd configuration...Reloading configuration: [ OK ]
复制mysql-zrm.conf到/etc/mysql-zrm/DailyBackupDB2DailyBackupDB12
[root@* zrm]# cp /etc/mysql-zrm/mysql-zrm.conf /etc/mysql-zrm/DailyBackupDB2
修改 /etc/mysql-zrm/DailyBackupDB2/mysql-zrm.conf的内容如下:
backup-level=1 backup-mode=logical snapshot-plugin="/usr/share/mysql-zrm/plugins/lvm-snapshot.pl" destination=/opt/backup/mysql compress=1 compress-plugin=/usr/bin/gzip encrypt=1 encrypt-plugin="/usr/share/mysql-zrm/plugins/encrypt.pl"
decrypt-option="-d" databases=moviesinnodb ##需要备份的数据库 ,蓝色字体需要自己修改 user="backupuser" password="backupuser" host="db2.domain.com" mailto= copy-plugin=/usr/share/mysql-zrm/plugins/socket-copy.pl ssh-user="mysql" ##表示远程db上的用户
接着在db2上创建数据库moviesinnodb和用户backupuser:
[root@localhost home]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.0.83-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.02 sec)
mysql> create database moviesinnodb; Query OK, 1 row affected (0.02 sec)
mysql> use moviesinnodb; Database changed mysql> create table customer(id int ,name varchar(20),age int); Query OK, 0 rows affected (0.01 sec)
mysql> insert into customer values(1,'zhang',26); Query OK, 1 row affected (0.00 sec)
mysql> insert into customer values(2,'zhu',23); Query OK, 1 row affected (0.00 sec)
mysql> select * from customer; +------+-------+------+ | id | name | age | +------+-------+------+ | 1 | zhang | 26 | | 2 | zhu | 23 | +------+-------+------+ 2 rows in set (0.00 sec)
mysql> grant lock tables,select,file,create,drop,index,shutdown,alter,insert,super,reload on *.* to identified by 'backupuser'; Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)
mysql> quit Bye 在backup server的root用户和db2的mysql用户建立无密码的ssh认证
[root@localhost ~]# mkdir /root/.ssh [root@localhost ~]# chmod 700 /root/.ssh/ [root@localhost ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): 回车即可 Enter same passphrase again: 回车即可 Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 3d:ea:6f:97:00:63:33:1e:f0:8f:17:47:e7:17:83:0e [root@localhost ~]# cd .ssh/ [root@localhost .ssh]# ls id_rsa id_rsa.pub 显然文件已经生成!
将文件复制到db2上如下:
[root@localhost .ssh]# scp id_rsa.pub 172.17.61.126:/home/ The authenticity of host '172.17.61.126 (172.17.61.126)' can't be established. RSA key fingerprint is 46:75:f2:73:c7:72:7d:61:c8:05:e7:37:42:8a:30:b4. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.17.61.126' (RSA) to the list of known hosts. password: id_rsa.pub 100% 236 0.2KB/s 00:00 [root@localhost .ssh]# 在db2上
home]# ls amanda-backup_client-2.6.1-1.rhel4.i386.rpm MySQL-zrm-client-2.0-1.noarch.rpm id_rsa.pub software mysql xliu [root@localhost home]# cp id_rsa.pub /home/mysql/.ssh/ [root@localhost home]# chown mysql: /home/mysql/.ssh/id_rsa.pub [root@localhost home]# su - mysql [mysql@localhost ~]$ ls [mysql@localhost ~]$ cd .ssh/ [mysql@localhost .ssh]$ ll total 4 -rw-r--r-- 1 mysql mysql 236 Feb 23 14:14 id_rsa.pub [mysql@localhost .ssh]$ mv id_rsa.pub authorized_keys [mysql@localhost .ssh]$ ll total 4 -rw-r--r-- 1 mysql mysql 236 Feb 23 14:14 authorized_keys
验证无密码的ssh认证是否搭建成功:如下: [root@localhost .ssh]# ssh Last login: Wed Feb 3 14:31:41 2010 from server1.domain.com [mysql@localhost ~]$ ls 显然无密码的ssh认证已经搭建成功!
测试:在server1上运行:
[root@localhost DailyBackupDB1]# mysql-zrm-scheduler --backup-set DailyBackupDB1 --backup-level 0 --now schedule:INFO: ZRM for MySQL Community Edition - version 2.0 Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log backup:INFO: ZRM for MySQL Community Edition - version 2.0 DailyBackupDB1:backup:INFO: START OF BACKUP DailyBackupDB1:backup:INFO: PHASE START: Initialization DailyBackupDB1:backup:INFO: backup-set=DailyBackupDB1 DailyBackupDB1:backup:INFO: backup-date=20100223145216 DailyBackupDB1:backup:INFO: mysql-server-os=Linux/Unix DailyBackupDB1:backup:INFO: host=db1.domain.com DailyBackupDB1:backup:INFO: backup-date-epoch=1266907936 DailyBackupDB1:backup:INFO: mysql-zrm-version=ZRM for MySQL Community Edition - version 2.0 DailyBackupDB1:backup:INFO: mysql-version=5.0.83-log DailyBackupDB1:backup:INFO: backup-directory=/opt/backup/mysql/DailyBackupDB1/20100223145216 DailyBackupDB1:backup:INFO: backup-level=0 DailyBackupDB1:backup:INFO: backup-mode=logical DailyBackupDB1:backup:INFO: PHASE END: Initialization DailyBackupDB1:backup:INFO: PHASE START: Running pre backup plugin DailyBackupDB1:backup:INFO: PHASE END: Running pre backup plugin DailyBackupDB1:backup:INFO: PHASE START: Flushing logs DailyBackupDB1:backup:INFO: PHASE END: Flushing logs DailyBackupDB1:backup:INFO: PHASE START: Creating logical backup DailyBackupDB1:backup:INFO: logical-databases=moviesmyisam DailyBackupDB1:backup:INFO: PHASE END: Creating logical backup DailyBackupDB1:backup:INFO: PHASE START: Calculating backup size & checksums DailyBackupDB1:backup:INFO: next-binlog=mysql-bin.000015 DailyBackupDB1:backup:INFO: backup-size=0.01 MB DailyBackupDB1:backup:INFO: PHASE END: Calculating backup size & checksums DailyBackupDB1:backup:INFO: PHASE START: Compression/Encryption DailyBackupDB1:backup:INFO: compress=/usr/bin/gzip DailyBackupDB1:backup:INFO: encrypt=/usr/share/mysql-zrm/plugins/encrypt.pl DailyBackupDB1:backup:INFO: decrypt-option=-d DailyBackupDB1:backup:INFO: backup-size-compressed=0.00 MB DailyBackupDB1:backup:INFO: PHASE END: Compression/Encryption DailyBackupDB1:backup:INFO: read-locks-time=00:00:00 DailyBackupDB1:backup:INFO: flush-logs-time=00:00:00 DailyBackupDB1:backup:INFO: compress-encrypt-time=00:00:00 DailyBackupDB1:backup:INFO: backup-time=00:00:00 DailyBackupDB1:backup:INFO: backup-status=Backup succeeded DailyBackupDB1:backup:INFO: Backup succeeded DailyBackupDB1:backup:INFO: PHASE START: Running post backup plugin DailyBackupDB1:backup:INFO: PHASE END: Running post backup plugin DailyBackupDB1:backup:INFO: PHASE START: Mailing backup report DailyBackupDB1:backup:INFO: PHASE END: Mailing backup report DailyBackupDB1:backup:INFO: PHASE START: Cleanup DailyBackupDB1:backup:INFO: PHASE END: Cleanup DailyBackupDB1:backup:INFO: END OF BACKUP /usr/bin/mysql-zrm started successfully
也可到/opt/backup/mysql目录下去验证!
[root@localhost 20100223145432]# cd /opt/backup/mysql/DailyBackupDB1/20100223145432/ [root@localhost 20100223145432]# ls backup-data index zrm_checksum [root@localhost 20100223145432]#
|
在过程遇到了问题:
1:[root@localhost log]# cd /var/log/mysql-zrm/
[root@localhost mysql-zrm]# ls
mysql-zrm.log mysql-zrm-reporter.log mysql-zrm-scheduler.log
[root@localhost mysql-zrm]# vi mysql-zrm.log
Tue Feb 23 14:21:26 2010: DailyBackupDB1:backup:ERROR: Output of command: 'mysqlhotcopy' is {
Out of memory!
}
Tue Feb 23 14:21:26 2010: DailyBackupDB1:backup:ERROR: mysqlhotcopy did not succeed. Command used is /usr/share/mysql-zrm/plugins/socket-copy.pl --mysqlhotcopy --user="backupuser" --password="*****" --host="db1.domain.com" --quiet moviesmyisam "/opt/backup/mysql/DailyBackupDB1/20100223142124" > /tmp/lRJMZLBIHp 2>&1 Return value is 256
Tue Feb 23 14:21:26 2010: DailyBackupDB1:backup:INFO: PHASE START: Cleanup
Tue Feb 23 14:21:26 2010: DailyBackupDB1:backup:INFO: backup-status=Backup failed
这个在网上找了好久都没有答案,我自己猜的,结果对了!
原因:zrm默认使用raw备份方式,只需要将#backup-mode=raw的注释去掉,并将raw修改为logical即可解决!
修改后如下:
[root@localhost DailyBackupDB1]# cat mysql-zrm.conf | grep -n backup-mode
43:backup-mode=logical
46:# for "raw" backup-mode and if the MySQL database data are stored in
2:[root@localhost DailyBackupDB2]# mysql-zrm-scheduler --backup-set DailyBackupDB2 --backup-level 0 --now
schedule:INFO: ZRM for MySQL Community Edition - version 2.0
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
backup:INFO: ZRM for MySQL Community Edition - version 2.0
DailyBackupDB2:backup:INFO: START OF BACKUP
DailyBackupDB2:backup:INFO: PHASE START: Initialization
DailyBackupDB2:backup:ERROR: Please specify the --encrypt-plugin
DailyBackupDB2:backup:INFO: PHASE START: Cleanup
DailyBackupDB2:backup:INFO: PHASE END: Cleanup
DailyBackupDB2:backup:INFO: END OF BACKUP
ERROR: /usr/bin/mysql-zrm did not finish successfully
解决方法:
将/etc/mysql-zrm/DailyBackupDB2/mysql-zrm.conf中
#encrypt-plugin="/usr/share/mysql-zrm/plugins/encrypt.pl"的注释去掉即可!
确认备份的完整性:
[root@localhost .gnupg]# mysql-zrm --action verify-backup --backup-set DailyBackupDB1
verify-backup:INFO: ZRM for MySQL Community Edition - version 2.0
DailyBackupDB1:verify-backup:INFO: Verification successful
[root@localhost .gnupg]# mysql-zrm --action verify-backup --backup-set DailyBackupDB2
verify-backup:INFO: ZRM for MySQL Community Edition - version 2.0
DailyBackupDB2:verify-backup:INFO: Verification successful
查看备份的性能:
[root@localhost .gnupg]# mysql-zrm-reporter --show backup-performance-info
reporter:WARNING: Backup root directory not specified, Assigning default value as /var/lib/mysql-zrm
REPORT TYPE : backup-performance-info
[root@localhost .gnupg]# mysql-zrm-reporter --help
USAGE :
/usr/bin/mysql-zrm-reporter
[--fields ]
[--destination ]
[--where ]
[--show [ backup-performance-info | restore-info | selective-restore-info |
[ replication-info | backup-app-performance-info
[--type ]
[--output ]
[--latest
[--noheader
[--help ]
Valid field names are : backup-date backup-directory backup-level backup-set backup-size backup-size-compressed backup-status backup-time comment compress compress-encrypt-time encrypt flush-logs-time host incremental logical-databases logical-tables mysql-version raw-databases raw-databases-snapshot raw-tables raw-tables-snapshot read-locks-time replication retention-policy slave-load-files
Please refer to mysql-zrm-reporter man page for more details
[root@localhost .gnupg]# mysql-zrm-reporter --show backup-performance-info --destination /opt/backup/mysql/
REPORT TYPE : backup-performance-info
backup_set backup_date backup_level backup_size backup_size_compressed backup_time compress_encrypt_time
----------------------------------------------------------------------------------------------------------------------------------------------
DailyBackupDB2 Tue 23 Feb 2010 03:09:45 0 0.01 MB 0.00 MB 00:00:01 00:00:00
PM CST
DailyBackupDB1 Tue 23 Feb 2010 02:54:32 0 0.01 MB 0.00 MB 00:00:00 00:00:00
PM CST
配置自动备份:
为DailyBackupDB1设置,在monday-friday 1:00pm进行增量备份,周六1:00am进行完全备份。
[root@localhost .gnupg]# mysql-zrm-scheduler --add --interval weekly --start-time 1:00 --day-of-week 1-5 --backup-level 1 --backup-set DailyBackupDB1
schedule:INFO: ZRM for MySQL Community Edition - version 2.0
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
DONE
[root@localhost .gnupg]# mysql-zrm-scheduler --add --interval weekly --start-time 1:00 --day-of-week 6 --backup-level 0 --backup-set DailyBackupDB1
schedule:INFO: ZRM for MySQL Community Edition - version 2.0
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
DONE
[root@localhost .gnupg]# mysql-zrm-scheduler --query ##查询功能
schedule:INFO: ZRM for MySQL Community Edition - version 2.0
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
0 1 * * 1-5 /usr/bin/zrm-pre-scheduler --action backup --backup-set DailyBackup1 --backup-level 1 --interval weekly
0 1 * * 6 /usr/bin/zrm-pre-scheduler --action backup --backup-set DailyBackup1 --backup-level 0 --interval weekly
0 1 * * 1-5 /usr/bin/zrm-pre-scheduler --action backup --backup-set DailyBackupDB1 --backup-level 1 --interval weekly
0 1 * * 6 /usr/bin/zrm-pre-scheduler --action backup --backup-set DailyBackupDB1 --backup-level 0 --interval weekly
数据库的恢复:
我现将db1上的moviesmyisam数据库删除:
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.0.83-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| moviesmyisam |
| mysql |
| test |
+--------------------+
4 rows in set (0.02 sec)
mysql> drop database moviesmyisam;
Query OK, 1 row affected (0.02 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
在server1上进行恢复:如下:
[root@localhost .gnupg]# mysql-zrm-reporter --show restore-info --where backup-set=DailyBackupDB1
REPORT TYPE : restore-info
backup_set backup_date backup_level backup_directory backup_status comment
-----------------------------------------------------------------------------------------------------------------------------------------------------
DailyBackupDB1 Tue 23 Feb 2010 02:54:32 0 /opt/backup/mysql/DailyBackupDB1/2010022 Backup succeeded ----
PM CST 3145432
[root@localhost .gnupg]# mysql-zrm --action restore --backup-set DailyBackupDB1 --source-directory /opt/backup/mysql/DailyBackupDB1/201002231
45432
restore:INFO: ZRM for MySQL Community Edition - version 2.0
DailyBackupDB1:restore:INFO: Restored database(s) from logical backup: moviesmyisam
DailyBackupDB1:restore:INFO: Restore done in 0 seconds.
然后在db1查看:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| moviesmyisam |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use moviesmyisam;
Database changed
mysql> show tables;
+------------------------+
| Tables_in_moviesmyisam |
+------------------------+
| person |
+------------------------+
1 row in set (0.00 sec)
mysql> select * from person;
+------+-------+
| id | name |
+------+-------+
| 1 | zhang |
| 2 | li |
+------+-------+
2 rows in set (0.00 sec)
mysql>
在恢复过程中也遇到了个小问题: