>  기사  >  데이터 베이스  >  mydumper/myloader 사용 요약

mydumper/myloader 사용 요약

PHP中文网
PHP中文网원래의
2017-06-20 15:37:362824검색
mydumper 설치:
mydumper 원칙:
myloader 원칙:
1. mydumper 백업
1. 16개의 백업 프로세스를 시작합니다. 모든 라이브러리 및 바이너리 로그 파일을 업로드하고 지정된 디렉토리 /docker/mydumper/all_backup
mydumper -u root -p root123 --threads=16 -o /docker/mydumper/all_backup
여기에 지정된 --threads=16 활성화 16개의 백업 스레드. 이는 MySQL에서 processlist를 표시하여 볼 수 있습니다.
백업이 완료되면 각 테이블에는 두 개의 파일이 있습니다.
하나는 테이블 구조 파일인 Database.table-schema.sql입니다.
하나는 테이블 데이터 파일인 Database.table.sql입니다.
또한 바이너리 로그 파일 메타데이터가 있습니다.
$ cat 메타데이터
덤프 시작 시간: 2017-06-15 10:57:24
SHOW MASTER STATUS:
로그: mysql-bin.000025
위치: 681395159
:6fbc72af-348e -11e7-865c-fa163e5807c3:1-22,
ad9b2529-348d-11e7-bef0-fa163e9e3c14:1-2663607
슬레이브 상태 표시:
호스트: 10.1 57. 24.87
로그: mysql-bin. 000047
위치: 144635857
GTID:6fbc72af-348e-11e7-865c-fa163e5807c3:1-22,
ad9b2529-348d-11e7-bef0-fa163e9e3c14:1- 2663607
완료된 덤프 시간: 2017-06 - 15 10:58:50
참고: 출력 디렉터리를 지정하지 않은 경우: mydumper -u root -p root123
, 내보내기-20170615-105920 디렉터리(내보내기-년, 월, 일-시, 분) , 두 번째)는 기본적으로 자동 생성됩니다
2. 모든 라이브러리를 지정된 폴더에 백업하고 백업 파일을 압축합니다(이 백업 압축 프로세스는 너무 많은 시간을 소비합니다)
mydumper -u root - p root123 -c -o /docker/mydumper /all_backup_compress
는 테이블 구조 파일과 테이블 데이터 파일을 모두 압축하고 바이너리 로그 파일은 변경되지 않은 채로 둡니다. 아래와 같이 파일 크기가 17G에서 7.7G로 압축됩니다. ㅋㅋㅋ
3. sampson 데이터베이스에 있는 모든 테이블의 테이블 구조를 백업합니다. 아니요 지정된 출력 디렉터리에 데이터를 백업합니다.
/docker/ mydumper/sampson-d
mydumper -u root -p root123 -B sampson -d -o /docker/mydumper/sampson-d
그러면 메타데이터와 sampson.table-schema.sql 파일만 있습니다. /docker/mydumper/sampson-d 디렉토리에 있습니다.
4 테이블 구조를 백업하지 않고 sampson 라이브러리의 모든 테이블 데이터를 지정된 출력 디렉터리 /docker/mydumper/sampson-m
Download
mydumper에 백업합니다. u root -p root123 -B sampson -m -o /docker/mydumper/sampson-m
그러면 /docker/mydumper/sampson-m 디렉터리에는 메타데이터와 sampson.table.sql 파일만 있습니다.
5 sampson 라이브러리의 모든 dsns 및 t1 테이블을 지정된 출력 디렉터리 /docker/mydumper/sampson -T
Download
mydumper -u root -p root123 -B sampson에 백업합니다. -T dsns,t1 -o /docker/mydumper/sampson-T
/docker/mydumper/sampson-T 디렉터리에는 dsns 및 t1 테이블의 백업 파일은 물론 메타데이터 및 sampson 데이터베이스 파일이 포함되어 있습니다.
참고: 백업을 백그라운드에서 실행해야 하는 경우 --daemon을 추가하여 백그라운드에서 내보내기 명령을 실행할 수 있습니다.
2.
myloader
Restore
1.
myloader -u 루트 -p root123 --threads= 16 --database=sampson -d /docker/mydumper/all_backup
2. 테이블 구조만
sampson-d library
에 백업된 디렉터리에서 sampson 라이브러리 테이블 구조를 복원합니다.
myloader -u root -p root123 --database=sampson-d -d /docker/mydumper/sampson-d
3 전체 폴더 에서 sampson 라이브러리를 samp 라이브러리로 복원합니다. 대상: myloader -u root -p root123 --database=samp --source-db=sampson -d /docker/mydumper/all_backup
참고: 백업할 때 매개변수를 추가하는 것이 좋습니다. 가동 및 복원 - v 3, 자세한 로그를 표시합니다.
root@dpsvstadbs05 12:13:35:mydumper$ myloader -u root -p root123  -d /docker/mydumper/all_backup --database=huihui --source-db=lizhi -v 3
** 메시지: 스레드 4개 created
** 메시지: `huihui` 데이터베이스 생성
** 메시지: `huihui`.`my1`
테이블 생성 중 `huihui`.`my2`
** 메시지: 테이블 생성 중 `huihui`.`my3`
** 메시지: `huihui`.`my4` 테이블 생성 중
** 메시지: `huihui`.`my5`
** 메시지: `huihui`.` 테이블 생성 중 my6`
** 메시지: `huihui`.`my7` 테이블 생성 중
** 메시지: `huihui`.`t1`
테이블 생성 중 `lizhi`.`my1` 파트 0을 복원하는 스레드 1
** 메시지: 스레드 3 복원 `lizhi`.`my2` 부분 0
** 메시지: 스레드 2 복원 `lizhi`.`my3` 부분 0
** 메시지: 스레드 4 복원 `lizhi`.` my4` 파트 0
** 메시지: 스레드 3 복원 `lizhi`.`my5` 파트 0
** 메시지: 스레드 1 복원 `lizhi`.`my6` 파트 0
** 메시지: 스레드 4 복원 ` lizhi`.`my7` 파트 0
** 메시지: `lizhi`.`t1` 파트 0
** 메시지: 스레드 2 종료 중
** 메시지: 스레드 1 종료 중
** 메시지: 스레드 4 종료 중
** 메시지: 스레드 3 종료 중
 
