Red Hat Training

A Red Hat training course is available for Red Hat Virtualization

6.2. 恢复自承载引擎环境

本节介绍了如何在一个新安装的主机上恢复自承载引擎环境。支持的恢复方法是使用 engine-backup 工具程序。
恢复自承载引擎环境包括以下几个关键操作:
  1. 创建一个全新安装的 Red Hat Enterprise Linux 主机并运行 hosted-engine 部署脚本。
  2. 在新的 Manager 虚拟机上恢复 Red Hat Enterprise Manager 的配置设置,以及数据库的内容。
  3. 删除处于 Non Operational 状态的主机,并在恢复的自承载环境中重新安装它们。

前提条件

  • 一个安装了全新 Red Hat Enterprise Linux 系统的物理主机来恢复自承载引擎环境。
  • 新的主机和 Manager 的操作系统版本必须和原来的版本相同。
  • 新环境需要具有 Red Hat Subscription Manager 权利。如需获得所需存储库的完整列表,请参阅安装指南中的订阅所需的权利
  • 新的 Manager 的完全限定域名需要和原始 Manager 的完全限定域名相同。DNS 中需要有它的正向和反向查询记录。
  • 您必须为新的自承载引擎环境准备好存储,用作 Manager 虚拟机的共享存储域。共享存储域应至少为 60 GB。如需了解与存储准备有关的更多信息,请参考管理指南中的存储章节。

6.2.1. 创建一个新的自承载引擎环境作为恢复的环境

您可以在备份环境中的硬件上恢复自承载引擎,但是必须使用故障转移(failover)主机。第 6.1 节 “备份自承载引擎 Manager 虚拟机” 中的故障转移主机(Host 1)使用默认的值作为主机名 - hosted_engine_1,这个主机名也在这里使用。因为自承载引擎恢复的特性,在对所恢复的引擎进行最后的同步前,使用的故障转移主机需要被删除(这要求在进行备份时,主机上没有运行任何虚拟机)。另外,您也可以在备份环境外的硬件上进行恢复。

重要

本过程假设您已经在一台物理主机上全新安装了 Red Hat Enterprise Linux 系统,并为主机订阅了所需的权利,而且安装了 ovirt-hosted-engine-setup 软件包。如需了解更多信息,请参阅安装指南中的订阅所需的权利第 2.1.1 节 “安装自承载引擎软件包”

