关于java:你还在用-VMware快试试这款更轻量级的虚拟机

28次阅读

共计 2428 个字符,预计需要花费 7 分钟才能阅读完成。

说起虚拟机工具大家最相熟的天然是 VMware,性能很多很弱小,最让我认可的中央就是能够十分不便的批改虚拟机的配置,让虚拟机达到本人想要的性能~~

可是 VMware 好用是真的好用,但就是要付费呀!还不便宜,每次续费的时候我多多少少都有点疼爱~~

Multipass

最近有读者给我举荐了一款虚拟机工具:Multipass,十分轻量级的虚拟机命令管理工具。运行环境反对 Linux、Windows 和 macOS。

开始应用

首先咱们须要在官网下载并且装置 Multipass,抉择本人对应的操作系统,我抉择的是 Windows。

装置之后,查看本人装置的版本

$ multipass version

创立 Ubuntu 虚拟机

首先查看能够下载应用的 Ubuntu 镜像,

$ multipass find

运行胜利后,能够看到上面的这些镜像列表,蕴含各种版本的。

Image                       Aliases           Version          Description
snapcraft:core18                              20201111         Snapcraft builder for Core 18
snapcraft:core20                              20201111         Snapcraft builder for Core 20
core                        core16            20200818         Ubuntu Core 16
core18                                        20200812         Ubuntu Core 18
16.04                       xenial            20210128         Ubuntu 16.04 LTS
18.04                       bionic            20210129         Ubuntu 18.04 LTS
20.04                       focal,lts         20210223         Ubuntu 20.04 LTS
20.10                       groovy            20210209         Ubuntu 20.10
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

新建一个容器,

$ multipass launch --name dg
Launched: dg

而后下载最新版的 Ubuntu 镜像,之后咱们就能够间接应用了。

$ multipass exec dg -- lsb_release -d
Description:    Ubuntu 18.04.4 LTS

操作虚拟机

查看虚拟机列表

虚拟机创立实现后,查看虚拟机列表。

Name                 State             IPv4             Image
dg                   Running           192.168.24.5     Ubuntu 18.04 LTS

当初有一台 Ubuntu 18.04 版本的虚拟机在运行,对应的 IP 地址是:192.168.24.5。

查看虚拟机信息

通过命令你能够查看以后运行的虚拟机具体信息。

$ multipass info --all

Name:           dg
State:          Running
IPv4:           192.168.24.5
Release:        Ubuntu 18.04.4 LTS
Image hash:     fe3030933742 (Ubuntu 18.04 LTS)
Load:           0.00 0.00 0.00
Disk usage:     1.5G out of 4.7G
Memory usage:   112.1M out of 985.7M

进入虚拟机

应用上面的命令查看虚拟机的系统配置信息、内存、磁盘等的应用状况。

$ multipass shell dg

如果你不想进入零碎外部,也能够通过上述提到的 multipass exce 命令,来操作 Ubuntu 零碎。

暂停 / 重启虚拟机

# 暂停
$ multipass stop dg
# 启动
$ multipass start dg

删除 / 开释虚拟机

应用 delete 命令 删除虚拟机之后,该虚拟机实际上还是存在了,想要彻底删除则须要开释虚拟机。

# 删除
$ multipass delete dg
# 开释
$ multipass purge dg

配置自动化

既要放弃开发环境和线上环境统一,又要节俭部署工夫。咱们能够应用 –cloud-init 对容器进行初始化配置:

$ multipass launch --name ubuntu --cloud-init config.yaml

config.yaml 是初始化配置文件,内容如下:

#cloud-config

runcmd:
 - curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
 - sudo apt-get install -y nodejs
 - wget https://releases.leanapp.cn/leancloud/lean-cli/releases/download/v0.21.0/lean-cli-x64.deb
 - sudo dpkg -i lean-cli-x64.deb

runcmd 能够指定容器首次启动时运行的命令

总结

通过一段时间的应用,我认为这款工具的确是不错的!比如说我要搞点 linux 的小试验,通过 Multipass 几分钟就能搭起零碎来测试。要测试小型数据库集群,也能够通过 Multipass 在本地疾速搭建虚拟机集群,很不错!

惟一美中不足的是 Multipass 只能应用 Ubuntu 镜像,因为这款工具是由 Ubuntu 背地的 Canonical 公司开发开源的。

相干链接

官网:https://multipass.run/

文档:https://multipass.run/docs/

近期热文举荐:

1.1,000+ 道 Java 面试题及答案整顿 (2021 最新版)

2. 劲爆!Java 协程要来了。。。

3. 玩大了!Log4j 2.x 再爆雷。。。

4.Spring Boot 2.6 正式公布,一大波新个性。。

5.《Java 开发手册(嵩山版)》最新公布,速速下载!

感觉不错,别忘了顺手点赞 + 转发哦!

正文完
 0