4.2. 迁移到 RHEL 的镜像模式时,使用 UID 和 GID 偏移
如果您没有重新安装运行 MicroShift 的操作系统,则必须在迁移过程中为可能的 UID 和 GID 偏移使用临时解决方案。解决这个问题的一种方法是添加在启动受影响的系统服务前应用必要的修复的 systemd 单元。
先决条件
- 您有一个现有的 RHEL for Edge 部署运行 MicroShift。
- 有到构建主机的 root 访问权限。
- 您有要部署的镜像。
流程
通过在 MicroShift image
-build 中输入以下命令来解决 Open vSwitch (OVS)的潜在 UID 或 GID 偏移:systemd服务# Install systemd configuration drop-ins to fix potential permission problems when upgrading from rpm-ostree commits to image mode container layers RUN mkdir -p /usr/lib/systemd/system/ovsdb-server.service.d && \ cat > /usr/lib/systemd/system/ovsdb-server.service.d/microshift-ovsdb-ownership.conf <<'EOF' # The openvswitch database files must be owned by the appropriate user and its primary group. That the user and its group can be overwritten, recreate them. [Service] ExecStartPre=/bin/sh -c '/bin/getent passwd openvswitch >/dev/null || useradd -r openvswitch' ExecStartPre=/bin/sh -c '/bin/getent group hugetlbfs >/dev/null || groupadd -r hugetlbfs' ExecStartPre=/sbin/usermod -a -G hugetlbfs openvswitch ExecStartPre=/bin/chown -Rhv openvswitch. /etc/openvswitch EOF
重要
在完成 RHEL 的 MicroShift 迁移到镜像模式后,不需要这个临时解决方案,并可删除。