过程 6.4. 创建一个新的自承载环境作为恢复的环境

  1. 更新 DNS

    更新 DNS,使 Red Hat Virtualization 环境的完全限定域名与新 Manager 的 IP 地址相对应。在以下过程中,完全限定域名被设置为 Manager.example.com。引擎的完全限定域名需要和备份中的原始引擎使用的值相同。
  2. 初始化引擎

    在新安装的 Red Hat Enterprise Linux 主机上运行 hosted-engine 脚本开始部署的过程。您可以在任何时候使用 CTRL+D 键终止部署的过程。如果通过网络运行 hosted-engine 部署脚本,则推荐使用 screen 窗口管理程序以避免在出现网络问题或其它问题时丢失部署进程。如果还没有安装,请安装 screen
    # screen
    # hosted-engine --deploy
  3. 准备初始化

    脚本开始会要求您确认在自承载引擎环境中作为虚拟机管理程序(hypervisor)的主机信息。
    Continuing will configure this host for serving as hypervisor and create a VM where you have to install oVirt Engine afterwards. 
    Are you sure you want to continue? (Yes, No)[Yes]:
  4. 配置存储

    选择使用的存储类型。
    During customization use CTRL-D to abort.
    Please specify the storage you would like to use (glusterfs, iscsi, fc, nfs3, nfs4)[nfs3]:
    • 对于 NFS 存储类型,使用 FQDN 或 IP 地址指定它的完整地址,以及共享存储域的路径名。
      Please specify the full shared storage connection path to use (example: host:/path): storage.example.com:/hosted_engine/nfs
    • 对于 iSCSI,指定 iSCSI 门户 IP 地址、端口、用户名和密码,并从检测到的列表中选择一个目标名。在部署的过程中只能选择一个 iSCSI 目标:
      Please specify the iSCSI portal IP address:           
      Please specify the iSCSI portal port [3260]:           
      Please specify the iSCSI portal user:           
      Please specify the iSCSI portal password:
      Please specify the target name (auto-detected values) [default]:
    • 对于 Gluster 存储类型,使用 FQDN 或 IP 地址指定它的完整地址,以及共享存储域的路径名。

      重要

      当前只支持 replica 3 Gluster 存储。请确认已进行了以下配置:
      • 在所有 3 个 Gluster 服务器的 /etc/glusterfs/glusterd.vol 文件中,把 rpc-auth-allow-insecure 设置为 on
        option rpc-auth-allow-insecure on
      • 对卷进行以下配置:
        gluster volume set volume cluster.quorum-type auto
        gluster volume set volume network.ping-timeout 10
        gluster volume set volume auth.allow \*
        gluster volume set volume group virt
        gluster volume set volume storage.owner-uid 36
        gluster volume set volume storage.owner-gid 36
        gluster volume set volume server.allow-insecure on
      Please specify the full shared storage connection path to use (example: host:/path): storage.example.com:/hosted_engine/gluster_volume
    • 对于光纤通道设备,主机的总线适配器需要被配置和连接,hosted-engine 脚本会自动检测到有效的 LUN。LUN 不能包括任何额外的数据。
      The following luns have been found on the requested target:
      [1]     3514f0c5447600351       30GiB   XtremIO XtremApp
                              status: used, paths: 2 active
                
      [2]     3514f0c5447600352       30GiB   XtremIO XtremApp
                              status: used, paths: 2 active
      
      Please select the destination LUN (1, 2) [1]:
  5. 配置网络

    这个脚本会检索可以作为环境的管理网桥的网卡(NIC),然后检查防火墙的配置,并根据控制台(SPICE 或 VNC)访问 Manager 虚拟机的需要来修改防火墙的配置。另外,它还需要一个可以被 ping 到的网关 IP 地址,ovirt-ha-agent 会使用它来决定主机是否适合运行 Manager 虚拟机。
    Please indicate a nic to set ovirtmgmt bridge on: (eth1, eth0) [eth1]:
    iptables was detected on your computer, do you wish setup to configure it? (Yes, No)[Yes]: 
    Please indicate a pingable gateway IP address [X.X.X.X]:
    
  6. 配置新的 Manager 虚拟机

    这个脚本会创建一个新的 Manager 虚拟机。根据具体情况指定引导设备、安装媒体的路径名、镜像别名、CPU 类型、虚拟 CPU 的数量以及磁盘的大小。为 Manager 虚拟机指定一个 MAC 地址,或使用系统自动创建的地址。在为 Manager 虚拟机安装操作系统前,这个 MAC 地址可以被用来更新 DHCP 服务器。为所创建的 Manager 虚拟机指定内存的大小和控制台连接类型。
    Please specify the device to boot the VM from (cdrom, disk, pxe) [cdrom]: 
    Please specify an alias for the Hosted Engine image [hosted_engine]:  
    The following CPU types are supported by this host:
              - model_Penryn: Intel Penryn Family
              - model_Conroe: Intel Conroe Family
    Please specify the CPU type to be used by the VM [model_Penryn]: 
    Please specify the number of virtual CPUs for the VM [Defaults to minimum requirement: 2]: 
    Please specify the disk size of the VM in GB [Defaults to minimum requirement: 25]: 
    You may specify a MAC address for the VM or accept a randomly generated default [00:16:3e:77:b2:a4]: 
    Please specify the memory size of the VM in MB [Defaults to minimum requirement: 4096]: 
    Please specify the console type you want to use to connect to the VM (vnc, spice) [vnc]:
    
  7. 指定主机的名称

    指定 admin@internal 用户用来访问管理门户的密码。
    为主机提供一个唯一的名称,避免与从备份中恢复的名称冲突。hosted_engine_1 这个名称可以在此使用,因为在进行备份前,这个主机已被设置为维护模式,它会在恢复引擎操作和在主机与引擎进行最后的同步操作间被删除。
    Enter engine admin password: 
    Confirm engine admin password:
    Enter the name which will be used to identify this host inside the Administration Portal [hosted_engine_1]:
  8. 配置引擎

    提供新的 Manager 虚拟机的完全限定域名。在这里使用 Manager.example.com 作为完全限定域名。指定 SMTP 服务器的名称、TCP 端口号、发送通知电子邮件的电邮地址、接收通知的一组电邮地址(以逗号分隔)。

    重要

    为引擎提供的完全限定域名(Manager.example.com)必须和初始设置原始 Manager 时提供的完全限定域名相同。
    Please provide the FQDN for the engine you would like to use.
    This needs to match the FQDN that you will use for the engine installation within the VM.
     Note: This will be the FQDN of the VM you are now going to create,
     it should not point to the base host or to any other existing machine.
     Engine FQDN: Manager.example.com
    Please provide the name of the SMTP server through which we will send notifications [localhost]: 
    Please provide the TCP port number of the SMTP server [25]: 
    Please provide the email address from which notifications will be sent [root@localhost]: 
    Please provide a comma-separated list of email addresses which will get notifications [root@localhost]:
  9. 配置预览

    在实际进行配置前,hosted-engine 脚本会显示您已输入的信息,并提示您确认这些信息。
    Bridge interface                   : eth1
    Engine FQDN                        : Manager.example.com
    Bridge name                        : ovirtmgmt
    SSH daemon port                    : 22
    Firewall manager                   : iptables
    Gateway address                    : X.X.X.X
    Host name for web application      : hosted_engine_1
    Host ID                            : 1
    Image alias                        : hosted_engine
    Image size GB                      : 25
    Storage connection                 : storage.example.com:/hosted_engine/nfs
    Console type                       : vnc
    Memory size MB                     : 4096
    MAC address                        : 00:16:3e:77:b2:a4
    Boot type                          : pxe
    Number of CPUs                     : 2
    CPU Type                           : model_Penryn
    
    Please confirm installation settings (Yes, No)[Yes]:
    
  10. 创建新的 Manager 虚拟机

    这个脚本创建的虚拟机会被配置为 Manager 虚拟机,并提供和它进行连接的信息。在 hosted-engine 脚本可以继续配置引擎前,您需要在这个虚拟机上安装一个操作系统 。
    [ INFO  ] Stage: Transaction setup
    [ INFO  ] Stage: Misc configuration
    [ INFO  ] Stage: Package installation
    [ INFO  ] Stage: Misc configuration
    [ INFO  ] Configuring libvirt
    [ INFO  ] Configuring VDSM
    [ INFO  ] Starting vdsmd
    [ INFO  ] Waiting for VDSM hardware info
    [ INFO  ] Waiting for VDSM hardware info
    [ INFO  ] Configuring the management bridge
    [ INFO  ] Creating Storage Domain
    [ INFO  ] Creating Storage Pool
    [ INFO  ] Connecting Storage Pool
    [ INFO  ] Verifying sanlock lockspace initialization
    [ INFO  ] Creating VM Image
    [ INFO  ] Disconnecting Storage Pool
    [ INFO  ] Start monitoring domain
    [ INFO  ] Configuring VM
    [ INFO  ] Updating hosted-engine configuration
    [ INFO  ] Stage: Transaction commit
    [ INFO  ] Stage: Closing up
    [ INFO  ] Creating VM
    You can now connect to the VM with the following command:
          /usr/bin/remote-viewer vnc://localhost:5900
    Use temporary password "3477XXAM" to connect to vnc console.
    Please note that in order to use remote-viewer you need to be able to run graphical applications.
    This means that if you are using ssh you have to supply the -Y flag (enables trusted X11 forwarding).
    Otherwise you can run the command from a terminal in your preferred desktop environment.
    If you cannot run graphical applications you can connect to the graphic console from another host or connect to the console using the following command:
    virsh -c qemu+tls://Test/system console HostedEngine
    If you need to reboot the VM you will need to start it manually using the command:
    hosted-engine --vm-start
    You can then set a temporary password using the command:
    hosted-engine --add-console-password
    The VM has been started.  Install the OS and shut down or reboot it.  To continue please make a selection:
             
      (1) Continue setup - VM installation is complete
      (2) Reboot the VM and restart installation
      (3) Abort setup
      (4) Destroy VM and abort setup
             
      (1, 2, 3, 4)[1]:
    使用以下命令通过 VNC 连接到虚拟机:
    /usr/bin/remote-viewer vnc://hosted_engine_1.example.com:5900
  11. 安装虚拟机操作系统

    连接到 Manager 虚拟机,安装 Red Hat Enterprise Linux 7 作为操作系统。
  12. 把主机和 Manager 进行同步

    返回到主机,选择选项 1 来继续 hosted-engine 脚本:
    (1) Continue setup - VM installation is complete
    Waiting for VM to shut down...
    [ INFO  ] Creating VM
    You can now connect to the VM with the following command:
          /usr/bin/remote-viewer vnc://localhost:5900
    Use temporary password "3477XXAM" to connect to vnc console.
    Please note that in order to use remote-viewer you need to be able to run graphical applications.
    This means that if you are using ssh you have to supply the -Y flag (enables trusted X11 forwarding).
    Otherwise you can run the command from a terminal in your preferred desktop environment.
    If you cannot run graphical applications you can connect to the graphic console from another host or connect to the console using the following command:
    virsh -c qemu+tls://Test/system console HostedEngine
    If you need to reboot the VM you will need to start it manually using the command:
    hosted-engine --vm-start
    You can then set a temporary password using the command:
    hosted-engine --add-console-password
    Please install and setup the engine in the VM.
    You may also be interested in subscribing to "agent" RHN/Satellite channel and installing rhevm-guest-agent-common package in the VM.
    To continue make a selection from the options below:
      (1) Continue setup - engine installation is complete
      (2) Power off and restart the VM
      (3) Abort setup
      (4) Destroy VM and abort setup
             
      (1, 2, 3, 4)[1]:
  13. 安装 Manager

    连接到新的 Manager 虚拟机,确认所有安装的软件包都是最新版本,安装 rhevm 软件包。
    # yum update

    注意

    如果与内核相关的软件包已被更新,则需要重启机器。
    # yum install rhevm
