前言
看到这个 Multipass 套件 我表示很惊讶 ,我自从买了 M1 后就用不了 Vagrant 来快速搭建集群环境,虽然不能和 Vagrant 一样可以部署多个系统,用过之后这体验就像是在用 docker 呢!虽然只有一个 ubuntu 足矣足矣!所有的操作都可以通过指令完成,你可能会想说「其他的 VM 也都可以啊!」,沒错,但是那些指令大多又臭又长 ,镜像管理也十分不方便,若要通过脚本部署,或者通过 Vagrant 来快速搭建虚拟机环境。
当然,这些在 Multipass 中全部构建,給你一個如 docker 般的体验。
在我的 MacBook Pro 2021 (Apple M1 Max) 上測試,启动一台最快不用 5 秒, 实在是爽弯弯的操作。
虚拟化方面
在 Linux 上面是通过 KVM 在 Windows 上面通过 Hyper-V Windows’s Docker 也是通过这个在 Mac 上面透過 HyperKit Mac 的 Docker 也是通过这个(不是 Docker Toolbox)
安裝
Linux
$ snap install multipass --classic
复制代码
Mac
$ brew cask install multipass
复制代码
执行方式
最快速的方式,全部使用初始值 ,默认会随机一个名称
或是设置其他的参数
$ multipass launch -c 4 -m 512M -d 2G -n name
复制代码
-c:cpu 数量-m:内存 可以用 K, M, G 等单位表示 最小值:128M,預設 1G-d:磁盘空间。可以用 K, M, G 等单位表示 最小值:512M,默认设置 5G-n:自定的名称
复制代码
列出虚拟机
$ multipass list
Name State IPv4 Imagemaster1 Running 192.168.64.3 Ubuntu 20.04 LTSworker1 Running 192.168.64.4 Ubuntu 20.04 LTSworker2 Running 192.168.64.5 Ubuntu 20.04 LTS
复制代码
查看状态
Name: worker2State: RunningIPv4: 192.168.64.5Release: Ubuntu 20.04.3 LTSImage hash: e9cae16ff305 (Ubuntu 20.04 LTS)Load: 0.00 0.00 0.00Disk usage: 1.2G out of 9.5GMemory usage: 157.4M out of 1.9GMounts: --
复制代码
进入操作系统
$ multipass shell worker2
复制代码
multipass shell worker2Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-94-generic aarch64)
* Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage
System information as of Mon Jan 24 16:44:46 CST 2022
System load: 0.0 Usage of /: 13.0% of 9.53GB Memory usage: 10% Swap usage: 0% Processes: 110 Users logged in: 0 IPv4 address for enp0s1: 192.168.64.5 IPv6 address for enp0s1: fd8d:aa4:bb8e:ec47:5054:ff:fec3:ecb4
0 updates can be applied immediately.
The list of available updates is more than a week old.To check for new updates run: sudo apt update
To run a command as administrator (user "root"), use "sudo <command>".See "man sudo_root" for details.
复制代码
終止
刪除
这个是时候,使用 multipass list 還看得到那個 instance,必须使用 multipass purge 才能真正的清除掉
列出所有可用镜像
其他指令
就不逐一列出了 用 multipass 可以查看
Usage: multipass [options] <command>Create, control and connect to Ubuntu instances.
This is a command line utility for multipass, aservice that manages Ubuntu instances.
Options: -h, --help Displays help on commandline options. --help-all Displays help including Qt specific options. -v, --verbose Increase logging verbosity. Repeat the 'v' in the short option for more detail. Maximum verbosity is obtained with 4 (or more) v's, i.e. -vvvv.
Available commands: alias Create an alias aliases List available aliases delete Delete instances exec Run a command on an instance find Display available images to create instances from get Get a configuration setting help Display help about a command info Display information about instances launch Create and start an Ubuntu instance list List all available instances mount Mount a local directory in the instance networks List available network interfaces purge Purge all deleted instances permanently recover Recover deleted instances restart Restart instances set Set a configuration setting shell Open a shell on a running instance start Start instances stop Stop running instances suspend Suspend running instances transfer Transfer files between the host and instances umount Unmount a directory from an instance unalias Remove an alias version Show version details
复制代码
特别地方
可以透过 cloud-init 来部署环境可以使用 libvirt 驱动,因此可以使用 virsh,像是管理 KVM 一样
cloud-init 以后在研究一下啊 先玩下 k8s 的集群
最后
官方的文档 https://multipass.run/docs
评论