mysqlhotcopy hot spare tools and experience summary

Available today tried it MYSQLHOTCOPY this fast hot standby MYISAM engine tools.
( This article is the case for a single server, multi-server will be added later related operations )
compare his and MYSQLDUMP of:
1, the former is in the sense of a fast COPY file, which is a database-side set of SQL statements.
2, the former can only run on the machine where the directory database, which can be used in remote client. However, the backup file is stored on the server.
3, the same places are performed online TABLES LOCK TABLES and UNLOCK
4, the former need only restore backup files to the source directory COPY be covered, which requires pour SQL files to their original library. ( Source or \ . Or MySQL < backup file )
step by MYSQLHOTCOPY backup:
1, there is no PERL-DBD module installed
on my machine:
[ root @ localhost the Data ] # RPM -qa | grep perl-DBD | grep MySQL

perl - DBD - MySQL - 3 . 0007- . 1 . FC6
2, assign a dedicated database for backup in the user segment
MySQL > Grant SELECT , reload , Lock Tables ON * . * To 'hotcopyer' @ 'localhost' IDENTIFIED by '123456' ;
Query the OK , 0 rows affected ( 0 . 00 sec )

MySQL > flush privileges ;
Query the OK , 0 rows affected ( 0 . 00 sec )

3, add the user's personal or visit /etc/my.cnf master file .my.cnf inside
[mysqlhotcopy]
interactive-timeout
user=hotcopyer
password=123456
port=3306
4、开始备份。
[root@localhost ~]# mysqlhotcopy t_girl t_girl_new

Locked 4 tables in 0 seconds.
Flushed tables (`t_girl`.`category`, `t_girl`.`category_part`, `t_girl`.`id`, `t_girl`.`parent`) in 0 seconds.
Copying 22 files...
Copying indices for 0 files...
Unlocked tables.
mysqlhotcopy copied 4 tables (22 files) in 5 seconds (5 seconds overall).

备份后的目录:
[root@localhost data]# du -h | grep t_girl

213M ./t_girl
213M ./t_girl_copy
[root@localhost ~]#

5、MYSQLHOTCOPY用法详解。
1)、mysqlhotcopy 原数据库名,新数据库名
[root@localhost ~]# mysqlhotcopy t_girl t_girl_new

Locked 4 tables in 0 seconds.
Flushed tables (`t_girl`.`category`, `t_girl`.`category_part`, `t_girl`.`id`, `t_girl`.`parent`) in 0 seconds.
Copying 22 files...
Copying indices for 0 files...
Unlocked tables.
mysqlhotcopy copied 4 tables (22 files) in 5 seconds (5 seconds overall).
2)、mysqlhotcopy 原数据库名,备份的目录
[root@localhost ~]# mysqlhotcopy t_girl /tmp/

Locked 4 tables in 0 seconds.
Flushed tables (`t_girl`.`category`, `t_girl`.`category_part`, `t_girl`.`id`, `t_girl`.` Parent` ) in 0 seconds The .
Copying 22 is Files . . .
Copying indices for 0 Files . . .
Unlocked Tables .
Mysqlhotcopy works copied appears. 4 Tables ( 22 is Files ) in. 6 seconds The ( . 6 seconds The Overall ) .
. 3), a single table supports regular expression
( except id table )
[ the root @ localhost Data ] # mysqlhotcopy works t_girl./~id/

the Using Copy suffix '_copy'
Locked in tables. 3 0 seconds The .
Flushed tables(`t_girl`.`category`, `t_girl`.`category_part`, `t_girl`.`parent`) in 0 seconds.
Copying 19 files...
Copying indices for 0 files...
Unlocked tables.
mysqlhotcopy copied 3 tables (19 files) in 6 seconds (6 seconds overall).
[root@localhost data]#


4), can be specially written record of the table. Specifically look for help.
the perldoc mysqlhostcopy

MySQL > Create Database hotcopy ;
Query the OK , . 1 Row affected ( 0 . 03 sec )
MySQL > use hotcopy
Database changed
MySQL > Create Table the checkpoint ( TIME_STAMP timestamp Not null , the src VARCHAR ( 32 ) , dest VARCHAR ( 60 ) , MSG VARCHAR ( 255 ) ) ;
Query the OK ,Rows affected 0 ( 0 . 01 sec )
at the same time remember to hotcopyer user rights.
MySQL > Grant INSERT ON hotcopy . the checkpoint to hotcopyer @ 'localhost' ;
Query the OK , 0 rows affected ( 0 . 00 sec )

MySQL > the flush privileges ;
Query the OK , 0 rows affected ( 0 . 00 sec )

MySQL > \ Q
Bye
repeated the third operation step

[ the root @ localhost ~ ]# mysqlhotcopy t_girl./~id/ --allowold --checkpoint hotcopy.checkpoint

Using copy suffix '_copy'
Existing hotcopy directory renamed to '/usr/local/mysql/data/t_girl_copy_old'
Locked 3 tables in 0 seconds.
Flushed tables (`t_girl`.`category`, `t_girl`.`category_part`, `t_girl`.`parent`) in 0 seconds.
Copying 19 files...
Copying indices for 0 files...
Unlocked tables.
Mysqlhotcopy works copied appears Tables. 3 ( . 19 Files ) in seconds The 12 is ( 13 is seconds The Overall ) .


By default the data is stored in the directory / t_girl_copy /
look record table.
MySQL > use hotcopy ;
Database changed
MySQL > SELECT * from the checkpoint ;
+ - - - - - - - - - - - - - - - - - - - - - + --------+-----------------------------------+-----------+
| time_stamp | src | | msg |
+ - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - -------------+-----------+
| 2008-03-11 14:44:58 | t_girl | /usr/local/mysql/data/t_girl_copy | Succeeded |
+---------------------+--------+-----------------------------------+-----------+
1 row in set (0.00 sec)

5)、支持增量备份。
[root@localhost ~]# mysqlhotcopy t_girl./~id/ --allowold --checkpoint hotcopy.checkpoint --addtodest t_girl_new

Locked 3 tables in 0 seconds.
Flushed tables (`t_girl`.`category`, `t_girl`.`category_part`, `t_girl`.`parent` ) in 0 seconds The .
Copying Files. 19 . . .
Copying indices for 0 Files . . .
Unlocked Tables .
mysqlhotcopy works copied appears Tables. 3 ( . 19 Files ) in seconds The. 7 ( . 7 seconds The Overall ) .
. 6), the other waiting tested re-release. . .

This article comes from " God, let there or be square! " Blog, reproduced please contact the author!

Reproduced in: https: //my.oschina.net/u/585111/blog/219450

Guess you like

Origin blog.csdn.net/weixin_34254823/article/details/92008325