4. 使用 Cron 安排备份作业
我们可以使用 cron 来安排 Holland 备份作业。
在这个例子中,我们将通过编辑 root 的 crontab 来配置一个典型的每日备份,该 crontab 将在每天 18:01 运行。
[jack@onitroad ~]# sudo crontab -e -u root 01 18 * * * holland -q bk
默认情况下,备份位置在目录 /var/spool/holland/下,我们可以通过编辑默认配置文件 /etc/holland/holland.conf 并更改 backup_directory 设置来修改它。
3.创建.my.cnf文件
在创建的 default.conf 文件中,我们将 defaults-extra-file 设置为 /root/.my.cnf ,因此我们必须创建 /root/.my.cnf 文件并将数据库凭据放入其中。
[jack@onitroad ~]# cat << END > /root/.my.cnf [client] user = your_user_backup_name_here password = your_user_backup_password_here host = your_master_server_ip_here END
1.安装Holland和依赖:
在继续安装荷兰备份和依赖项之前,我们必须安装 EPEL 存储库:
[jack@onitroad ~]# sudo yum install epel-release [jack@onitroad ~]# sudo yum install holland holland-common holland-mysqldump
Holland 是一个用 Python 编写的开源备份框架。
它可用于根据我们选择安装的插件使用多种方法备份几种不同的数据库类型。
在本教程中,我们将介绍如何在 CentOS 7/RHEL 7 上使用常见的 mysqldump 方法安装和配置 Holland 以备份 MariaDB 或者 MySQL 数据库。
准备工作:创建一个备份用户:
我们将在 MariaDB Master 中创建一个备份用户,Holland 备份将使用它:
[jack@onitroad ~]# mysql -u root -p MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'your_user_backup_name_here'@'%' IDENTIFIED BY 'your_user_backup_password_here' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit
2. 使用 Holland 配置备份任务
默认的荷兰备份作业位置是 /etc/holland/backupsets/,我们可以其中创建新的备份作业。
让我们创建一个新的备份作业文件:
[jack@onitroad ~]# cat << END > /etc/holland/backupsets/default.conf## Default Backup-Set## Backs up all MySQL databases in a one-file-per-database fashion using ## lightweight in-line compression and engine auto-detection. This backup-set ## is designed to provide reliable backups "out of the box", however it is ## generally advisable to create additional custom backup-sets to suit ## one's specific needs. [holland:backup] plugin = mysqldump backups-to-keep = 1 auto-purge-failures = yes purge-policy = after-backup estimated-size-factor = 1.0 # This section defines the configuration options specific to the backup # plugin. In other words, the name of this section should match the name # of the plugin defined above. [mysqldump] file-per-database = yes #lock-method = auto-detect #databases = "*" #exclude-databases = "foo", "bar" #tables = "*" #exclude-tables = "foo.bar" #stop-slave = no #bin-log-position = no # The following section is for compression. The default, unless the # mysqldump provider has been modified, is to use inline fast gzip # compression (which is identical to the commented section below). [compression] method = gzip options = "--rsyncable" [mysql:client] defaults-extra-file = /root/.my.cnf END
日期:2020-06-02 22:18:17 来源:oir作者:oir