第 4 章 迁移到一个基于 RHEL 的自承载环境

4.1. 迁移到自承载环境

当需要把一个标准 Red Hat Enterprise Virtualization 中存在的实例迁移到自承载环境中时,可以使用 hosted-engine 脚本来简化迁移的过程。这个脚本会要求用户输入一系列信息,并根据提供的信息对环境进行配置。在以下过程中,标准 Red Hat Enterprise Virtualization 环境中的 Manager 被称为 BareMetal-Manager。
迁移过程包括以下几个关键的步骤:
  • 运行 hosted-engine 脚本来配置主机作为自承载引擎的主机,并创建一个新的 Red Hat Enterprise Virtualization 虚拟机。
  • 使用 engine-backup 工具程序备份引擎数据库和配置文件,把备份数据复制到新的 Manager 虚拟机上,并使用带有 --mode=restore 选项的 engine-backup 命令恢复备份。运行 engine-setup 对 Manager 虚拟机进行配置。
  • 使用 hosted-engine 脚本进行设置。

先决条件

  • 准备一个安装了 ovirt-hosted-engine-setup 软件包的新 hypervisor 主机。请参阅 第 2 章 在 Red Hat Enterprise Virtualization Hypervisor 上部署自承载引擎 以获得相关的详细信息。主机需要是当前 Red Hat Enterprise Virtualization 环境支持的版本。

    注意

    如果选择使用一个已存在的主机,把它设置为维护模式,并把它移出当前的环境。请参阅 管理指南 中的 Removing a Host 以获得更详细的相关信息。
  • 获得和 BareMetal-Manager 使用的操作系统相同版本的安装介质。
  • 新的 Manager 的完全限定域名需要和原始 BareMetal-Manager 的完全限定域名相同。DNS 中需要有它的正向和反向查询记录。
  • 需要有访问和修改 BareMetal-Manager 的权限。

