搜索

19.8. 在本地磁盘上使用 rootVolume 和 etcd 部署 OpenStack

download PDF
重要

在本地磁盘上使用 rootVolume 和 etcd 在 Red Hat OpenStack Platform (RHOSP)上部署只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。

有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围

作为第 2 天操作,您可以通过将 etcd 从根卷(由 OpenStack Cinder 提供)移到专用的临时本地磁盘,解决并防止 Red Hat OpenStack Platform (RHOSP)安装的性能问题。

19.8.1. 在本地磁盘上部署 RHOSP

如果您有一个现有的 RHOSP 云,您可以将 etcd 从该云移到专用临时本地磁盘。

警告

此流程仅用于在本地磁盘中测试 etcd,不应在生产环境中使用。在某些情况下,可能会发生 control plane 的完整丢失。如需更多信息,请参阅"备份和恢复"下的"备份和恢复操作"。

先决条件

  • 您有一个带有正常工作的 Cinder 的 OpenStack 云。
  • 您的 OpenStack 云至少有 75 GB 可用存储,以适应 OpenShift control plane 的 3 个根卷。
  • OpenStack 云使用 Nova 临时存储进行部署,该存储使用本地存储后端而不是 rbd

流程

  1. 运行以下命令,为 control plane 创建至少有 10 GB 临时磁盘的 Nova 类别,并基于您的环境替换 --ram--disk 和 <flavor_name> 的值:

    $ openstack flavor create --<ram 16384> --<disk 0> --ephemeral 10 --vcpus 4 <flavor_name>
  2. 使用 control plane 的 root 卷部署集群,例如:

    YAML 文件示例

    # ...
    controlPlane:
      name: master
      platform:
        openstack:
          type: ${CONTROL_PLANE_FLAVOR}
          rootVolume:
            size: 25
            types:
            - ${CINDER_TYPE}
      replicas: 3
    # ...

  3. 运行以下命令部署您创建的集群:

    $ openshift-install create cluster --dir <installation_directory> 1
    1
    对于 <installation_directory>,请指定之前创建的自定义 ./install-config.yaml 文件的位置。
  4. 运行以下命令,在继续下一步前验证您部署的集群是否健康:

    $ oc wait clusteroperators --all --for=condition=Progressing=false 1
    1
    确保集群操作器完成进行,且集群没有部署或更新。
  5. 运行以下命令,编辑 ControlPlaneMachineSet (CPMS) 来添加 etcd 使用的额外块设备:

    $ oc patch ControlPlaneMachineSet/cluster -n openshift-machine-api --type json -p ' 1
    [
        {
          "op": "add",
          "path": "/spec/template/machines_v1beta1_machine_openshift_io/spec/providerSpec/value/additionalBlockDevices", 2
          "value": [
            {
              "name": "etcd",
              "sizeGiB": 10,
              "storage": {
                "type": "Local" 3
              }
            }
          ]
        }
      ]
    '
    1
    将 JSON 补丁应用到 ControlPlaneMachineSet 自定义资源 (CR)。
    2
    指定添加 additionalBlockDevices 的路径。
    3
    在集群中添加至少 10 GB 的 etcd 设备。只要 etcd 设备适合 Nova 类别,就可以指定大于 10 GB 的值。例如,如果 Nova 类别有 15 GB,您可以创建具有 12 GB 的 etcd 设备。
  6. 使用以下步骤验证 control plane 机器是否健康:

    1. 运行以下命令,等待 control plane 机器集更新完成:

      $ oc wait --timeout=90m --for=condition=Progressing=false controlplanemachineset.machine.openshift.io -n openshift-machine-api cluster
    2. 运行以下命令验证 3 个 control plane 机器集是否已更新:

      $ oc wait --timeout=90m --for=jsonpath='{.status.updatedReplicas}'=3 controlplanemachineset.machine.openshift.io -n openshift-machine-api cluster
    3. 运行以下命令,验证 3 个 control plane 机器集是否健康:

      $ oc wait --timeout=90m --for=jsonpath='{.status.replicas}'=3 controlplanemachineset.machine.openshift.io -n openshift-machine-api cluster
    4. 运行以下命令,验证 ClusterOperators 是否没有在集群中进行:

      $ oc wait clusteroperators --timeout=30m --all --for=condition=Progressing=false
    5. 运行以下脚本,验证 3 个 control plane 机器是否都有之前创建的额外块设备:
    $ cp_machines=$(oc get machines -n openshift-machine-api --selector='machine.openshift.io/cluster-api-machine-role=master' --no-headers -o custom-columns=NAME:.metadata.name) 1
    
    
    if [[ $(echo "${cp_machines}" | wc -l) -ne 3 ]]; then
      exit 1
    fi 2
    
    
    for machine in ${cp_machines}; do
      if ! oc get machine -n openshift-machine-api "${machine}" -o jsonpath='{.spec.providerSpec.value.additionalBlockDevices}' | grep -q 'etcd'; then
    	exit 1
      fi 3
    done
    1
    检索集群中运行的 control plane 机器。
    2
    迭代带有名称 etcdadditionalBlockDevices 条目的机器。
    3
    输出每个 control plane 机器的名称,该机器具有一个名为 etcdadditionalBlockDevice
  7. 使用以下 YAML 文件,创建一个名为 98-var-lib-etcd.yaml 的文件:

    警告

    此流程用于在本地磁盘上测试 etcd,不应在生产环境中使用。在某些情况下,可能会发生 control plane 的完整丢失。如需更多信息,请参阅"备份和恢复"下的"备份和恢复操作"。

    apiVersion: machineconfiguration.openshift.io/v1
    kind: MachineConfig
    metadata:
      labels:
        machineconfiguration.openshift.io/role: master
      name: 98-var-lib-etcd
    spec:
      config:
        ignition:
          version: 3.4.0
        systemd:
          units:
          - contents: |
              [Unit]
              Description=Mount local-etcd to /var/lib/etcd
    
              [Mount]
              What=/dev/disk/by-label/local-etcd 1
              Where=/var/lib/etcd
              Type=xfs
              Options=defaults,prjquota
    
              [Install]
              WantedBy=local-fs.target
            enabled: true
            name: var-lib-etcd.mount
          - contents: |
              [Unit]
              Description=Create local-etcd filesystem
              DefaultDependencies=no
              After=local-fs-pre.target
              ConditionPathIsSymbolicLink=!/dev/disk/by-label/local-etcd 2
    
              [Service]
              Type=oneshot
              RemainAfterExit=yes
              ExecStart=/bin/bash -c "[ -L /dev/disk/by-label/ephemeral0 ] || ( >&2 echo Ephemeral disk does not exist; /usr/bin/false )"
              ExecStart=/usr/sbin/mkfs.xfs -f -L local-etcd /dev/disk/by-label/ephemeral0 3
    
              [Install]
              RequiredBy=dev-disk-by\x2dlabel-local\x2detcd.device
            enabled: true
            name: create-local-etcd.service
          - contents: |
              [Unit]
              Description=Migrate existing data to local etcd
              After=var-lib-etcd.mount
              Before=crio.service 4
    
              Requisite=var-lib-etcd.mount
              ConditionPathExists=!/var/lib/etcd/member
              ConditionPathIsDirectory=/sysroot/ostree/deploy/rhcos/var/lib/etcd/member 5
    
              [Service]
              Type=oneshot
              RemainAfterExit=yes
    
              ExecStart=/bin/bash -c "if [ -d /var/lib/etcd/member.migrate ]; then rm -rf /var/lib/etcd/member.migrate; fi" 6
    
              ExecStart=/usr/bin/cp -aZ /sysroot/ostree/deploy/rhcos/var/lib/etcd/member/ /var/lib/etcd/member.migrate
              ExecStart=/usr/bin/mv /var/lib/etcd/member.migrate /var/lib/etcd/member 7
    
              [Install]
              RequiredBy=var-lib-etcd.mount
            enabled: true
            name: migrate-to-local-etcd.service
          - contents: |
              [Unit]
              Description=Relabel /var/lib/etcd
    
              After=migrate-to-local-etcd.service
              Before=crio.service
    
              [Service]
              Type=oneshot
              RemainAfterExit=yes
    
              ExecCondition=/bin/bash -c "[ -n \"$(restorecon -nv /var/lib/etcd)\" ]" 8
    
              ExecStart=/usr/sbin/restorecon -R /var/lib/etcd
    
              [Install]
              RequiredBy=var-lib-etcd.mount
            enabled: true
            name: relabel-var-lib-etcd.service
    1
    etcd 数据库必须由设备挂载,而不是标签,以确保 systemd 生成此配置中使用的设备依赖项来触发文件系统创建。
    2
    如果文件系统 dev/disk/by-label/local-etcd 已存在,则不要运行。
    3
    如果 /dev/disk/by-label/ephemeral0 不存在,则会失败并显示警报消息。
    4
    将现有数据迁移到本地 etcd 数据库。这个配置会在挂载 /var/lib/etcd 后进行,但在 CRI-O 启动前,etcd 还没有运行。
    5
    要求挂载 etcd,且不包含成员目录,但 ostree 会被挂载。
    6
    清理任何以前的迁移状态。
    7
    复制和移动单独的步骤,以确保创建完整的成员目录。
    8
    在执行完整的递归重新标记前,对挂载点目录执行快速检查。如果文件路径 /var/lib/etcd 中的 restorecon 无法重命名目录,则不会执行递归重命名。
  8. 运行以下命令来创建新的 MachineConfig 对象:

    $ oc create -f 98-var-lib-etcd.yaml
    注意

    将 etcd 数据库移到每个 control plane 机器的本地磁盘需要时间。

  9. 运行以下命令,验证 etcd 数据库是否已传输到每个 control plane 的本地磁盘:

    1. 运行以下命令验证集群是否仍然在更新:

      $ oc wait --timeout=45m --for=condition=Updating=false machineconfigpool/master
    2. 运行以下命令验证集群是否已就绪:

      $ oc wait node --selector='node-role.kubernetes.io/master' --for condition=Ready --timeout=30s
    3. 运行以下命令,验证集群 Operator 是否在集群中运行:

      $ oc wait clusteroperators --timeout=30m --all --for=condition=Progressing=false

19.8.2. 其他资源

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.