KVM部署Alibaba Cloud Linux操作系统

下载镜像文件

下载链接:https://mirrors.aliyun.com/alinux/image/?spm=a2c4g.11186623.0.0.79ed5af6pehv54
下载文件:aliyun_3_x64_20G_nocloud_alibase_20230727.qcow2

部署KVM虚拟化环境

yum -y install qemu libvirt rr-testsuite
systemctl start libvirtd
systemctl enable libvirtd

准备镜像文件

将aliyun_3_x64_20G_nocloud_alibase_20230727.qcow2拷贝到镜像文件目录,一般默认/var/lib/libvirt/images/disks/

 本地生成seed.img引导镜像

1、在镜像文件同一级目录下,创建meta-data和user-data两个配置文件。

cd /var/lib/libvirt/images/disks/
mkdir seed
cd seed
vi meta-data

#cloud-config
#vim:syntax=yaml

local-hostname: alinux-host   

vi user-data

#cloud-config
#vim:syntax=yaml

# 添加一个名为alinux的账号,并且可以执行sudo命令。
users:
  - default
  - name: alinux
    sudo: ['ALL=(ALL)   ALL']
    plain_text_passwd: aliyun
    lock_passwd: false

# 添加Alibaba Cloud Linux 3的YUM源。
yum_repos:
    alinux3-module:
        name: alinux3-module
        baseurl: https://mirrors.aliyun.com/alinux/$releasever/module/$basearch/
        enabled: 1
        gpgcheck: 1
        gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3
    alinux3-updates:
        name: alinux3-updates
        baseurl: https://mirrors.aliyun.com/alinux/$releasever/updates/$basearch/
        enabled: 1
        gpgcheck: 1
        gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3
    alinux3-plus:
        name: alinux3-plus
        baseurl: https://mirrors.aliyun.com/alinux/$releasever/plus/$basearch/
        enabled: 1
        gpgcheck: 1
        gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3
    alinux3-powertools:
        name: alinux3-powertools
        baseurl: https://mirrors.aliyun.com/alinux/$releasever/powertools/$basearch/
        gpgcheck: 1
        enabled: 1
        gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3
    alinux3-os:
        name: alinux3-os
        baseurl: https://mirrors.aliyun.com/alinux/$releasever/os/$basearch/
        gpgcheck: 1
        enabled: 1
        gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3

2、配置epel-testing仓库

vi /etc/yum.repos.d/epel-testing.repo

[epel-testing]
name=Extra Packages for Enterprise Linux 8 - Testing - $basearch
baseurl=http://mirrors.cloud.aliyuncs.com/epel/testing/8/Everything/$basearch
enabled=0
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

3、安装cloud-utils并生成seed.img镜像

sudo yum install -y cloud-utils
sudo cloud-localds seed.img user-data meta-data

定义虚拟机

vi /etc/libvirt/qemu/AliyunOS3.xml


  AliyunOS3
  4194304
  4194304
  8
  
    hvm
    
  
  
    
    
  
  
    
  
  
  destroy
  restart
  destroy
  
    
    
  
  
    /usr/libexec/qemu-kvm
    
      
      
      
    
    
      
      
      
    
    
      
      
      
    
    
      
    
    
    
    
    
    
    
  

根据虚拟机配置文件,创建虚拟机

virsh define AliyunOS3.xml

virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     AliyunOS3                        shut off

启动虚拟机

virsh start AliyunOS3

virsh list
 Id    Name                           State
----------------------------------------------------
 2     AliyunOS3                      running

连接虚拟机的console口

注意:我们上面没有提前配置KVM虚拟机环境的网络桥接,可能你无法直接远程访问这台机器。可以通过rinetd做转发。

virsh console AliyunOS3

KVM部署Alibaba Cloud Linux操作系统_第1张图片

你可能感兴趣的:(操作系统,alibaba,linux,kvm)