首页 > 代码库 > backup mysql for xtrabackup with xbstream and lz4
backup mysql for xtrabackup with xbstream and lz4
需要临时为mysql添加一个实例,使用xtrabackup最简单快速。
在现有数据节点上:
/home/work/app/xtrabackup-2.2.3/innobackupex --ibbackup=/home/work/app/xtrabackup-2.2.3/xtrabackup --parallel=8 --defaults-file= ${BACKUP_CNF} --socket=${BACKUP_SOCK} --user={BACKUP_USER} --password=${BACKUP_PWD} ${BAK} --no-timestamp --stream=xbstream | lz4 -B4 | nc host port
在临时征用的数据节点上:
nc -l port | lz4 -B7 -d | /home/work/app/xtrabackup-2.2.3/xbstream -x
传输完成后恢复之
/home/work/app/xtrabackup-2.2.3/innobackupex --ibbackup=/home/work/app/xtrabackup-2.2.3/xtrabackup --parallel=8 --apply-log --use-memory=4G --defaults-file=${BACKUP_CNF}${BAK}
tudou@b2c.xiaomi.com
使用xbstream的好处是可以使用--parallel=8参数来并行备份
使用lz4目的是提高压缩和解压速度,下面是lz4在centos环境下的安装过程
wget --content-disposition https://github.com/Cyan4973/lz4/archive/r122.tar.gz
tar zxf lz4-r122.tar.gz
cd lz4-r122/
make -j 4
make install PREFIX=/home/work/app/lz4-r122
压缩
lz4 -B4
解压lz4 -B7 -d
help信息lz4 -?
Incorrect parameters
Usage :
lz4 [arg] [input] [output]
input : a filename
with no FILE, or when FILE is - or stdin, read standard input
Arguments :
-1 : Fast compression (default)
-9 : High compression
-d : decompression (default for .lz4 extension)
-z : force compression
-f : overwrite output without prompting
-h/-H : display help/long help and exitbackup mysql for xtrabackup with xbstream and lz4