pt-archiver結合crontab定時自動歸檔資料
根據時間戳定時歸檔
#!/bin/sh
#source ~/.bash_profile
#Get current timestamp
current=`date "+%Y-%m-%d %H:%M"`
timeStamp=`date -d "$current" +%s`
#echo $timeStamp
#currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000))
currentTimeStamp=$((timeStamp*1000))
echo $currentTimeStamp
date=$(date +%Y%m%d)
#Create new table
#Source db information
source_ip="xxx.xxx.xxx.xxx"
source_port="xxx"
source_username="xxxx"
source_password="xxxx"
source_dbname="xxxx"
source_table="xxxxx"
column_name="xxxx"
#Target db information
target_ip="xxx.xxx.xxx.xxx"
target_port="xxxx"
target_username="xxxxx"
target_password="xxxxx"
target_dbname="xxxxx"
target_table="${source_table}_${date}"
#echo $target_table
create_table_sql="CREATE TABLE ${target_table} (id bigint NOT NULL);"
/bin/mysql -h${target_ip} -P${target_port} -u${target_username} -p${target_password} ${target_dbname} -e "${create_table_sql}"
#Archive history data
/usr/bin/pt-archiver --source h=${source_ip},u=${source_username},p=${source_password},D=${source_dbname},t=${source_table},A=utf8,P=${source_port} --dest h=${target_ip},u=${target_username},p=${target_password},D=${target_dbname},t=${target_table},A=utf8,P=${target_port} --max-lag=3m --limit=1000 --progress=50000 --statistics --where "${column_name} <=$currentTimeStamp" --bulk-delete --replace
相關文章
- pt-archiver 歸檔資料Hive
- pt-archiver資料歸檔Hive
- MySQL使用pt-archiver歸檔歷史資料MySqlHive
- crontab不能自動刪除歸檔日誌
- 定時自動啟動任務crontab命令用法
- 優雅地使用pt-archiver進行資料歸檔Hive
- [Linux]crontab定時任務自動化Linux
- pt-archiver工具歸檔和恢復資料一例Hive
- oracle自動歸檔的設定Oracle
- 使用 crontab 設定 Homebrew 自動更新
- crontab 定時
- LightBD/PostgreSQL資料庫設定歸檔保留時間SQL資料庫
- 設定Oracle9i為自動歸檔模式Oracle模式
- crontab命令簡介 linux定時設定 Cron實現自動任務 (轉)Linux
- SQL Server 自動迴圈歸檔分割槽資料指令碼SQLServer指令碼
- crontab定時任務
- 資料庫啟動歸檔模式資料庫模式
- 配置crontab+ftp自動下載檔案FTP
- linux的crontab定時服務備份mysql資料LinuxMySql
- springboot結合flyway自動建立資料庫及資料表Spring Boot資料庫
- 結合Global和C#中的定時器實現自動Job(一)C#定時器
- OARCLE資料庫歸檔模式的設定資料庫模式
- 如何設定資料庫為歸檔模式資料庫模式
- CentOS Crontab(定時任務)CentOS
- Rman 定時備份crontab
- 11g資料庫設定歸檔模式資料庫模式
- oracle資料庫rman歸檔設定和管理Oracle資料庫
- 自動定時備份 mysql 資料庫 的 shell 指令碼MySql資料庫指令碼
- rman在歸檔與非歸檔時備份資料庫的簡單示例資料庫
- Linux crontab 定時任務Linux
- Linux 定時任務(crontab)Linux
- Linux - crontab(定時任務)Linux
- 定時任務crontab 詳解
- (定時任務)crontab 的用法
- crontab定時任務維護
- 如何使用資料庫Scheduler定時刪除歸檔|美創運維日記資料庫運維
- ORACLE資料庫歸檔改為非歸檔Oracle資料庫
- Veritas Enterprise Vault 15.0 (Windows) - 自動捕獲資料並歸檔資訊Windows