过程 4.1. 迁移到自承载环境

  1. 初始化引擎

    运行 hosted-engine 脚本。推荐使用 screen 来运行这个脚本,这可以防止,在出现网络问题或终端被非正常终止时丢失当前运行的任务。screen 软件包包括在标准的 Red Hat Enterprise Linux 软件仓库中,安装这个软件包后就可以使用这个工具程序。使用 CTRL+D 键组合可以随时终止脚本。
    # yum install screen
    # screen hosted-engine --deploy

    注意

    当网络中断或超时时,可以运行 screen -d -r 来恢复当前运行的 hosted-engine
  2. 配置存储

    选择使用的存储类型。
    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 地址指定它的完整地址,以及共享存储域的路径名。

      重要

      当前只支持 3 个 Gluster 存储副本(replica)。请确认已进行了以下配置:
      • 在所有 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]:
    选择环境中使用的存储域和存储数据中心名。
    [ INFO  ] Installing on first host
    Please provide storage domain name. [hosted_storage]: 
    Local storage datacenter name is an internal name and currently will not be shown in engine's admin UI.Please enter local datacenter name [hosted_datacenter]:
  3. 配置网络

    这个脚本会检测可以被用来对环境进行管理的网卡(NIC),然后会检查防火墙的配置,并根据控制台(SPICE 或 VNC)访问 HostedEngine-VM 的需要来修改防火墙的配置。另外,提供一个可以被 ping 到的网络 IP 地址,ovirt-ha-agent 会使用它来决定 HostedEngine-VM 是否在正常运行。
    Please indicate a nic to set rhevm 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]:
  4. 配置虚拟机

    脚本会创建一个虚拟机,并把它配置为一个 Red Hat Enterprise Virtualization Manager(在这里被称为 HostedEngine-VM)。指定引导设备、安装介质的路径名、CPU 类型、虚拟 CPU 的数量以及磁盘的大小。为 HostedEngine-VM 指定一个 MAC 地址,或使用系统自动创建的地址。在虚拟机安装操作系统前,可以使用这个 MAC 地址更新 DHCP 服务器。为 HostedEngine-VM 指定内存的大小,以及控制器连接类型。
    Please specify the device to boot the VM from (cdrom, disk, pxe) [cdrom]: 
    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]:
  5. 配置引擎

    指定在 Red Hat Enterprise Virtualization 环境中标识 Host-HE1 的名称,以及访问管理门户所使用的 admin@internal 用户的密码。提供 HostedEngine-VM 的 FQDN(在这里我们使用 Manager.example.com 作为 FQDN)。最后,提供 SMTP 的名称和 TCP 端口号、发送事件通知的电子邮件地址、以及需要接收事件通知的用户的电子邮件地址列表(以逗号分隔)。

    重要

    引擎的 FQDN 必须和 BareMetal-Manager 在初始设置时提供的 FQDN 相同。
    Enter the name which will be used to identify this host inside the Administrator Portal [hosted_engine_1]: Host-HE1
    Enter 'admin@internal' user password that will be used for accessing the Administrator Portal: 
    Confirm 'admin@internal' user password: 
    Please provide the FQDN for the engine you want to use. This needs to match the FQDN that you will use for the engine installation within the VM: 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]:
  6. 配置预览

    在实际进行配置前,hosted-engine 脚本会显示已输入的信息,并提示您确认这些信息。
    Bridge interface                   : eth1
    Engine FQDN                        : manager.example.com
    Bridge name                        : rhevm
    SSH daemon port                    : 22
    Firewall manager                   : iptables
    Gateway address                    : X.X.X.X
    Host name for web application      : Host-HE1
    Host ID                            : 1
    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)[No]:
  7. 配置 HostedEngine-VM

    这个脚本会创建虚拟机 HostedEngine-VM,并提供和它进行连接的详情信息。您需要在 HostedEngine-VM 上安装一个操作系统后才能继续在 Host-HE1 上执行 hosted-engine 脚本。
    [ INFO  ] Stage: Transaction setup
    ...
    [ INFO  ] Creating VM
    You can now connect to the VM with the following command:
    	/usr/bin/remote-viewer vnc://localhost:5900
    Use temporary password "5379skAb" 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 协议连接到虚拟机。使用自承载引擎主机的 FQDN 或 IP 地址替换其中的 FQDN。
    /usr/bin/remote-viewer vnc://FQDN:5900
  8. 安装虚拟机操作系统

    连接到 hosted-engine 脚本所创建的虚拟机(HostedEngine-VM),安装 Red Hat Enterprise Linux 6.7 操作系统。
  9. 同步主机和虚拟机

    返回到 Host-HE1,选择选项 1 来继续 hosted-engine 脚本:
    (1) Continue setup - VM installation is complete
  10. 安装 Manager

    连接到 HostedEngine-VM,订阅相关的 Red Hat Enterprise Virtualization Manager 仓库(repository)。详情请参阅安装指南中的 订阅所需的权利
    确认所有安装的软件包都是最新版本,并安装了 rhevm 软件包。
    # yum update
    # yum install rhevm
  11. 禁用 BareMetal-Manager

    连接到 BareMetal-Manager,停止引擎并禁止它在系统引导时运行。
    # service ovirt-engine stop
    # chkconfig ovirt-engine off

    注意

    推荐停止运行 BareMetal-Manager,这可以确保在系统备份被创建后,不会再对虚拟环境进行改变。另外,它还可以防止 BareMetal-Manager 和 HostedEngine-VM 同时管理存在的资源。
  12. 更新 DNS

    更新您的 DNS,从而使 Red Hat Enterprise Virtualization 环境的 FQDN 可以正确地解析 HostedEngine-VM 的 IP 地址,以及在 Host-HE1 上配置 hosted-engine 部署脚本所提供的 FQDN。在这里,FQDN 被设置为 manager.example.com,因为所提供引擎的 FQDN 和新设置引擎的 FQDN 必须相同。
  13. 为 BareMetal-Manager 创建一个备份

    连接到 BareMetal-Manager,运行 engine-backup 命令。使用 --mode=backup--file=FILE--log=LogFILE 参数来分别指定备份的模式、备份文件的名称以及日志文件的名称。
    # engine-backup --mode=backup --file=FILE --log=LogFILE
  14. 把备份文件复制到 HostedEngine-VM

    登录到 BareMetal-Manager,把备份文件复制到 HostedEngine-VM 上。在以下的例子中,[manager.example.com] 是 HostedEngine-VM 的 FQDN,/backup/ 是备份文件要被复制到的目录或路径。如果这些目录和路径还没有存在,您需要登录到 HostedEngine-VM 上后创建它们。
    # scp -p FILE LogFILE manager.example.com:/backup/
  15. 在 HostedEngine-VM 上恢复备份文件

    参阅 第 6.3 节 “恢复自承载引擎 Manager”。因为已在前面的步骤中进行了,所以请跳过恢复过程中的 Copying the Backup Files to the New Manager 一步。在运行 engine-setup 后返回这个过程。
  16. 把主机和 Manager 进行同步

    返回到 Host-HE1,选择选项 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...
    [ INFO  ] The VDSM Host is now operational
              Please shutdown the VM allowing the system to launch it as a monitored service.
              The system will wait until the VM is down.
  17. 关闭 HostedEngine-VM

    关闭 HostedEngine-VM。
    # shutdown -h now
  18. 设置确认

    返回到 Host-HE1,确认它检测到 HostedEngine-VM 已经被关闭。
    [ INFO  ] Enabling and starting HA services
              Hosted Engine successfully set up
    [ INFO  ] Stage: Clean up
    [ INFO  ] Stage: Pre-termination
    [ INFO  ] Stage: Termination
现在,Red Hat Enterprise Virtualization 引擎已被迁移到一个自承载引擎环境中。Manager 现在运行于 Host-HE1 主机中的一个虚拟机(HostedEngine-VM)上。HostedEngine-VM 被设置为高可用的,它会在需要时被迁移到其它主机上。