1. 星速云首页
  2. 阿里云文档

阿里云Red Hat云接入和Windows许可证2. 创建RHEL镜像

此部分介绍如何将脱机IDC中的物理主机或经典虚拟化平台中的虚拟机迁移到阿里云。

选项1. 将物理服务器迁移到阿里云ECS(P2V和V2V)

如果您使用云迁移工具将物理服务器的操作系统镜像迁移到阿里云ECS,请参阅使用迁云工具迁移到ECS。在将镜像导入ECS后,通过已导入的镜像创建RHEL实例。

选项2. 将虚拟机迁移到阿里云ECS(V2V)

此部分介绍如何在本地物理服务器上创建阿里云支持的虚拟机镜像。您可以独自完成此任务,也可以使用迁云工具

注意:如果RHEL7服务器上已运行满足步骤1中提到的要求的虚拟机,则可以从步骤3开始,并忽略步骤2。

1. 准备一台物理RHEL 7服务器

登录到物理RHEL7服务器,然后确认下表中列出的所有包都已安装在您的RHEL服务器上。您可以运行

yum info [package]

查看是否已安装特定包。

存储库 描述
libvirt rhel-7-server-rpms 用于管理平台虚拟化的开源API、守护进程和管理工具。
virt-manager rhel-7-server-rpms 桌面虚拟机管理器。
libguestfs rhel-7-server-rpms 一组用于访问和修改虚拟机(VM)磁盘镜像的工具。
libguestfs-tools rhel-7-server-rpms 用于虚拟机的系统管理工具,包括Guestfish。
qemu-img rhel-7-server-rpms 用于将虚拟机磁盘镜像文件从一种格式转换为另一种格式的工具。

2. 创建虚拟机

如果RHEL 7服务器上已运行满足步骤1中提到的要求的虚拟机,则可以从步骤3开始,并忽略步骤2。

  1. Red Hat下载页面下载最新的Red Hat Enterprise Linux 7.5 更新 KVM Guest镜像或Red Hat Enterprise Linux 7.4 更新 KVM Guest镜像。

    注意:虽然阿里云支持RHEL 7.4,但建议您下载功能更全面的RHEL 7.5。

  2. 将镜像保存到在准备一台物理RHEL 7服务器部分所准备的RHEL服务器中。

  3. 将镜像移动到/var/lib/libvirt/images目录中。

  4. 在Virtual Machine Manager窗口上,单击iCON图标创建新的虚拟机。

    VMM

  5. 按照Create a new virtual machine向导完成配置:

    1. 选择Import existing disk image安装Guest操作系统,然后单击Forward。

      NewVM

    2. 浏览/var/lib/libvirt/images目录并选择qcow2 KVM Guest镜像。

      GuestImage

    3. 为新虚拟机设置内存和CPU内核。

      NewVMMemory

    4. 查看新虚拟机的配置,指定名称,然后选择Customize configuration before install。

      CustomizeBeforeInstall

    5. 在自定义配置对话框的左侧窗格中,单击NIC,然后选择virtio作为Device model。

    6. 单击Begin Installation。

      将开始创建新虚拟机。在此过程中,虚拟机控制台将显示并引导到登录提示。

    7. 当登录提示出现时,关闭虚拟机。

  6. 运行

    virt-customize

    为虚拟机的根用户设置密码。例如:

    1. <span class="pln"> </span><span class="com"># virt-customize -a /var/lib/libvirt/images/rhel-server-7.5-x86_64-kvm.qcow2 --root-password password:redhat!</span>
    2. <span class="pln"> </span><span class="pun">[</span><span class="pln">   </span><span class="lit">0.0</span><span class="pun">]</span><span class="pln"> </span><span class="typ">Examining</span><span class="pln"> the guest </span><span class="pun">...</span>
    3. <span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="lit">103.0</span><span class="pun">]</span><span class="pln"> </span><span class="typ">Setting</span><span class="pln"> a random seed</span>
    4. <span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="lit">103.0</span><span class="pun">]</span><span class="pln"> </span><span class="typ">Setting</span><span class="pln"> passwords</span>
    5. <span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="lit">112.0</span><span class="pun">]</span><span class="pln"> </span><span class="typ">Finishing</span><span class="pln"> off</span>
  7. 启动RHEL虚拟机并以根用户身份登录。

在您登录到虚拟机后,前往配置Guest操作系统。

2.2.3. 配置Guest操作系统

确保RHEL虚拟机的Guest操作系统满足限制部分中列出的所有要求。

验证Guest操作系统的配置

项目 要求
/etc/shadow 通过运行

chattr

命令使/etc/shadow处于未锁定状态。

qemu-ga 已卸载qemu-ga。
网络 已禁用或已卸载网络管理器,并且已启用网络服务。
ssh 已启用SSH服务,并且未设置PermitRootLogin。
防火墙 已禁用防火墙。
文件系统 使用xfs、ext3或ext4。不要使用具有64位功能的ext4。
passwd 已安装passwd。
分区 使用MBR分区。
逻辑卷管理器(LVM) 未使用逻辑卷管理器(LVM)。
/lib 只能对/lib和/lib64使用相对路径。
cloud-init Guest操作系统必须安装了 cloud-init。

说明:cloud-init缺省配置会禁止密码方式登录,如需启用密码登录,请参见文档安装cloud-init,根据其中“安装cloud-init”段落中的第5步,修改

/etc/cloud/cloud.cfg

配置文件中cloud_init_modules段落。

配置ntp.conf文件