在软件包安装完成后,您就可以继续自承载引擎 Manager 的恢复过程。

6.2.2. 恢复自承载引擎 Manager

以下介绍了如何使用 engine-backup 工具程序来自动为备份的自承载引擎 Manager 虚拟机和 Data Warehouse 恢复设置以及数据库的内容。这些内容只适用于初始运行 engine-setup 时自动配置的组件。如果在运行 engine-setup 时手工配置了数据库,请参照 第 6.2.3 节 “手工恢复自承载引擎 Manager” 中的内容手工恢复备份的环境。

过程 6.5. 恢复自承载引擎 Manager

  1. 把备份文件安全地复制到新的 Manager 虚拟机上。以下示例把文件从一个网络存储服务器复制到 第 6.1 节 “备份自承载引擎 Manager 虚拟机” 所复制的文件中。Storage.example.com 是存储服务器的完全限定域名;/backup/EngineBackupFiles 是备份文件在存储服务器上的文件路径;/backup/ 是文件要被复制到的、在新 Manager 机器上的文件路径。
    # scp -p Storage.example.com:/backup/EngineBackupFiles /backup/
  2. 使用 engine-backup 工具程序恢复一个完整的备份。
    • 如果只恢复 Manager,运行以下命令:
      # engine-backup --mode=restore --file=file_name --log=log_file_name --provision-db --restore-permissions
    • 如果恢复 Manager 和 Data Warehouse,运行以下命令:
      # engine-backup --mode=restore --file=file_name --log=log_file_name --provision-db --provision-dwh-db --restore-permissions
    如果运行成功,以下输出会被显示:
    You should now run engine-setup.
    Done.
  3. 配置恢复的 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]:
  4. 从恢复的环境中删除主机

    如果被恢复的自承载引擎部署在一个新硬件中,而这个硬件系统的名称没有出现在备份的引擎中,则跳过这一步。这一步只适用于在一个故障转移主机上(hosted_engine_1)进行部署的情况。因为这个主机在备份时已存在,它仍然还会存在于恢复的引擎中。因此,在进行最后的同步前,需要把它先从环境中删除。
    1. 登录到管理门户
    2. 主机标签页。故障转移主机(hosted_engine_1)会处于维护模式,而且没有运行任何虚拟机。
    3. 删除
    4. 确定

    注意

    如果需要删除的主机的状态为 non-operational,请参照 第 6.2.4 节 “从恢复的自承载引擎环境中删除状态为 Non-Operational 的主机” 中的介绍来强制删除这个主机。
  5. 把主机和 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.
  6. 关闭新的 Manager 虚拟机。
    # shutdown -h now
  7. 返回到主机,确认它检测到 Manager 虚拟机已被关闭。
    [ INFO  ] Enabling and starting HA services
              Hosted Engine successfully set up
    [ INFO  ] Stage: Clean up
    [ INFO  ] Stage: Pre-termination
    [ INFO  ] Stage: Termination
  8. 激活主机。
    1. 登录到管理门户
    2. 主机标签页。
    3. hosted_engine_1 并点维护按钮。主机可能会需要几分钟时间进入维护模式。
    4. 激活按钮。
    一旦激活后,hosted_engine_1 就可以竞争成为 SPM,存储域和数据中心都变为活跃状态。
  9. 对状态为 Non Responsive 的主机进行手工隔离(fencing),这会使它上面的虚拟机迁移到其它活跃的主机上。在管理门户中,点主机右键,选确认“主机已被重启”
    当进行备份时在那个主机上运行的所有虚拟机都会被从那个主机上删除,并从 Unknown 状态变为 Down 状态。这些虚拟机现在可以在 hosted_engine_1 上运行。使用 REST API 把被隔离的主机强制删除。
