免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
MySQL之mysqldump備份的
userphoto

2022.06.14 浙江

關注

備份大小在10G以下,可以用mysqldump進行備份(du -sh 數(shù)據(jù)庫數(shù)據(jù)文件夾----查看數(shù)據(jù)庫數(shù)據(jù)大?。?/p>

mysqldump是單線程備份,單線程恢復的,速度比較慢


備份語句

前提:數(shù)據(jù)庫用了gtid進行主從復制的

/usr/local/mysql/bin/mysqldump -uroot -p123456 --single-transaction --master-data=2 -A > /root/1.sql

--single-transaction  #保證數(shù)據(jù)一致性,mysqldump在執(zhí)行備份語句那一時刻,他會備份到那時刻的數(shù)據(jù)。跟xtrabackup不一樣,xtrabackup是備份到備份完數(shù)據(jù)那一刻的數(shù)據(jù)。

--master-data=2   #在bin-log日志里記錄備份到了哪個位置

注意:這里沒有加上  --set-gtid-purged=OFF  默認  --set-gtid-purged=ON

好啦,備份完之后,我們測試一下,把數(shù)據(jù)導入另外一個數(shù)據(jù)庫:

mysql> reset master;

Query OK, 0 rows affected (0.04 sec)

#清空這個數(shù)據(jù)庫的bin-log日志和gtid記錄,此時通過show slave status\G  查看信息都是空的

        Master_SSL_Crl:

         Master_SSL_Crlpath:

          Retrieved_Gtid_Set:

            Executed_Gtid_Set:

                Auto_Position: 1

        Replicate_Rewrite_DB:

                Channel_Name:

          Master_TLS_Version:

開始導入數(shù)據(jù):

/usr/local/mysql/bin/mysql -uroot -p123456 < /root/1.sql

進入mysql查看,show slave status\G

Master_SSL_Crl:

          Master_SSL_Crlpath:

          Retrieved_Gtid_Set:

            Executed_Gtid_Set: 6bf23ca7-f1c9-11e9-bc34-0050562b3b5a:1,

f50c4171-f1c4-11e9-8de8-0050563a3356:1-68735

                Auto_Position: 1

        Replicate_Rewrite_DB:

                Channel_Name:

          Master_TLS_Version:

1 row in set (0.00 sec)

#可見已經(jīng)導入數(shù)據(jù)庫,gtid那邊已經(jīng)執(zhí)行過語句了。但是這些gtid都是其他數(shù)據(jù)庫的。

好啦,我們看下bin-log日志

[root@localhost datanode1]# ls -lh bin-log-mysqld5.000001

-rw-r-----. 1 mysql mysql 154 Sep 12 01:57 bin-log-mysqld5.000001

#看到bin-log日志大小沒有發(fā)生變化,如果有寫入了bin-log日志,大小應該是32M的

結(jié)論:

開啟gtid后,備份的時候使用--set-gtid-purged=ON

備份出來的數(shù)據(jù),導入到其他數(shù)據(jù)庫里,是不會寫入bin-log日志的。但是會執(zhí)行gtid語句,而且這些gtid語句的uuid是備份這數(shù)據(jù)數(shù)據(jù)庫的uuid


備份使用 --set-gtid-purged=OFF的情況

/usr/local/mysql/bin/mysqldump -uroot -p123456 --single-transaction --master-data=2 --set-gtid-purged=OFF  -A > /root/1.sql

#清掉bin-log和gtid信息

reset master;

#查看gtid信息

show slave status\G

Last_SQL_Error_Timestamp:

              Master_SSL_Crl:

          Master_SSL_Crlpath:

          Retrieved_Gtid_Set:

            Executed_Gtid_Set:

                Auto_Position: 1

        Replicate_Rewrite_DB:

                Channel_Name:

          Master_TLS_Version:

1 row in set (0.00 sec)

#開始導入數(shù)據(jù)

/usr/local/mysql/bin/mysql -uroot -p123456 < 1.sql 

查看bin-log日志大小

-rw-r-----. 1 mysql mysql 32M Sep 12 02:24 /data/mysql/datanode1/bin-log-mysqld5.000001

#bin-log日志寫入了內(nèi)容

查看gtid信息

Master_SSL_Crl:

          Master_SSL_Crlpath:

          Retrieved_Gtid_Set:

            Executed_Gtid_Set: 55001361-d483-11e9-ab0d-0050563aec90:1-177

                Auto_Position: 1

        Replicate_Rewrite_DB:

                Channel_Name:

          Master_TLS_Version:

#可以看得出這個gtid里的Uuid是這臺導入數(shù)據(jù)的數(shù)據(jù)庫的uuid。

結(jié)論:

--set-gtid-purged=OFF

會寫入bin-log

gtid會是導入數(shù)據(jù)的那臺mysql的uuid


本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Mysqldump邏輯備份與恢復
MySQL binlog日志操作詳解
不停止MySQL服務增加從庫的兩種方式
MySQL完全備份、增量備份與恢復
mysql主從服備份
Mysql 在線新建或重做主從
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服