[英]How can I achieve 'incremental backup with 1 hour timing' period in mysql using Ansible Playbook based on binlog?
I have two servers. 我有两台服务器。 master and slave which moderated for replication.
主服务器和从属服务器进行复制。 replication process is working good.
复制过程运行良好。 Here I wants to use "incremental dump" option for every one hour and upload that to s3 bucket or another server or local machine(control machine).
在这里,我想每隔一小时使用“增量转储”选项,并将其上传到s3存储桶或其他服务器或本地计算机(控制计算机)。 From the mysql documentations I have a confident to done this using binlogfile.
从mysql文档中,我有信心使用binlogfile完成此操作。 But I have no idea where from I start.
但是我不知道从哪里开始。
I am following the steps which are given below. 我正在执行以下步骤。 But I dont know how the binlog file changing only equivalent of incremental dump even it have all the queries what we done in the database.
但是我不知道binlog文件如何更改仅相当于增量转储,即使它具有我们在数据库中所做的所有查询。
I wants to take dump from slave db. How that will take dump exactly one hour time period. How can I achieve that?
my replication code is here. 我的复制代码在这里。
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "CREATE TABLE db_test.mytable (name VARCHAR(100));"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "INSERT INTO db_test.mytable (name) VALUES ('ANSIBLE');"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "FLUSH TABLES WITH READ LOCK;"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "SHOW MASTER STATUS;"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "unlock tables;"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "drop database db_test;"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "DROP TABLE IF EXISTS db_test.mytable;"
-get master
-adding values to dummy host
-changemaster using dummyhost value
-starting slave
Finally I found a solution. 终于我找到了解决方案。
Flush binary logs
[new binary log file created] Flush binary logs
[已创建新的二进制日志文件] binlog.index
file, found previous binary file. binlog.index
文件,找到以前的二进制文件。 Copied that file to where I want to upload. crontab -e
file. crontab -e
文件来完成自动化。 1 */1 * * *
is the value used for time scheduling.[every first minute of an hour] 1 */1 * * *
是用于时间安排的值。[每小时的第一分钟]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.