现在,这个环境已被恢复到 hosted_engine_1 活跃时的状态,并可以在恢复的环境中运行虚拟机。那些处于 Non Operational 状态的、可以运行引擎的主机现在就可以按照 第 6.2.4 节 “从恢复的自承载引擎环境中删除状态为 Non-Operational 的主机” 中的步骤被删除,并根据 第 7 章 在自承载环境中安装额外的主机 中介绍的步骤在新环境中重新安装。

注意

如果 Manager 数据库被成功恢复,但 Manager 虚拟机的状态为 Down,并且无法被迁移到另外一个自承载的主机上,您可以启用一个新的 Manager 虚拟机,并按照 https://access.redhat.com/solutions/1517683 中的步骤把不再可用的 Manager 虚拟机从环境中删除。

6.2.3. 手工恢复自承载引擎 Manager

以下介绍了如何通过备份手工恢复一个自承载引擎 Manager 虚拟机的配置信息和数据库内容。

过程 6.6. 恢复自承载引擎 Manager

  1. 手工创建一个空的数据库来保存从备份中恢复的数据库内容。以下操作需要在数据库所在的机器上执行。
    1. 如果数据库不在 Manager 虚拟机上,则需要安装 postgresql-server 软件包。如果虚拟机位于 Manager 所在的虚拟机上,则不需要进行这一步,因为这个软件包已包括在 rhevm 软件包中。
      # yum install postgresql-server
    2. 初始化 postgresql 数据库,启动 postgresql 服务,把它设置为在系统引导时被自动启动:
      # postgresql-setup initdb
      # systemctl start postgresql.service
      # systemctl enable postgresql.service
    3. 进入 postgresql 命令行:
      # su postgres
      $ psql
    4. 创建 engine 用户:
      postgres=# create role engine with login encrypted password 'password';
      如果还需要恢复 Data Warehouse,在相关的主机上创建 ovirt_engine_history 用户:
      postgres=# create role ovirt_engine_history with login encrypted password 'password';
    5. 创建新数据库:
      postgres=# create database database_name owner engine template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
      如果还需要恢复 Data Warehouse,在相关的主机上创建数据库:
      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';
    6. 退出 postgresql 命令行并登出 postgres 用户:
      postgres=# \q
      $ exit
    7. 编辑 /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
    8. 重启 postgresql 服务:
      # systemctl restart postgresql.service
  2. 把备份文件安全地复制到新的 Manager 虚拟机上。以下示例把文件从一个网络存储服务器复制到 第 6.1 节 “备份自承载引擎 Manager 虚拟机” 所复制的文件中。Storage.example.com 是存储服务器的完全限定域名;/backup/EngineBackupFiles 是备份文件在存储服务器上的文件路径;/backup/ 是文件要被复制到的、在新 Manager 机器上的文件路径。
    # scp -p Storage.example.com:/backup/EngineBackupFiles /backup/
  3. 恢复一个完整备份或数据库备份(通过 --change-db-credentials 参数指定新数据库的凭证信息)。Manager 本地数据库的 database_locationlocalhost

    注意

    在以下的例子中,对于每个数据库都使用了没有指定密码的 --*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
      如果需要恢复作为完全备份一部分的 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-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 --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=files --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.
  4. 配置恢复的 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]:
  5. 从恢复的环境中删除主机

    如果被恢复的自承载引擎部署在一个新硬件中,而这个硬件系统的名称没有出现在备份的引擎中,则跳过这一步。这一步只适用于在一个故障转移主机上(hosted_engine_1)进行部署的情况。因为这个主机在备份时已存在,它仍然还会存在于恢复的引擎中。因此,在进行最后的同步前,需要把它先从环境中删除。
    1. 登录到管理门户。
    2. 主机标签页。故障转移主机(hosted_engine_1)会处于维护模式,而且没有运行任何虚拟机。
    3. 删除
    4. 确定
  6. 把主机和 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.
  7. 关闭新的 Manager 虚拟机。
    # shutdown -h now
  8. 返回到主机,确认它检测到 Manager 虚拟机已被关闭。
    [ INFO  ] Enabling and starting HA services
              Hosted Engine successfully set up
    [ INFO  ] Stage: Clean up
    [ INFO  ] Stage: Pre-termination
    [ INFO  ] Stage: Termination
  9. 激活主机。
    1. 登录到管理门户。
    2. 主机标签页。
    3. hosted_engine_1 并点维护按钮。主机可能会需要几分钟时间进入维护模式。
    4. 激活按钮。
    一旦激活后,hosted_engine_1 就可以竞争成为 SPM,存储域和数据中心都变为活跃状态。
  10. 对状态为 Non Responsive 的主机进行手工隔离(fencing),这会使它上面的虚拟机迁移到其它活跃的主机上。在管理门户中,点主机右键,选确认“主机已被重启”
    当进行备份时在那个主机上运行的所有虚拟机都会被从那个主机上删除,并从 Unknown 状态变为 Down 状态。这些虚拟机现在可以在 hosted_engine_1 上运行。使用 REST API 把被隔离的主机强制删除。
