Show Table of Contents
6.3. 恢复自承载引擎 Manager
以下介绍了如何通过备份恢复一个自承载引擎 Manager 虚拟机的配置信息和数据库内容。
过程 6.3. 恢复自承载引擎 Manager
- 手工创建一个空的数据库来保存从备份中恢复的数据库内容。以下操作需要在数据库所在的机器上执行。
- 如果数据库不在 Manager 虚拟机上,则需要安装 postgresql-server 软件包。如果虚拟机位于 Manager 所在的虚拟机上,则不需要进行这一步,因为这个软件包已包括在 rhevm 软件包中。
# yum install postgresql-server
- 初始化
postgresql数据库,启动postgresql服务,把它设置为在系统引导时被自动启动:# service postgresql initdb # service postgresql start # chkconfig postgresql on
- 进入 postgresql 命令行:
# su postgres $ psql
- 创建
engine用户:postgres=# create role engine with login encrypted password 'password';
如果您还需要恢复 Reports 和 Data Warehouse,在相关的主机上创建ovirt_engine_reports和ovirt_engine_history用户:postgres=# create role ovirt_engine_reports with login encrypted password 'password';
postgres=# create role ovirt_engine_history with login encrypted password 'password';
- 创建新数据库:
postgres=# create database database_name owner engine template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
如果您还需要恢复 Reports 和 Data Warehouse,在相关的主机上创建数据库:postgres=# create database database_name owner ovirt_engine_reports template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
postgres=# create database database_name owner ovirt_engine_history template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
- 退出 postgresql 命令行并登出 postgres 用户:
postgres=# \q $ exit
- 编辑
/var/lib/pgsql/data/pg_hba.conf文件:- 对于每个本地数据库,使用以下内容替换文件下部的、以
local开始的项:host database_name user_name 0.0.0.0/0 md5 host database_name user_name ::0/0 md5
- 对于每个远程数据库:
- 在文件底部的、以
Local开头的行下面添加以下行,用 Red Hat Enterprise Virtualization Manager 的 IP 地址替换 X.X.X.X:host database_name user_name X.X.X.X/32 md5
- 允许 TCP/IP 到数据库的连接。编辑
/var/lib/pgsql/data/postgresql.conf文件,添加以下行:listen_addresses='*'
在这个例子中,postgresql服务被配置为监听所有接口上的连接。您可以使用 IP 地址来指定只监听特定接口上的连接。 - 修改防火墙规则来打开 PostgreSQL 数据库连接所使用的默认端口,然后保存更新的防火墙规则:
# iptables -I INPUT 5 -p tcp -s Manager_IP_Address --dport 5432 -j ACCEPT # service iptables save
- 重启
postgresql服务:# service postgresql restart
把备份文件复制到新的 Manager 所在的机器上
把备份文件安全地复制到新的 Manager 虚拟机上。此例会把文件从一个网络存储服务器复制到 第 6.1 节 “备份自承载引擎 Manager 虚拟机” 所复制的文件中。Storage.example.com 是存储服务器的完全限定域名;/backup/EngineBackupFiles 是备份文件在存储服务器上的文件路径;/backup/ 是文件要被复制到的、在新 Manager 机器上的文件路径。# scp -p Storage.example.com:/backup/EngineBackupFiles /backup/
- 恢复一个完整备份或数据库备份(通过
--change-db-credentials参数指定新数据库的凭证信息)。Manager 本地数据库的 database_location 是localhost:注意
在以下的例子中,对于每个数据库都使用了没有指定密码的--*password选项,这会使数据库在相应的阶段要求用户输入密码。虽然可以在命令中使用这些选项指定密码,但是这些密码信息会被保存在 shell 的历史记录中,因此我们不推荐使用这个方法来提供密码。另外,也可以选择使用--*passfile=password_file 选项来为engine-backup安全地传递每个数据库的密码,而不再需要人工输入密码。- 恢复一个完全备份:
# engine-backup --mode=restore --file=file_name --log=log_file_name --change-db-credentials --db-host=database_location --db-name=database_name --db-user=engine --db-password
如果需要恢复作为完全备份一部分的 Reports 和 Data Warehouse,则要包括这两个数据库的凭证:engine-backup --mode=restore --file=file_name --log=log_file_name --change-db-credentials --db-host=database_location --db-name=database_name --db-user=engine --db-password --change-reports-db-credentials --reports-db-host=database_location --reports-db-name=database_name --reports-db-user=ovirt_engine_reports --reports-db-password --change-dwh-db-credentials --dwh-db-host=database_location --dwh-db-name=database_name --dwh-db-user=ovirt_engine_history --dwh-db-password
- 恢复数据库备份会首先恢复配置文件备份,然后再恢复数据库备份:
# engine-backup --mode=restore --scope=files --file=file_name --log=log_file_name
# engine-backup --mode=restore --scope=db --file=file_name --log=file_name --change-db-credentials --db-host=database_location --db-name=database_name --db-user=engine --db-password
以上例子恢复了 Manager 数据库的备份。# engine-backup --mode=restore --scope=reportsdb --file=file_name --log=file_name --change-reports-db-credentials --reports-db-host=database_location --reports-db-name=database_name --reports-db-user=ovirt_engine_reports --reports-db-password
以上例子恢复了 Reports 数据库的备份。# engine-backup --mode=restore --scope=dwhdb --file=file_name --log=file_name --change-dwh-db-credentials --dwh-db-host=database_location --dwh-db-name=database_name --dwh-db-user=ovirt_engine_history --dwh-db-password
以上例子恢复了 Data Warehouse 数据库的备份。
如果运行成功,以下输出会被显示:You should now run engine-setup. Done.
配置 Manager
配置恢复的 Manager 虚拟机。这个过程会检测到存在的配置设置和数据库内容。确认这些设置。完成后,系统会提供一个 SSH 指纹(fingerprint)和一个内部的证书授权哈希数据(Certificate Authority hash)。# engine-setup
[ INFO ] Stage: Initializing [ INFO ] Stage: Environment setup Configuration files: ['/etc/ovirt-engine-setup.conf.d/10-packaging.conf', '/etc/ovirt-engine-setup.conf.d/20-setup-ovirt-post.conf'] Log file: /var/log/ovirt-engine/setup/ovirt-engine-setup-20140304075238.log Version: otopi-1.1.2 (otopi-1.1.2-1.el6ev) [ INFO ] Stage: Environment packages setup [ INFO ] Yum Downloading: rhel-65-zstream/primary_db 2.8 M(70%) [ INFO ] Stage: Programs detection [ INFO ] Stage: Environment setup [ INFO ] Stage: Environment customization --== PACKAGES ==-- [ INFO ] Checking for product updates... [ INFO ] No product updates found --== NETWORK CONFIGURATION ==-- Setup can automatically configure the firewall on this system. Note: automatic configuration of the firewall may overwrite current settings. Do you want Setup to configure the firewall? (Yes, No) [Yes]: [ INFO ] iptables will be configured as firewall manager. --== DATABASE CONFIGURATION ==-- --== OVIRT ENGINE CONFIGURATION ==-- Skipping storing options as database already prepared --== PKI CONFIGURATION ==-- PKI is already configured --== APACHE CONFIGURATION ==-- --== SYSTEM CONFIGURATION ==-- --== END OF CONFIGURATION ==-- [ INFO ] Stage: Setup validation [ INFO ] Cleaning stale zombie tasks --== CONFIGURATION PREVIEW ==-- Database name : engine Database secured connection : False Database host : X.X.X.X Database user name : engine Database host name validation : False Database port : 5432 NFS setup : True Firewall manager : iptables Update Firewall : True Configure WebSocket Proxy : True Host FQDN : Manager.example.com NFS mount point : /var/lib/exports/iso Set application as default page : True Configure Apache SSL : True Please confirm installation settings (OK, Cancel) [OK]:从恢复的环境中删除主机
如果被恢复的自承载引擎部署在一个新硬件中,而这个硬件系统的名称没有出现在备份的引擎中,则跳过这一步。这一步只适用于在一个故障转移主机上(hosted_engine_1)进行部署的情况。因为这个主机在备份时已存在,它仍然还会存在于恢复的引擎中。因此,在进行最后的同步前,需要把它先从环境中删除。- 登录到管理门户
- 点主机标签页。故障转移主机(
hosted_engine_1)会处于维护模式,而且没有运行任何虚拟机。 - 点。
- 点。
把主机和 Manager 进行同步
返回到主机,选择选项 1 来继续hosted-engine脚本:(1) Continue setup - engine installation is complete
[ INFO ] Engine replied: DB Up!Welcome to Health Status! [ INFO ] Waiting for the host to become operational in the engine. This may take several minutes... [ INFO ] Still waiting for VDSM host to become operational...
在此阶段,hosted_engine_1会出现在管理门户中,它的状态会在变为 Non Operational 前经历 Installing 状态和 Initializing 状态。主机会等待 VDSM 主机变为正常运行的状态,并最终发生超时。这是因为环境中的另外一个主机具有 SPM 角色,而这个具有 SPM 角色的主机处于 Non Responsive 的状态,因此,hosted_engine_1无法和存储域进行交流。当超时发生时,您会被提示关闭虚拟机来完成部署的过程。当部署完成后,主机可以被手工设置为维护模式,并通过管理门户激活。[ INFO ] Still waiting for VDSM host to become operational... [ ERROR ] Timed out while waiting for host to start. Please check the logs. [ ERROR ] Unable to add hosted_engine_2 to the manager Please shutdown the VM allowing the system to launch it as a monitored service. The system will wait until the VM is down.关闭 Manager
关闭新的 Manager 虚拟机。# shutdown -h now
设置确认
返回到主机,确认它检测到 Manager 虚拟机已被关闭。[ INFO ] Enabling and starting HA services Hosted Engine successfully set up [ INFO ] Stage: Clean up [ INFO ] Stage: Pre-termination [ INFO ] Stage: Termination激活主机
- 登录到管理门户
- 点主机标签页。
- 选
hosted_engine_1并点维护按钮。主机可能会需要几分钟时间进入维护模式。 - 点按钮。
一旦激活后,hosted_engine_1就可以竞争成为 SPM,存储域和数据中心都变为活跃状态。把虚拟机迁移到活跃的主机上
对状态为 Non Responsive 的主机进行手工隔离(fencing),这会使它上面的虚拟机迁移到其它活跃的主机上。在管理门户中,点主机右键,选确认“主机已被重启”。当进行备份时在那个主机上运行的所有虚拟机都会被从那个主机上删除,并从 Unknown 状态变为 Down 状态。这些虚拟机现在可以在hosted_engine_1上运行。使用 REST API 把被隔离的主机强制删除。
现在,这个环境已被恢复到
hosted_engine_1 活跃时的状态,并可以在恢复的环境中运行虚拟机。那些处于 Non Operational 状态的、可以运行引擎的主机现在就可以被删除,并在新环境中重新安装。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.