5.3. 使用命令行部署自托管引擎

您可以从命令行部署自托管引擎。安装设置软件包后,您将运行 hosted-engine --deploy 命令,而脚本则收集环境的详细信息,并使用它们来配置主机和管理器。

您可以在部署期间通过手动、暂停部署或使用自动化来自定义 Manager 虚拟机。

  • 在安装 Manager 并将部署主机添加到管理器后,将变量 he_pause_host 设置为 true 会暂停部署。
  • 将变量 he_pause_before_engine_setup 设置为 true,在安装管理器之前暂停部署,并在使用 he_restore_from_file 时恢复管理器之前暂停部署。

    注意

    当将部署主机上的 he_pause_hosthe_pause_before_engine_setup 变量设置为 true 时,会在 /tmp 中创建带有后缀 _he_setup_lock 的锁定文件。然后,您可以根据需要手动自定义虚拟机。在您删除锁定文件或 24 小时之后(以先到者为准),部署将继续。

  • 将 Ansible playbook 添加到部署主机上的以下任一目录会自动运行该 playbook。将 playbook 添加到 /usr/share/ansible/collections/ansible_collections/redhat/rhv/roles/hosted_engine_setup/hooks/ 中的以下目录之一下:

    • enginevm_before_engine_setup
    • enginevm_after_engine_setup
    • after_add_host
    • after_setup

先决条件

  • 在执行 engine-setup 之前,将设备内容升级到最新的产品版本。

    • 要手动执行此操作,请暂停使用 he_pause_before_engine_setup 并执行 dnf 更新的部署
    • 要自动执行此操作,请应用 enginevm_before_engine_setup hook。
  • FQDN 为您的管理器和主机做好准备。正向和反向查找记录必须在 DNS 中设置。
  • 使用 FCP 或 iSCSI 块存储域时,单个目标 LUN 是自托管引擎唯一支持的设置。
  • 可选:如果您要在使用自动化部署期间自定义管理器虚拟机,则必须添加一个 Ansible playbook。请参阅 在部署过程中使用自动化自定义引擎虚拟机
  • 自托管引擎设置脚本要求使用引擎虚拟机到其裸机主机的 root 帐户的 2048 位 RSA 密钥进行 ssh 公钥访问。在 /etc/ssh/sshd_config 中,这些值必须设置为如下:

    • PubkeyAcceptedKeyTypes 必须允许 2048 位 RSA 密钥或更强大的密钥。

      默认情况下,此设置使用系统范围的加密策略。如需更多信息,请参阅 manual page crypto-policies(7)

      注意

      在 4.4.5.5 之前的版本中使用 Manager 注册的 RHVH 主机需要 RSA 2048 进行向后兼容,直到迁移了所有密钥。

      RHVH 主机注册了 4.4.5.5,之后使用 Manager 和 RHVH 支持的最强算法。PubkeyAcceptedKeyTypes 设置可帮助确定使用哪一种算法。

    • PermitRootLogin 设置为 without-passwordyes
    • PubkeyAuthentication 设置为 yes