现在,这个环境已被恢复到 hosted_engine_1 活跃时的状态,并可以在恢复的环境中运行虚拟机。那些处于 Non Operational 状态的、可以运行引擎的主机现在就可以按照 第 6.2.4 节 “从恢复的自承载引擎环境中删除状态为 Non-Operational 的主机” 中的步骤被删除,并根据 第 7 章 在自承载环境中安装额外的主机 中介绍的步骤在新环境中重新安装。

注意

如果 Manager 数据库被成功恢复,但 Manager 虚拟机的状态为 Down,并且无法被迁移到另外一个自承载的主机上,您可以启用一个新的 Manager 虚拟机,并按照 https://access.redhat.com/solutions/1517683 中的步骤把不再可用的 Manager 虚拟机从环境中删除。

6.2.4. 从恢复的自承载引擎环境中删除状态为 Non-Operational 的主机

当一个主机通过管理门户被隔离(fencing) 后,就可以使用 REST API 请求强制删除它。这个过程会使用 cURL(一个命令行接口,多数 Linux 发行版本都会包括它)向 HTTP 服务器发送一个请求。它会连接到 Manager 虚拟机来进行相关的请求。
  1. 隔离无法正常工作的主机

    在管理门户中,在主机上点鼠标右键,选确认“主机已被重启”
    当进行备份时在那个主机上运行的所有虚拟机都会被从那个主机上删除,并从 Unknown 状态变为 Down 状态。使用 REST API 把被隔离的主机强制删除。
  2. 获得 Manager 的证书颁发机构(CA)

    连接到 Manager 虚拟机,在命令行中使用 cURL 进行以下请求。
    使用 GET 请求获得 Manager 的 CA 以供今后的 API 请求使用。在下面的示例中,使用 --output 选项指定 hosted-engine.ca 文件作为 Manager CA 证书的输出。--insecure 选项意味着这个初始的请求不包括证书。
    # curl --output hosted-engine.ca --insecure https://[Manager.example.com]/ca.crt
  3. 获得要被删除的主机的 GUID

    在主机集合中使用一个 GET 请求获得要被删除的主机的 GUID。以下例子中包括了 Manager CA 证书文件,使用 admin@internal 用户进行验证,并在命令执行过程中会被提示输入它的密码。
    # curl --request GET --cacert hosted-engine.ca --user admin@internal https://[Manager.example.com]/api/hosts
    这个请求会返回环境中所有主机的信息。主机的 GUID 是和主机名相连的十六进制字符串。如需了解更多与 Red Hat Virtualization REST API 相关的信息,请参阅 Red Hat Virtualization REST API Guide
  4. 删除隔离的主机

    使用带有被隔离主机的 GUID 的 DELETE 请求从环境中删除这个主机。除了以前请求中使用的参数,这个例子中的请求还包括使用 XML 的头(header),以及内容(body)项。在内容项中,把 force 操作设置为 true
    curl --request DELETE --cacert hosted-engine.ca --user admin@internal --header "Content-Type: application/xml" --header "Accept: application/xml" --data "<action><force>true</force></action>" https://[Manager.example.com]/api/hosts/ecde42b0-de2f-48fe-aa23-1ebd5196b4a5
    只要指定了相应的 GUID,就可以使用这个 DELETE 请求来移除自承载引擎环境中的每一个隔离的主机。
  5. 从主机上删除自承载引擎配置

    删除存在的主机自承载引擎配置,从而可以在主机被重新安装到一个自承载引擎环境中时对它进行配置。
    登录到主机,删除配置文件:
    # rm /etc/ovirt-hosted-engine/hosted-engine.conf
现在,主机就可以被重新安装到自承载引擎环境中。