在Ubuntu 14.04終端,我可以從主數據庫轉儲數據庫到從屬:同時爲管道上執行mysqldump的頭使用bash到mysql
mysqldump --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2 --user=myuser --password=[password] --host=127.0.0.1 mydb | mysql --max_allowed_packet=128M -h 192.168.1.110 -u myuser -p[password] otherdb
但我同時要重定向在mysqldump的輸出到head -30 > /tmp/pointintime.log
這樣我就可以得到及時的信息點:
--
-- Position to start replication or point-in-time recovery from
--
-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.049868', MASTER_LOG_POS=107;
如何做到這一點?我試着用tee
但這會導致在從進口端SQL語法錯誤(因爲儘管它打破了輸出,而不是發送完整的語句):
mysqldump --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2 --user=myuser --password=[password] --host=127.0.0.1 mydb | tee >(head -30 >/tmp/pointintime.log) | mysql --max_allowed_packet=128M -h 192.168.1.110 -u myuser -p[password] otherdb
如何mysqldump
進口到從MySQL數據庫,同時檢索head -30
的轉儲?我不想先轉儲到文件,因爲數據庫是巨大的,它更有效地通過網絡。
我也使用多個tee
重定向嘗試,但有相同的語法錯誤:
mysqldump --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2 --user=myuser --password=[password] --host=127.0.0.1 mydb | tee >(mysql --max_allowed_packet=128M -h 192.168.1.110 -u myuser -p[password] otherdb) >(head -30 >/tmp/pointintime.log)
ERROR 1064 (42000) at line 47: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near..
不錯,也請詳細解說。 – joshweir