附:
 
mydumper参数详解
 
$ mydumper --helpUsage:
  mydumper [OPTION...] multi-threaded MySQL dumping

Help Options:  -?, --help                  Show help optionsApplication Options:  -B, --database              要备份的数据库,不指定则备份所有库
  -T, --tables-list           需要备份的表,名字用逗号隔开
  -o, --outputdir             备份文件输出的目录
  -s, --statement-size        生成的insert语句的字节数,默认1000000
  -r, --rows                  Try to split tables into chunks of this many rows. This option turns off --chunk-filesize
  -F, --chunk-filesize        Split tables into chunks of this output file size. This value is in MB
  -c, --compress              Compress output files压缩输出文件
  -e, --build-empty-files     如果表数据是空,还是产生一个空文件(默认无数据则只有表结构文件)
  -x, --regex                 Regular expression for 'db.table' matching 使用正则表达式匹配'db.table'
  -i, --ignore-engines        Comma delimited list of storage engines to ignore忽略的存储引擎,用逗号分割
  -m, --no-schemas            Do not dump table schemas with the data不备份表结构,只备份数据
  -d, --no-data               Do not dump table data备份表结构,不备份数据
  -G, --triggers              Dump triggers备份触发器
  -E, --events                Dump events
  -R, --routines              Dump stored procedures and functions备份存储过程和函数
  -k, --no-locks              不使用临时共享只读锁,使用这个选项会造成数据不一致
  --less-locking              Minimize locking time on InnoDB tables.减少对InnoDB表的锁施加时间
  -l, --long-query-guard      设定阻塞备份的长查询超时时间,单位是秒,默认是60秒(超时后默认mydumper将会退出)
  -K, --kill-long-queries     Kill long running queries (instead of aborting)杀掉长查询 (不退出)
  -D, --daemon                Enable daemon mode启用守护进程模式,守护进程模式以某个间隔不间断对数据库进行备
  -I, --snapshot-interval     dump快照间隔时间,默认60s,需要在daemon模式下
  -L, --logfile               使用的日志文件名(mydumper所产生的日志), 默认使用标准输出
  --tz-utc                    SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when a server has data in different time zones or data is being moved between servers with different time zones, defaults to on use --skip-tz-utc to disable.
  --skip-tz-utc               
  --use-savepoints            使用savepoints来减少采集metadata所造成的锁时间,需要 SUPER 权限
  --success-on-1146           Not increment error count and Warning instead of Critical in case of table doesn't exist
  --lock-all-tables           Use LOCK TABLE for all, instead of FTWRL
  -U, --updated-since         Use Update_time to dump only tables updated in the last U days
  --trx-consistency-only      Transactional consistency only
  -h, --host                  连接的主机名
  -u, --user                  用来备份的用户名
  -p, --password              用户密码
  -P, --port                  连接端口
  -S, --socket                使用socket通信时的socket文件
  -t, --threads               开启的备份线程数,默认是4
  -C, --compress-protocol     压缩与mysql通信的数据
  -V, --version               显示版本号
  -v, --verbose               输出信息模式, 0 = silent, 1 = errors, 2 = warnings, 3 = info, 默认为2

 

myloader参数详解

 

$ myloader --helpUsage:
  myloader [OPTION...] multi-threaded MySQL loader

Help Options:  -?, --help                        Show help optionsApplication Options:  -d, --directory                   Directory of the dump to import之前备份好的现在需要导入的文件夹
  -q, --queries-per-transaction     Number of queries per transaction, default 1000每次事物执行的查询数量,默认是1000
  -o, --overwrite-tables            Drop tables if they already exist如果要恢复的表存在,则先drop掉该表,使用该参数,需要备份时候要备份表结构
  -B, --database                    An alternative database to restore into还原到指定的数据库
  -s, --source-db                   Database to restore选择被还原的数据库,将这个数据库数据还原到--database指定的数据库里
  -e, --enable-binlog               Enable binary logging of the restore data启用还原数据的二进制日志
  -h, --host                        连接的主机名
  -u, --user                        用来备份的用户名
  -p, --password                    用户密码
  -P, --port                        连接端口
  -S, --socket                      使用socket通信时的socket文件
  -t, --threads                     开启的备份线程数,默认是4
  -C, --compress-protocol           压缩与mysql通信的数据
  -V, --version                     显示版本号
  -v, --verbose                     输出信息模式, 0 = silent, 1 = errors, 2 = warnings, 3 = info, 默认为2

 

위 내용은 mydumper/myloader 사용 요약의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.