4.3. 备份 control plane
要备份 control plane,您必须首先停止 pacemaker 集群,以及 control plane 节点上运行的所有容器。不要操作堆栈以确保状态一致性。完成备份过程后,启动 pacemaker 集群和容器。
作为前提条件,您必须备份数据库,以确保在重启 pacemaker 集群和容器后可以恢复数据库。
同时备份 control plane 节点。
前提条件
- 您已创建并导出了备份目录。如需更多信息,请参阅创建并导出备份目录。
- 您已在每个 control plane 节点上安装和配置了 ReaR。如需更多信息,请参阅 安装和配置 Relax 和 Recover (ReaR)。
流程
查找数据库密码:
[heat-admin@overcloud-controller-x ~]# PASSWORD=$(sudo /bin/hiera -c /etc/puppet/hiera.yaml mysql::server::root_password)备份数据库:
[heat-admin@overcloud-controller-x ~]# mysql -uroot -p$PASSWORD -s -N -e "select distinct table_schema from information_schema.tables where engine='innodb' and table_schema != 'mysql';" | xargs mysqldump -uroot -p$PASSWORD --single-transaction --databases > openstack-backup-mysql.sql[heat-admin@overcloud-controller-x ~]# mysql -uroot -p$PASSWORD -s -N -e "SELECT CONCAT('\"SHOW GRANTS FOR ''',user,'''@''',host,''';\"') FROM mysql.user where (length(user) > 0 and user NOT LIKE 'root')" | xargs -n1 mysql -uroot -p$PASSWORD -s -N -e | sed 's/$/;/' > openstack-backup-mysql-grants.sql注意备份数据库是一种预报措施。此步骤可确保如果 Galera 集群没有自动恢复,则可以手动恢复 Galera 集群。有关恢复 Galera 集群的更多信息,请参阅 对 Galera 集群进行故障排除。
在其中一个 control plane 节点上,停止 pacemaker 集群:
重要不要操作堆栈。当您停止 pacemaker 集群和容器时,这会导致将 control plane 服务临时中断到 Compute 节点。网络连接、Ceph 和 NFS data plane 服务也会中断。您不能创建实例、迁移实例、验证请求或监控集群的运行状况,直到 pacemaker 集群和容器按照此流程的最后一步返回服务。
[heat-admin@overcloud-controller-x ~]# sudo pcs cluster stop --all在每个 control plane 节点上,停止容器:
停止容器:
[heat-admin@overcloud-controller-x ~]# sudo docker stop $(sudo docker ps -a -q)停止 ceph-mon@controller.service 容器:
[heat-admin@overcloud-controller-x ~]# sudo systemctl stop ceph-mon@$(hostname -s)停止 ceph-mgr@controller.service 容器:
[heat-admin@overcloud-controller-x ~]# sudo systemctl stop ceph-mgr@$(hostname -s)
可选:如果您使用
ganesha-nfs,请在一个控制器中禁用文件服务器:[heat-admin@overcloud-controller-x ~]# sudo pcs resource disable ceph-nfs可选:如果您使用 ceph 服务
ceph-mds和ceph-rgw,请停止这些服务:[heat-admin@overcloud-controller-x ~]# sudo systemctl stop ceph-mds@$(hostname -s) [heat-admin@overcloud-controller-x ~]# sudo systemctl stop ceph-rgw@$(hostname -s)要备份 control plane,请在每个 control plane 节点上运行 control plane 备份:
[heat-admin@overcloud-controller-x ~]# sudo rear -d -v mkbackup您可以在
/ctl_plane_backups目录下找到您在备份节点上使用 ReaR 创建的备份 ISO 文件。注意执行备份命令时,您可能会看到有关 tar 过程中忽略的
tar命令和套接字的警告信息,类似于以下警告:WARNING: tar ended with return code 1 and below output: ---snip--- tar: /var/spool/postfix/public/qmgr: socket ignored ... ... This message indicates that files have been modified during the archiving process and the backup might be inconsistent. Relax-and-Recover continues to operate, however, it is important that you verify the backup to ensure that you can use this backup to recover your system.当备份过程为每个 control plane 节点生成 ISO 镜像时,重启 pacemaker 集群。在其中一个 control plane 节点上,输入以下命令:
[heat-admin@overcloud-controller-x ~]# sudo pcs cluster start --all在每个 control plane 节点上,启动容器:
启动容器:
[heat-admin@overcloud-controller-x ~]# sudo systemctl restart docker启动
ceph-mon@controller.service容器:[heat-admin@overcloud-controller-x ~]# sudo systemctl start ceph-mon@$(hostname -s)启动
ceph-mgr@controller.service容器:[heat-admin@overcloud-controller-x ~]# sudo systemctl start ceph-mgr@$(hostname -s)
可选:如果您使用
ceph-mds和ceph-rgw,请启动这些服务:[heat-admin@overcloud-controller-x ~]# sudo systemctl start ceph-rgw@$(hostname -s) [heat-admin@overcloud-controller-x ~]# sudo systemctl start ceph-mds@$(hostname -s)可选:如果您使用
ganesha-nfs,请在一个控制器中启用文件服务器:[heat-admin@overcloud-controller-x ~]# sudo pcs resource enable ceph-nfs