【手把手教程】MacOS 安裝Multipass輕量級虛擬機(jī)
?? 千尋簡筆記介紹
千尋簡筆記已開源,Gitee與GitHub搜索chihiro-notes
,包含筆記源文件.md
,以及PDF版本方便閱讀,且是用了精美主題,閱讀體驗(yàn)更佳,如果文章對你有幫助請幫我點(diǎn)一個(gè)Star
~
引言
由于在mac上使用docker,創(chuàng)建了兩個(gè)容器之后內(nèi)存占用就非常高,總結(jié)兩套解決方案。
方案一: 在docke 中調(diào)整內(nèi)存大小。
方案二:創(chuàng)建一個(gè)輕量的虛擬機(jī),在虛擬機(jī)上運(yùn)行docker,
創(chuàng)建一個(gè)輕量的虛擬機(jī)
下載網(wǎng)址:https://multipass.run/
1 安裝
- 繼續(xù) -> 繼續(xù) -> 同意 -> 繼續(xù) -> 安裝(輸入密碼)-> 關(guān)閉(完成安裝)
2 啟動
- 啟動Multipass -> 點(diǎn)擊頭頂?shù)某壬珗D標(biāo) Open Shell -> 等待獲取鏡像文件、安裝虛擬機(jī)實(shí)例
- 虛擬機(jī)安裝完成自動進(jìn)入虛擬機(jī)實(shí)例
3 本地終端命令
3.1 查看 multipass 當(dāng)前支持的虛擬機(jī)系統(tǒng)版本
multipass find
xingchen@star ~ % multipass find
Image Aliases Version Description
18.04 bionic 20230303 Ubuntu 18.04 LTS
20.04 focal 20230209 Ubuntu 20.04 LTS
22.04 jammy,lts 20230302 Ubuntu 22.04 LTS
22.10 kinetic 20230302 Ubuntu 22.10
anbox-cloud-appliance latest Anbox Cloud Appliance
charm-dev latest A development and testing environment for charmers
docker 0.4 A Docker environment with Portainer and related tools
jellyfin latest Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube latest minikube is local Kubernetes
ros-noetic 0.1 A development and testing environment for ROS Noetic.
ros2-humble 0.1 A development and testing environment for ROS 2 Humble.
xingchen@star ~ %
3.2 查看本機(jī)安裝的虛擬機(jī)實(shí)例
multipass list
xingchen@star ~ % multipass list
Name State IPv4 Image
primary Running 192.168.64.2 Ubuntu 22.04 LTS
xingchen@star ~ %
3.3 進(jìn)入虛擬機(jī)實(shí)例
multipass shell [虛擬機(jī)實(shí)例的名字]
# 查看虛擬機(jī)的Name
xingchen@star ~ % multipass list
Name State IPv4 Image
primary Running 192.168.64.2 Ubuntu 22.04 LTS
# primary 默認(rèn)的Name
xingchen@star ~ % multipass shell primary
Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-67-generic aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Thu Mar 9 19:20:44 CST 2023
System load: 0.0
Usage of /: 30.1% of 4.68GB
Memory usage: 19%
Swap usage: 0%
Processes: 93
Users logged in: 1
IPv4 address for enp0s1: 192.168.64.2
IPv6 address for enp0s1: fdb0:864c:55e9:a6ea:5054:ff:fec4:4f69
* Introducing Expanded Security Maintenance for Applications.
Receive updates to over 25,000 software packages with your
Ubuntu Pro subscription. Free for personal use.
https://ubuntu.com/pro
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Last login: Thu Mar 9 19:08:00 2023 from 192.168.64.1
ubuntu@primary:~$
3.4 關(guān)閉/開啟實(shí)例
-
關(guān)閉實(shí)例
multipass stop primary
-
開啟實(shí)例文章來源:http://www.zghlxwxcb.cn/news/detail-808978.html
multipass start primary
3.5 創(chuàng)建指定版本的虛擬機(jī)實(shí)例
multipass launch -n [實(shí)例名稱] -c [核數(shù)] -d [磁盤大小] -m [內(nèi)存大小] [image 版本]
-n 實(shí)例名稱
-c cpu核數(shù)
-m 內(nèi)存大小
-d 磁盤大小
## 查看更多安裝相關(guān)的參數(shù)
multipass launch --help
3.6 卸載命令
sudo sh "/Library/Application Support/com.canonical.multipass/uninstall.sh"
3.7 設(shè)置root 密碼
sudo passwd
ubuntu@primary:/$ sudo passwd
New password:
Retype new password:
passwd: password updated successfully
3.8 其他命令
multipass help
xingchen@star ~ % multipass help
Usage: multipass [options] <command>
Create, control and connect to Ubuntu instances.
This is a command line utility for multipass, a
service that manages Ubuntu instances.
Options:
-h, --help Displays help on commandline 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
authenticate Authenticate client
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 aliases
version Show version details
xingchen@star ~ %
4 擴(kuò)展命令
4.1 啟動一個(gè)新的虛擬機(jī)
- 指定鏡像與名字
multipass launch --name=test1 --cpus=1 --mem=2048MiB
multipass launch appliance:[Image] -n [name]
還可以使用以下參數(shù)自定義虛擬機(jī)的配置:文章來源地址http://www.zghlxwxcb.cn/news/detail-808978.html
- –name:指定虛擬機(jī)的名稱。
- –cpus:指定虛擬機(jī)使用的 CPU 核數(shù)。
- –mem:指定虛擬機(jī)使用的內(nèi)存大
4.2 修改內(nèi)存
- 官方文檔有說明https://multipass.run/docs/modify-an-instance
自測可用 multipass1.10.1版本,qemu,主機(jī)macbookairM1 11.6.8系統(tǒng) ubuntu22.04
# 想修改CPU 硬盤內(nèi)存的話可以這樣用
multipass set local.實(shí)例名.(cpus|disk|memory)=(4|50G|5G)
# 舉例:要修改實(shí)例名為acc的虛擬機(jī)的內(nèi)存為5G,在關(guān)機(jī)狀態(tài)下控制臺輸入
multipass set local.acc.memory=5G
# 再開機(jī)就行啦
4.3 調(diào)整cpu
multipass set local.mysql-master.cpus=2
# 這個(gè)可以調(diào)cpu。 更多配置multipass get --keys可以看到。也就是cpu mem disk
到了這里,關(guān)于【手把手教程】MacOS 安裝Multipass一款更輕量級的虛擬機(jī) 保姆級安裝教程的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!