?????????MySQL binlog??
???????????? ???????[ 2016/5/19 11:02:28 ] ????????MySQL ?????
???????????binlog????????????????б???????????????????????С??????????л?????????????????????????????????????????????????У???????崻??????????????????????????binlog??????
?????????????y???????????????б?????????и?????????MySQL?????????????д????????????????б??????????????MySQL?????????д???????б??????д?????binlog???????????????±??????????????
??????MySQL5.6?????mysqlbinlog???????????????binlog???????????????????
????mysqlbinlog????????????????????????????????????????????????????MySQL 5.6??????Replication API???????????????????????????MySQL??????????????????????????????????????????????????0.5~1??????б????
????????????
????mysqlbinlog --read-from-remote-server --raw --host=192.168.244.145 --port=3306 --user=repl --password=repl --stop-never mysql-bin.000001
???????????£?
????--read-from-remote-server???????????????????binlog?????????????????????????binlog??
????--raw??binlog???????????????洢??????У????????????????????????????檔
????--user???????MySQL?????????????REPLICATION SLAVE????
????--stop-never??mysqlbinlog??????????????????????????binlog???????????????binlog???浽???????????????????????????????????????δ?????mysqlbinlog???????????????????binlog??
????mysql-bin.000001??????????binlog????????
?????????????????????????????????????
????--stop-never-slave-server-id?????????????????binlog???mysqlbinlog?????????????????????????????????????????????server-id???????-1??
????--to-last-log??????mysqlbinlog???????????????binlog????????????????binlog?????????????????????????--stop-never???????????--to-last-log??
????--result-file????????????????????binlog?????浽???????????????mysql-bin.000001????????--result-file=/test/backup-?????浽????????????/test/backup-mysql-bin.000001??????????--result-file?????????????????????????“/”?????--result-file=/test/????????--result-file=/test????????浽???????????/testmysql-bin.000001??
????????
???????????и??????????????????????????????????????????????????????????????????mysqlbinlog?????????????????????????
?????????????
?????????????????????????
#!/bin/sh
BACKUP_BIN=/usr/bin/mysqlbinlog
LOCAL_BACKUP_DIR=/backup/binlog/
BACKUP_LOG=/backup/binlog/backuplog
REMOTE_HOST=192.168.244.145
REMOTE_PORT=3306
REMOTE_USER=repl
REMOTE_PASS=repl
FIRST_BINLOG=mysql-bin.000001
#time to wait before reconnecting after failure
SLEEP_SECONDS=10
##create local_backup_dir if necessary
mkdir -p ${LOCAL_BACKUP_DIR}
cd ${LOCAL_BACKUP_DIR}
## ????while?????????????????????????????
while :
do
if [ `ls -A "${LOCAL_BACKUP_DIR}" |wc -l` -eq 0 ];then
LAST_FILE=${FIRST_BINLOG}
else
LAST_FILE=`ls -l ${LOCAL_BACKUP_DIR} | grep -v backuplog |tail -n 1 |awk '{print $9}'`
fi
${BACKUP_BIN} --raw --read-from-remote-server --stop-never --host=${REMOTE_HOST} --port=${REMOTE_PORT} --user=${REMOTE_USER} --password=${REMOTE_PASS} ${LAST_FILE}
echo "`date +"%Y/%m/%d %H:%M:%S"` mysqlbinlog???????????$?" | tee -a ${BACKUP_LOG}
echo "${SLEEP_SECONDS}???????????????????" | tee -a ${BACKUP_LOG}
sleep ${SLEEP_SECONDS}
done
????????????
????1. ?????????????????????????????????10s???????????
????2. ???????????????FIRST_BINLOG???????????binlog????????????mysql-bin.000001????????е??????????????????μ?binlog?????μ?binlog????????
???????
????1. ????????--raw??mysqlbinlog??????????????????????????????????????????????У??4K?????Ρ??????????????????д????????????mysqlbinlog?????????????????????????????е?binlog????????μ??????С?
????2. ????mysqlbinlog??????????????????????????relaylog??????????????????????????????????????????????д??relaylog?С?
????3. ????????--raw???????????????????????????--result-file=/test/???????????????????д????????????--result-file=/test/1.sql???????mysqlbinlog???????????????????????4K?????Ρ?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11