按照以下步骤配置ntp.conf文件,它在/etc/ntp.conf目录中。

  1. 运行以下命令将ntp.conf文件备份为ntp.conf.bk。

    1. <span class="pln"> cp </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">ntp</span><span class="pun">.</span><span class="pln">conf </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">ntp</span><span class="pun">.</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">bk</span>
  2. 编辑/etc/ntp.conf文件并将其内容替换为以下内容。

    1. <span class="pln"> driftfile  </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">lib</span><span class="pun">/</span><span class="pln">ntp</span><span class="pun">/</span><span class="pln">drift</span>
    2. <span class="pln"> pidfile    </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">run</span><span class="pun">/</span><span class="pln">ntpd</span><span class="pun">.</span><span class="pln">pid</span>
    3. <span class="pln"> logfile    </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">ntp</span><span class="pun">.</span><span class="pln">log</span>
    4.  
    5. <span class="pln"> </span><span class="com"># Access Control Support</span>
    6. <span class="pln"> restrict    </span><span class="kwd">default</span><span class="pln"> kod nomodify notrap nopeer noquery</span>
    7. <span class="pln"> restrict </span><span class="pun">-</span><span class="lit">6</span><span class="pln"> </span><span class="kwd">default</span><span class="pln"> kod nomodify notrap nopeer noquery</span>
    8. <span class="pln"> restrict </span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span>
    9. <span class="pln"> restrict </span><span class="lit">192.168</span><span class="pun">.</span><span class="lit">0.0</span><span class="pln"> mask </span><span class="lit">255.255</span><span class="pun">.</span><span class="lit">0.0</span><span class="pln"> nomodify notrap nopeer noquery</span>
    10. <span class="pln"> restrict </span><span class="lit">172.16</span><span class="pun">.</span><span class="lit">0.0</span><span class="pln"> mask </span><span class="lit">255.240</span><span class="pun">.</span><span class="lit">0.0</span><span class="pln"> nomodify notrap nopeer noquery</span>
    11. <span class="pln"> restrict </span><span class="lit">100.64</span><span class="pun">.</span><span class="lit">0.0</span><span class="pln"> mask </span><span class="lit">255.192</span><span class="pun">.</span><span class="lit">0.0</span><span class="pln"> nomodify notrap nopeer noquery</span>
    12. <span class="pln"> restrict </span><span class="lit">10.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pln"> mask </span><span class="lit">255.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pln"> nomodify notrap nopeer noquery</span>
    13.  
    14. <span class="pln"> </span><span class="com"># local clock</span>
    15. <span class="pln"> server </span><span class="lit">127.127</span><span class="pun">.</span><span class="lit">1.0</span>
    16. <span class="pln"> fudge  </span><span class="lit">127.127</span><span class="pun">.</span><span class="lit">1.0</span><span class="pln"> stratum </span><span class="lit">10</span>
    17.  
    18. <span class="pln"> restrict ntp1</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    19. <span class="pln"> restrict ntp1</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    20. <span class="pln"> restrict ntp10</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    21. <span class="pln"> restrict ntp11</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    22. <span class="pln"> restrict ntp12</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    23. <span class="pln"> restrict ntp2</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    24. <span class="pln"> restrict ntp2</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    25. <span class="pln"> restrict ntp3</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    26. <span class="pln"> restrict ntp3</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    27. <span class="pln"> restrict ntp4</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    28. <span class="pln"> restrict ntp4</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    29. <span class="pln"> restrict ntp5</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    30. <span class="pln"> restrict ntp5</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    31. <span class="pln"> restrict ntp6</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    32. <span class="pln"> restrict ntp6</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    33. <span class="pln"> restrict ntp7</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    34. <span class="pln"> restrict ntp8</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    35. <span class="pln"> restrict ntp9</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com nomodify notrap nopeer noquery</span>
    36.  
    37. <span class="pln"> server ntp1</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    38. <span class="pln"> server ntp1</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    39. <span class="pln"> server ntp10</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    40. <span class="pln"> server ntp11</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    41. <span class="pln"> server ntp12</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    42. <span class="pln"> server ntp2</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    43. <span class="pln"> server ntp2</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    44. <span class="pln"> server ntp3</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    45. <span class="pln"> server ntp3</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    46. <span class="pln"> server ntp4</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    47. <span class="pln"> server ntp4</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    48. <span class="pln"> server ntp5</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    49. <span class="pln"> server ntp5</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    50. <span class="pln"> server ntp6</span><span class="pun">.</span><span class="pln">aliyun</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    51. <span class="pln"> server ntp6</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    52. <span class="pln"> server ntp7</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    53. <span class="pln"> server ntp8</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>
    54. <span class="pln"> server ntp9</span><span class="pun">.</span><span class="pln">cloud</span><span class="pun">.</span><span class="pln">aliyuncs</span><span class="pun">.</span><span class="pln">com iburst minpoll </span><span class="lit">4</span><span class="pln"> maxpoll </span><span class="lit">10</span>

在确认Guest操作系统的配置后,便可以创建虚拟机镜像了。或者,您也可以使用阿里云提供的云迁移工具创建和导入虚拟镜像。有关更多信息,请参阅主题使用迁云工具迁移到ECS

4. 创建虚拟镜像

按照以下步骤创建虚拟机镜像:

  1. 在RHEL虚拟机菜单上,选择View > Snapshots。

  2. 单击+图标并创建快照。

    在拍摄快照后,将创建虚拟机镜像。虚拟机镜像采用QCOW2格式。

下一步

将镜像转换为受支持的格式

注明:本文为星速云原创版权所有,禁止转载,一经发现将追究版权责任!

发表评论

登录后才能评论