流程

  1. 安装部署工具:

    # dnf install ovirt-hosted-engine-setup
  2. 使用 tmux 窗口管理器运行脚本,以避免在出现网络或终端中断时丢失会话。

    安装并运行 tmux

    # dnf -y install tmux
    # tmux
  3. 启动部署脚本:

    # hosted-engine --deploy

    或者,要在将部署主机添加到管理器后暂停部署,请使用命令行选项 --ansible-extra-vars=he_pause_host=true

    # hosted-engine --deploy --ansible-extra-vars=he_pause_host=true
    注意

    要随时退出脚本,使用 Ctrl+D组合键中止部署。在会话超时或连接中断时,运行 tmux attach 来恢复部署会话。

  4. 出现提示时,输入 Yes 以开始部署:

    Continuing will configure this host for serving as hypervisor and will create a local VM with a running engine.
    The locally running engine will be used to configure a new storage domain and create a VM there.
    At the end the disk of the local VM will be moved to the shared storage.
    Are you sure you want to continue? (Yes, No)[Yes]:
  5. 配置网络。检查显示的网关是否正确并按 Enter。在同一个子网中输入可 ping 地址,以便脚本可以检查主机的连通性。

    Please indicate a pingable gateway IP address [X.X.X.X]:
  6. 脚本会检测可能的 NIC,以用作环境的管理网桥。输入其中之一或按 Enter 以接受默认值。

    Please indicate a nic to set ovirtmgmt bridge on: (ens1, ens0) [ens1]:
  7. 指定如何检查网络连接。默认值为 dns

    Please specify which way the network connectivity should be checked (ping, dns, tcp, none) [dns]:
    ping
    尝试 ping 网关。
    dns
    检查与 DNS 服务器的连接。
    tcp
    创建到主机和端口组合的 TCP 连接。您需要指定目标 IP 地址和端口。连接成功创建后,网络就被视为处于活动状态。确保给定主机能够接受给定端口上传入的 TCP 连接。
    none
    网络始终被视为已连接。
  8. 输入数据中心的名称,在其中为自托管引擎部署主机。默认名称为 Default

    Please enter the name of the data center where you want to deploy this hosted-engine host.
    Data center [Default]:
  9. 输入集群的名称,在其中为自托管引擎部署主机。默认名称为 Default

    Please enter the name of the cluster where you want to deploy this hosted-engine host.
    Cluster [Default]:
  10. 如果要使用自定义设备进行虚拟机安装,请输入 OVA 存档的路径。否则,将此字段留空,以使用 RHV-M Appliance。
  11. 要使用自定义 RHV-M 设备设备镜像进行部署,请指定 OVA 存档的路径。否则,将此字段留空,以使用 RHV-M Appliance。

    If you want to deploy with a custom engine appliance image, please specify the path to the OVA archive you would like to use.
     Entering no value will use the image from the rhvm-appliance rpm, installing it if needed.
     Appliance image path []:
  12. 为 Manager 虚拟机输入 CPU 和内存配置:

    Please specify the number of virtual CPUs for the VM. The default is the appliance OVF value [4]:
    Please specify the memory size of the VM in MB. The default is the maximum available [6824]:
  13. 为 Manager 虚拟机指定 FQDN,如 manager.example.com

    Please provide the FQDN you would like to use for the engine.
    Note: This will be the FQDN of the engine VM you are now going to launch,
    it should not point to the base host or to any other existing machine.
    Engine VM FQDN []:
  14. 指定 Manager 虚拟机的域。例如,如果 FQDN 是 manager.example.com,则输入 example.com

    Please provide the domain name you would like to use for the engine appliance.
    Engine VM domain: [example.com]
  15. 为 Manager 创建 root 密码,并重新输入它以确认:

    Enter root password that will be used for the engine appliance:
    Confirm appliance root password:
  16. 可选:输入 SSH 公钥,可让您在不输入密码的情况下以 root 用户身份登录 Manager 虚拟机,并指定是否为 root 用户启用 SSH 访问:

    You may provide an SSH public key, that will be added by the deployment script to the authorized_keys file of the root user in the engine appliance.
    This should allow you passwordless login to the engine machine after deployment.
    If you provide no key, authorized_keys will not be touched.
    SSH public key []:
    
    Do you want to enable ssh access for the root user (yes, no, without-password) [yes]:
  17. 可选:您可以在 Manager 虚拟机上应用 DISA STIG 安全配置集。DISA STIG 配置文件是默认的 OpenSCAP 配置文件。

    Do you want to apply a default OpenSCAP security profile? (Yes, No) [No]:
  18. 输入 Manager 虚拟机的 MAC 地址,或接受随机生成的地址。如果要通过 DHCP 为 Manager 虚拟机提供 IP 地址,请确保此 MAC 地址具有有效的 DHCP 保留。部署脚本将不会为您配置 DHCP 服务器。

    You may specify a unicast MAC address for the VM or accept a randomly generated default [00:16:3e:3d:34:47]:
  19. 输入 Manager 虚拟机的网络详情:

    How should the engine VM network be configured (DHCP, Static)[DHCP]?

    如果您指定了 Static,请输入 Manager 虚拟机的 IP 地址:

    重要
    • 静态 IP 地址必须属于与主机相同的子网。例如,如果主机在 10.1.1.0/24 中,则管理器虚拟机的 IP 必须位于同一子网范围 (10.1.1.1-254/24) 中。
    • 对于 IPv6,Red Hat Virtualization 仅支持静态寻址。
    Please enter the IP address to be used for the engine VM [x.x.x.x]:
    Please provide a comma-separated list (max 3) of IP addresses of domain name servers for the engine VM
    Engine VM DNS (leave it empty to skip):
  20. 指定是否将 Manager 虚拟机和基础主机的条目添加到虚拟机的 /etc/hosts 文件中。您必须确保主机名可以被解析。

    Add lines for the appliance itself and for this host to /etc/hosts on the engine VM?
    Note: ensuring that this host could resolve the engine VM hostname is still up to you.
    Add lines to /etc/hosts? (Yes, No)[Yes]:
  21. 提供 SMTP 服务器的名称和 TCP 端口号、用于发送电子邮件通知的电子邮件地址,以及用于接收这些通知的电子邮件地址列表。或者,按 Enter 接受默认值:

    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]:
  22. admin@internal 用户创建一个密码,以访问管理门户并重新输入它以确认:

    Enter engine admin password:
    Confirm engine admin password:
  23. 指定部署主机的主机名:

    Please provide the hostname of this host on the management network [hostname.example.com]:

    该脚本将创建虚拟机。默认情况下,脚本会先下载并安装 RHV-M 设备,这将增加安装时间。

  24. 可选:如果您设置了变量 he_pause_host: true,部署会在将部署主机添加到 Manager 后暂停。现在,您可以从部署主机登录到 Manager 虚拟机,以自定义它。您可以使用 FQDN 或 Manager 的 IP 地址登录。例如,如果 Manager 的 FQDN 是 manager.example.com

    $ ssh root@manager.example.com
    提示

    在安装日志中,其 IP 地址位于 local_vm_ip 中。安装日志是 /var/log/ovirt-hosted-engine-setup/ovirt-hosted-engine-setup-ansible-bootstrap_local_vm* 的最新实例。

    1. 根据需要自定义 Manager 虚拟机。
    2. 完成后,使用带有管理器 FQDN 的浏览器登录管理门户,并确保主机的状态为 Up
    3. 通过配置 Manager 虚拟机,删除锁定文件和部署脚本自动继续。
  25. 选择要使用的存储类型:

    Please specify the storage you would like to use (glusterfs, iscsi, fc, nfs)[nfs]:
    • 对于 NFS,输入版本、存储的完整地址和路径,以及任何挂载选项:

      Please specify the nfs version you would like to use (auto, v3, v4, v4_1)[auto]:
      Please specify the full shared storage connection path to use (example: host:/path): storage.example.com:/hosted_engine/nfs
      If needed, specify additional mount options for the connection to the hosted-engine storage domain []:
    • 对于 iSCSI,请输入门户详情并从自动检测的列表中选择目标和 LUN。您只能在部署期间选择一个 iSCSI 目标,但支持多路径连接同一门户组的所有门户。

      注意

      要指定多个 iSCSI 目标,您必须先启用多路径,然后才能部署自托管引擎。详情请查看 Red Hat Enterprise Linux DM 多路径。另外,还有一个多路径帮助程序工具,它生成脚本来安装和配置使用不同选项的多路径。

      Please specify the iSCSI portal IP address:
      Please specify the iSCSI portal port [3260]:
      Please specify the iSCSI discover user:
      Please specify the iSCSI discover password:
      Please specify the iSCSI portal login user:
      Please specify the iSCSI portal login password:
      
      The following targets have been found:
      	[1]	iqn.2017-10.com.redhat.example:he
      		TPGT: 1, portals:
      			192.168.1.xxx:3260
      			192.168.2.xxx:3260
      			192.168.3.xxx:3260
      
      Please select a target (1) [1]: 1
      
      The following luns have been found on the requested target:
        [1] 360003ff44dc75adcb5046390a16b4beb   199GiB  MSFT   Virtual HD
            status: free, paths: 1 active
      
      Please select the destination LUN (1) [1]:
    • 对于 Gluster 存储,输入存储的完整地址和路径,以及任何挂载选项:

      重要

      仅支持副本 1 和副本 3 Gluster 存储。确保您按如下方式配置卷:

      gluster volume set VOLUME_NAME group virt
      gluster volume set VOLUME_NAME performance.strict-o-direct on
      gluster volume set VOLUME_NAME network.remote-dio off
      gluster volume set VOLUME_NAME storage.owner-uid 36
      gluster volume set VOLUME_NAME storage.owner-gid 36
      gluster volume set VOLUME_NAME network.ping-timeout 30
      Please specify the full shared storage connection path to use (example: host:/path): storage.example.com:/hosted_engine/gluster_volume
      If needed, specify additional mount options for the connection to the hosted-engine storage domain []:
    • 对于光纤通道,从自动检测的列表中选择 LUN。必须配置并连接主机总线适配器,而且 LUN 不得包含任何现有数据。要重复使用现有 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]:
  26. 输入 Manager 虚拟机的磁盘大小:

    Please specify the size of the VM disk in GB: [50]:

    当部署成功完成时,一个数据中心、集群、主机、存储域和管理器虚拟机已在运行。您可以登录到管理门户来添加任何其他资源。

  27. 可选:安装和配置 Red Hat Single Sign On,以便您可以向环境中添加其他用户。如需更多信息,请参阅 管理指南 中的 安装和配置红帽单点登录
  28. 可选: 部署 Grafana,以便您可以监控和显示来自 RHV 环境的报告。如需更多信息,请参阅管理指南中的配置 Grafana

Manager 虚拟机、运行它的主机以及自托管引擎存储域在管理门户中标有金色标牌。

注意

管理器的 I/O 调度程序和托管 Manager 的 I/O 请求重新排序 I/O 请求。这种双重重新排序可能会延迟 I/O 请求到存储层,从而影响性能。

根据您的数据中心,您可以通过将 I/O 调度程序更改为 none 来提高性能。如需更多信息,请参阅 RHEL 监控和管理系统状态中的可用磁盘调度程序

下一步是启用 Red Hat Virtualization Manager 存储库。