{"rsdb":{"rid":"156494","subhead":"","postdate":"0","aid":"117464","fid":"57","uid":"1","topic":"1","content":"

\u4ee5\u5feb\u901f\u521b\u5efa\u4e00\u4e2aMySQL\u4ece\u5e93\u7684\u9700\u6c42\u51fa\u53d1\uff0c\u5982\u4e0b\u51e0\u79cd\u5907\u9009\u65b9\u6848\uff1a<\/p>

\u73af\u5883\uff1a<\/p>

node1? \u4e3b\u5e93<\/p>

node2? \u65b0\u670d\u52a1\u5668\uff0c\u9700\u8981\u505a\u6210node1\u4ece\u5e93? \uff08node1\u5df2\u7ecf\u914d\u7f6e\u514d\u5bc6\u7801SSH\u767b\u9646\u5230node2\uff09<\/p>

\u8f6f\u4ef6\u7248\u672c\uff1a<\/p>

MySQL \u5b98\u65b95.6\u7248\u672c\uff0c\u6570\u636e\u5e93\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u90fd\u662froot<\/p>

\u90fd\u5b89\u88c5\u4e86percona-xtrabackup<\/strong><\/p>

0 \u5f31\u9e21\u7248\uff1a\u3010\u6700\u8017\u65f6\u95f4\u3011<\/strong><\/p>

mysqldump -uroot -proot -q --single-transaction -A --master-data=2 > \/root\/all.sql? # \u5907\u4efd<\/p>

mysql -uroot -proot < \/root\/all.sql? # \u8fd8\u539f<\/p>

\u8fd9\u79cd\u65b9\u5f0f\u6700\u7b80\u5355\u7684\uff0c\u4e0d\u591a\u8bf4\u3002<\/p>

1 \u521d\u7ea7\u7248\uff1a<\/strong><\/p>

innobackupex --user=root --password=root --socket=\/var\/lib\/mysql\/mysql.sock --parallel=4 --no-timestamp \/root\/bak<\/p>

\u7f3a\u70b9\u901f\u5ea6\u6162\uff0c\u5907\u4efd\u7684\u6587\u4ef6\u8f83\u5927\u3002\u597d\u5904\u662f\u76f8\u5bf9\u4e8emysqldump\u800c\u8a00\uff0c\u8fd9\u4e2a\u5de5\u5177\u80fd\u5e76\u884c\u5907\u4efd\u64cd\u4f5c\u3002<\/p>

scp \/root\/bak root@node2:\/root? # \u5c06\/root\/bak\u8fd9\u4e2a\u538b\u7f29\u540e\u7684\u6587\u4ef6scp\u5230\u76ee\u6807\u4e3b\u673anode2\uff0c<\/p>

\u7136\u540e\u53bbnode2\u89e3\u538b\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>

mkdir \/tmp\/mysql? # \/tmp\/mysql \u8fd9\u662f\u4e2a\u4e34\u65f6\u5b58\u653e\u62f7\u8d1d\u8fc7\u6765\u7684\u6570\u636e\u5e93\u89e3\u538b\u6587\u4ef6\u76ee\u5f55,\u548cmysql\u7684\u81ea\u5df1\u7684datadir\u6ca1\u6709\u4efb\u4f55\u5173\u7cfb<\/p>

cat \/root\/bak | lz4 -d | xbstream -x -C \/tmp\/mysql<\/p>

innobackupex --apply-log \/tmp\/mysql\/# \u5bfc\u5165\u6570\u636e\u540e\uff0c\u8fd8\u8981\u6267\u884c\u4e0b\u6574\u7406\u64cd\u4f5c
innobackupex --copy-back? \/tmp\/mysql\/? # \u5c06\u6574\u7406\u597d\u7684\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165\u5230\u539f\u5148\u7684mysql datadir\u91cc
?
chown mysql.mysql? \/data\/mysql\/ -R
\/etc\/init.d\/mysql start \u8fd9\u6837\u4e00\u53f0mysql\u5c31\u542f\u52a8\u597d\u4e86<\/p>

2 lz4\u52a0\u901f\u7248\uff1a<\/strong><\/p>

yum install lz4 -y? # \u5148\u57282\u53f0\u4e3b\u673a\u4e0a\u5b89\u88c5\u8fd9\u4e2a\u538b\u7f29\u5de5\u5177\uff0c\u6027\u80fd\u6bd4gzip\u3001bzip2\u5f3a\u5f88\u591a\u3002<\/p>

node1\u4e0a\u5907\u4efd\uff1a<\/p>

innobackupex --user=root \\
--password=root \\
--socket=\/var\/lib\/mysql\/mysql.sock \\
--parallel=4 \\
--no-timestamp \\
--stream=xbstream . | lz4 -B4 > \/root\/bak<\/p>

scp \/root\/bak root@node2:\/root? # \u5c06\/root\/bak\u8fd9\u4e2a\u538b\u7f29\u540e\u7684\u6587\u4ef6scp\u5230\u76ee\u6807\u4e3b\u673anode2\uff0c<\/p>

\u7136\u540e\u53bbnode2\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>

mkdir \/tmp\/mysql
cat \/root\/bak | lz4 -d | xbstream -x -C \/tmp\/mysql?
?
innobackupex --apply-log \/tmp\/mysql\/# \u5bfc\u5165\u6570\u636e\u540e\uff0c\u8fd8\u8981\u6267\u884c\u4e0b\u6574\u7406\u64cd\u4f5c
innobackupex --copy-back? \/tmp\/mysql\/? # \u5c06\u6574\u7406\u597d\u7684\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165\u5230\u539f\u5148\u7684mysql datadir\u91cc
?
chown mysql.mysql? \/data\/mysql\/ -R
\/etc\/init.d\/mysql start \u8fd9\u6837\u4e00\u53f0mysql\u5c31\u542f\u52a8\u597d\u4e86<\/p>

3 \u7ba1\u9053\u52a0\u5f3a\u7248\uff1a<\/strong><\/p>

innobackupex --user=root \\
--password=root \\
--parallel=4 \\
--socket=\/var\/lib\/mysql\/mysql.sock \\
--no-timestamp \\
--stream=xbstream . |\\
lz4 -B4 |\\
ssh root@node2 \\
\"cat - > \/tmp\/bak\"<\/p>

# \u4e0a\u9762\u8fd9\u6761\u547d\u4ee4\u662f\u76f4\u63a5\u538b\u7f29\u5e76\u5907\u4efd\u5230\u8fdc\u7a0b\u7684\/tmp\u76ee\u5f55\u4e0b<\/p>

\u7136\u540e\u5230node2\u4e0a\u53bb\u8fd8\u539f\uff1a<\/p>

mkdir \/tmp\/mysql
cat \/tmp\/bak | lz4 -d -B7 | xbstream -x -C \/tmp\/mysql<\/p>

innobackupex --apply-log \/tmp\/mysql\/# \u5bfc\u5165\u6570\u636e\u540e\uff0c\u8fd8\u8981\u6267\u884c\u4e0b\u6574\u7406\u64cd\u4f5c
innobackupex --copy-back? \/tmp\/mysql\/? # \u5c06\u6574\u7406\u597d\u7684\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165\u5230\u539f\u5148\u7684mysql datadir\u91cc
chown mysql.mysql? \/data\/mysql\/ -R
\/etc\/init.d\/mysql start \u8fd9\u6837\u4e00\u53f0mysql\u5c31\u542f\u52a8\u597d\u4e86<\/p>

4 \u76f4\u63a5\u5907\u4efd\u5230\u8fdc\u7a0b\u540c\u65f6\u8fd8\u539f\u7248\uff1a \u3010\u63a8\u8350\u4f7f\u7528\u65b9\u6cd54<\/span>\u3011<\/strong><\/p>

\u9996\u5148\u9700\u8981\u5728node2\u4e0a\u521b\u5efa\u4e2a\/tmp\/mysql\u76ee\u5f55\uff0c\u4e0d\u7136node1\u5907\u4efd\u6587\u4ef6\u53d1\u9001\u8fc7\u53bb\u6ca1\u76ee\u5f55\u5b58\u653e\u3002<\/p>

\u7136\u540e\u518dnode1\u4e0a\u6267\u884c\uff1a<\/p>

innobackupex --user=root \\
--password=root \\
--parallel=4 \\
--socket=\/var\/lib\/mysql\/mysql.sock \\
--no-timestamp \\
--stream=xbstream . |\\
lz4 -B4 |\\
ssh node2 \\
\"cat - | lz4 -d -B7 | xbstream -x -C \/tmp\/mysql\"<\/p>","orderid":"0","title":"\u5feb\u901f\u521b\u5efa\u4e00\u4e2aMySQL\u4ece\u5e93\u7684\u65b9\u6cd5","smalltitle":"","mid":"0","fname":"\u6570\u636e\u5e93\u7f16\u7a0b","special_id":"0","bak_id":"0","info":"0","hits":"325","pages":"1","comments":"0","posttime":"2017-02-21 08:15:58","list":"1487636158","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u5feb\u901f<\/A> \u521b\u5efa<\/A> \u4e00\u4e2a<\/A> MySQL<\/A> \u4ece\u5e93\u7684<\/A> \u65b9\u6cd5<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.31","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u5feb\u901f\u521b\u5efa\u4e00\u4e2aMySQL\u4ece\u5e93\u7684\u65b9\u6cd5","lastview":"1713606218","digg_num":"410","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}