Centos7下利用Multipass创建Ubuntu18虚拟机(踩坑记录)

Centos7下利用Multipass创建Ubuntu18虚拟机(踩坑记录)

  • No package epel-release available
  • Error: Package: snapd-selinux-2.49-2.el7.noarch (epel)
  • 安装过程
    • snap安装
    • 安装 multipass

直接给出我参考的博文(都需要):
https://www.techrepublic.com/article/multipass-is-a-new-tool-for-launching-virtual-machines/(强推,讲的很清晰,照着做就行)
https://multipass.run/(讲的不简洁,有兴趣可以看看)

踩过的坑:

No package epel-release available

使用yum install epel-release命令安装EPEL报错的

root@node11:~$ sudo yum install epel-release
No package epel-release available.
Error: Nothing to do

网上主流方法: 修改一些配置文件,我就不赘述了,一搜一大堆
我的方法:

install the EPEL repository on CentOS-7 by this command:
$ rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

参考了https://www.shellhacks.com/epel-repo-centos-8-7-6-install/,centos6/8只需要将我命令对应版本号改了就行。

Error: Package: snapd-selinux-2.49-2.el7.noarch (epel)

这是安装snap出现的错误

root@node11:~$ sudo yum install snapd
Error: Package: snapd-selinux-2.49-2.el7.noarch (epel)
           Requires: selinux-policy-base >= 3.13.1-268.el7_9.2
           Installed: selinux-policy-targeted-3.13.1-229.el7.noarch (@anaconda)
               selinux-policy-base = 3.13.1-229.el7
           Available: selinux-policy-minimum-3.13.1-229.el7.noarch (local-centos7.6-x86_64--install-centos7.6-x86_64)
               selinux-policy-base = 3.13.1-229.el7
           Available: selinux-policy-mls-3.13.1-229.el7.noarch (local-centos7.6-x86_64--install-centos7.6-x86_64)
               selinux-policy-base = 3.13.1-229.el7
 You could try using --skip-broken to work around the problem
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
rdma-core-devel-51mlnx1-1.51066.x86_64 has missing requires of pkgconfig(libnl-3.0)
rdma-core-devel-51mlnx1-1.51066.x86_64 has missing requires of pkgconfig(libnl-route-3.0)

这两篇文章都给出了很好的解决方法:
https://blog.csdn.net/qq_39195042/article/details/109641161
https://unix.stackexchange.com/questions/617912/unable-to-install-snapd-on-centos-7-due-to-dependency-error
错误原因就是** selinux-policy-base >= 3.13.1-268.el7 **依赖的版本要大于3.13.1.268
需要重新安装 selinux-policyselinux-policy-targeted
移除 selinux-policy

$ yum remove selinux-policy

安装对应依赖

$ sudo yum install http://mirror.centos.org/centos/7/updates/x86_64/Packages/selinux-policy-3.13.1-268.el7_9.2.noarch.rpm
 
$ sudo yum install http://mirror.centos.org/centos/7/updates/x86_64/Packages/selinux-policy-targeted-3.13.1-268.el7_9.2.noarch.rpm

安装过程

snap安装

向centos7添加EPEL

$ sudo yum install epel-release

centos8请使用:

$ sudo dnf install epel-release
$ sudo dnf upgrade

将EPEL存储库添加到Centos安装中后,只需安装snapd软件包:

sudo yum install snapd

安装后,需要启用管理主snap通信套接字的systemd单元:

$ sudo systemctl enable --now snapd.socket

在/var/lib/snap/snap和/snap之间创建符号链接:

$ sudo ln -s /var/lib/snapd/snap /snap

安装 multipass

root@node11:~$ sudo snap install multipass
2021-03-19T16:13:18+08:00 INFO Waiting for automatic snapd restart...
multipass 1.6.2 from Canonical✓ installed

找到所有可用的Ubuntu镜像

root@node11:~$ multipass find
Image                       Aliases           Version          Description
snapcraft:core18                              20201111         Snapcraft builder for Core 18
snapcraft:core20                              20201111         Snapcraft builder for Core 20
snapcraft:core                                20210316         Snapcraft builder for Core 16
core                        core16            20200818         Ubuntu Core 16
core18                                        20200812         Ubuntu Core 18
16.04                       xenial            20210316         Ubuntu 16.04 LTS
18.04                       bionic            20210315.1       Ubuntu 18.04 LTS
20.04                       focal,lts         20210315         Ubuntu 20.04 LTS
20.10                       groovy            20210315         Ubuntu 20.10
daily:21.04                 devel,hirsute     20210317         Ubuntu 21.04
appliance:adguard-home                        20200812         Ubuntu AdGuard Home Appliance
appliance:mosquitto                           20200812         Ubuntu Mosquitto Appliance
appliance:nextcloud                           20200812         Ubuntu Nextcloud Appliance
appliance:openhab                             20200812         Ubuntu openHAB Home Appliance
appliance:plexmediaserver                     20200812         Ubuntu Plex Media Server Appliance

安装Ubuntu 18.04 LTS

root@node11:~$ multipass launch 18.04
Launched: active-squirrelfish

然后,我们可以检查它是否使用以下命令运行:

root@node11:~$ multipass list                                            
Name                    State             IPv4             Image
active-squirrelfish     Running           10.105.212.57    Ubuntu 18.04 LTS

连接

root@node11:~$ multipass shell active-squirrelfish
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-137-generic x86_64)

你可能感兴趣的:(linux,ubuntu,centos)