| 參數(shù) | 說明 |
|---|---|
| A | 字符編碼 |
| D | 庫 |
| F | 從文件讀取選項(xiàng) |
| L | 加載數(shù)據(jù)本地文件 |
| P | 端口 |
| S | socket文件 |
| a | 執(zhí)行查詢的數(shù)據(jù)庫 |
| b | 如果是true, 禁用SQL_LOG_BIN |
| h | 數(shù)據(jù)庫地址 |
| i | 查詢使用的索引 |
| m | 插件模塊名稱 |
| p | 數(shù)據(jù)庫密碼 |
| t | 表 |
| u | 用戶名 |
| 參數(shù) | 默認(rèn)值 | 說明 |
|---|---|---|
| --limit 10000 | 每次取1000行數(shù)據(jù)用pt-archive處理,Number of rows to fetch and archive per statement. | |
| --txn-size 1000 | 設(shè)置1000行為一個事務(wù)提交一次,Number of rows pertransaction. | |
| --where 'id<3000' | 設(shè)置操作條件 | |
| --progress 5000 | 每處理5000行輸出一次處理信息 | |
| --statistics | 輸出執(zhí)行過程及最后的操作統(tǒng)計 | |
| --charset=UTF8 | 指定字符集為UTF8 | |
| --bulk-delete | 批量刪除source上的舊數(shù)據(jù)(例如每次1000行的批量刪除操作) | |
| --bulk-insert | 批量插入數(shù)據(jù)到dest主機(jī) (看dest的general log發(fā)現(xiàn)它是通過在dest主機(jī)上LOAD DATA LOCAL INFILE插入數(shù)據(jù)的) | |
| --replace | 將insert into 語句改成replace寫入到dest庫 | |
| --sleep 120 | 每次歸檔了limit個行記錄后的休眠120秒(單位為秒) | |
| --file '/root/test.txt' | 導(dǎo)出的文件路徑 | |
| --purge | 刪除source數(shù)據(jù)庫的相關(guān)匹配記錄 | |
| --header | 輸入列名稱到首行(和--file一起使用) | |
| -no-check-charset | 不指定字符集 | |
| --check-columns | 檢驗(yàn)dest和source的表結(jié)構(gòu)是否一致,不一致自動拒絕執(zhí)行(不加這個參數(shù)也行。默認(rèn)就是執(zhí)行檢查的) | |
| --no-check-columns | 不檢驗(yàn)dest和source的表結(jié)構(gòu)是否一致,不一致也執(zhí)行(會導(dǎo)致dest上的無法與source匹配的列值被置為null或者0) | |
| --chekc-interval | 默認(rèn)1s檢查一次 | |
| --local | 不把optimize或analyze操作寫入到binlog里面(防止造成主從延遲巨大) | |
| --retries | 超時或者出現(xiàn)死鎖的話,pt-archiver進(jìn)行重試的間隔(默認(rèn)1s) | |
| --no-version-check | 目前為止,發(fā)現(xiàn)部分pt工具對阿里云RDS操作必須加這個參數(shù) | |
| --analyze=ds | 操作結(jié)束后,優(yōu)化表空間(d表示dest,s表示source) |
pt-archiver \
--source h=localhost,u=root,p=1234,P=3306,D=test,t=t \
--no-check-charset --where ‘a(chǎn)<=376‘ --limit 10000 --txn-size 1000 --purge/usr/bin/pt-archiver \
--source h=localhost,u=root,p=1234,P=3306,D=test,t=t1\
--dest h=192.168.2.12,P=3306,u=archiver,p=archiver,D=test,t=t1_bak \
--progress 5000 --where 'mc_id<=125' \
--statistics --charset=UTF8 --limit=10000 --txn-size 1000 --no-delete/usr/bin/pt-archiver \
--source h=localhost,u=root,p=1234,P=3306,D=test,t=t1 \
--dest h=192.168.2.12,P=3306,u=archiver,p=archiver,D=test,t=t1_his \
--progress 5000 --where "CreateDate <‘2017-05-01 00:00:00‘ " \
--statistics --charset=UTF8 --limit=10000 --txn-size 1000 --bulk-delete/usr/bin/pt-archiver \
--source h=localhost,u=archiver,p=archiver,P=3306,D=test,t=t1 \
--dest h=192.168.2.12,P=3306,u=archiver,p=archiver,D=test,t=t1_his \
--progress 5000 --where "c <‘2017-05-01 00:00:00‘ " \
--statistics --charset=UTF8 --limit=10000 --txn-size 1000 --no-delete --bulk-insert/usr/bin/pt-archiver \
--source h=10.0.20.26,u=root,p=1234,P=3306,D=test,t=t \
--file ‘/root/test.txt‘ \
--progress 5000 --where ‘a(chǎn)<12000‘ \
--no-delete --statistics --charset=UTF8 --limit=10000 --txn-size 1000/usr/bin/pt-archiver \
--source h=10.0.20.26,u=root,p=1234,P=3306,D=test,t=t \
--file ‘/root/test.txt‘ \
--progress 5000 --where ‘a(chǎn)<12000‘ \
--statistics --charset=UTF8 --limit=10000 --txn-size 1000 --purge
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
本文題目:pt-archiver數(shù)據(jù)刪除、遷移工具使用-創(chuàng)新互聯(lián)
文章轉(zhuǎn)載:http://www.yijiale78.com/article4/ceshie.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、全網(wǎng)營銷推廣、網(wǎng)站策劃、網(wǎng)站設(shè)計公司、標(biāo)簽優(yōu)化、營銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容