It’s 2024, I advise you to uninstall VMware, Amway is a free open source and lightweight virtual machine: Multipass

Hello, this is the Network Technology Alliance site.

Speaking of virtual machines, the first thing we think of must be VMware virtual machines. If we usually use H3C's HCL emulator, you will also come into contact with VirtualBox. I remember when I was in college, I often installed various systems on VMware virtual machines, such as windows server, ubuntu, etc. VMware virtual machines are easy to use, but they are paid and heavy. Sometimes I just want to test a very small function, and I have to install such a heavy virtual machine, which is really a waste of time. Today Rui Ge will give you a lightweight, free, open source virtual machine: Multipass.

Table of contents:

1. Multipass basics

Virtualization technology is a technology that abstracts computing resources and creates virtual instances. It allows multiple virtual computers to be run on a single physical computer, each of which can independently run different operating systems and applications. Multipass uses virtualization technology to provide users with a lightweight virtual machine management solution.

Multipass is a lightweight virtualization tool that allows users to create and manage multiple virtual machine instances on the local system. Through Multipass, users can easily build and test different development environments for software development and testing. Multipass provides a simple and powerful command line interface, making the creation and management of virtual machines extremely easy.

Multipass is based on Hypervisor technology and realizes the creation and management of virtual machines by running a Hypervisor layer on the host operating system. Multipass uses KVM (Kernel-based Virtual Machine) as the default hypervisor, but also supports other hypervisors such as Hyper-V and VirtualBox.

Multipass was developed to simplify the management of local development environments and provide developers with a way to quickly create, deploy and destroy virtual machines. Maintained by Canonical, Multipass is widely used on the Ubuntu operating system and has corresponding support on other mainstream operating systems.

Multipass has a wide range of applications, including:

  • Developer environment construction: Multipass can help developers easily build various development environments locally and quickly switch between different development configurations.

  • Testing and debugging: Software testers can use Multipass to test in different virtual machines to ensure the compatibility of the software in different environments.

  • Multi-platform software development and testing: Developers of multi-platform software can use Multipass to test their software on different operating systems to ensure cross-platform stability.

Compared with traditional virtual machine management tools, Multipass has the following features:

  • Lightweight: Multipass virtual machines are lightweight and occupy less system resources, so they can run multiple virtual machine instances in resource-limited environments.

  • Quick creation: Multipass provides the ability to quickly create virtual machines. Users can quickly start a virtual machine instance through simple commands, reducing waiting time.

  • Ease of use: Multipass provides a simple and powerful command line interface, allowing users to easily create, manage and destroy virtual machines, lowering the threshold for learning and use.

2. Multipass installation and configuration

Before you start using Multipass, you first need to install Multipass on your system.

We need to remember the Multipass official website address:

https://multipass.run/

On Ubuntu , Multipass can be installed using the following command:

sudo snap install multipass

On macOS , Multipass can be installed using Homebrew:

brew install multipass

Installation on Windows

On Windows, you can download the installer from the Multipass official website for installation.

Multipass can run on multiple operating systems, but the system needs to meet some basic requirements:

  • Hardware virtualization support: If using a KVM Hypervisor, make sure your system supports hardware virtualization and has the appropriate BIOS/UEFI settings enabled.

  • Operating system version: Multipass supports multiple operating systems, including Ubuntu, macOS, Windows, etc. Make sure your system version meets the requirements.

Ubuntu virtual machine, created using Multipass

3. Basic configuration options of Multipass

After the installation is complete, you can perform basic configuration through the following steps:

  1. Initialize Multipass: Run the following command to initialize Multipass:
multipass launch --name my-vm

This will create a my-vmvirtual machine instance named .

  1. View the list of virtual machines: Use the following command to view the list of created virtual machines:
multipass list

This will display the virtual machine instances currently on the system.

  1. Connect to the virtual machine: Use the following command to connect to the virtual machine:
multipass shell my-vm

This will open a new command line window to connect to the virtual machine.

4. Use Multipass to create a virtual machine

Multipass provides a series of commands for creating, managing, and operating virtual machines.

  • multipass launch: Create a new virtual machine instance.
multipass launch --name my-vm

  • multipass list: Display the list of virtual machines on the current system.
multipass list

  • multipass shell: Connect to the virtual machine.
multipass shell my-vm

4.1 Create and start a virtual machine

The command to create and start a new virtual machine instance is as follows:

multipass launch --name my-vm

This will download the Ubuntu image and create a my-vmvirtual machine instance named . You can multipass listview the virtual machine list through the command.

4.2 Network configuration of virtual machine

Multipass virtual machines use NAT (Network Address Translation) by default to communicate with the host. If you need to access virtual machine services or access virtual machine services from the host, you can use port forwarding.

For example, forward port 8080 of the host to port 80 of the virtual machine:

multipass stop my-vm  # 先停止虚拟机
multipass start my-vm  # 启动虚拟机
multipass info my-vm  # 获取虚拟机的 IP 地址
multipass forward my-vm 8080:80  # 将主机的 8080 端口转发到虚拟机的 80 端口

You can now http://localhost:8080access the service on the virtual machine by accessing it on the host machine.

5. Virtual machine management and operation

5.1 Enter the virtual machine

To enter the command line interface of a virtual machine, you can use the following command:

multipass shell my-vm

This will open a new command line window and connect to my-vmthe virtual machine named .

5.2 Copy files and directories

multipass transferFiles and directories can be transferred between the host and the virtual machine using the command:

multipass transfer local-file.txt my-vm:/path/in/vm/

This will local-file.txtcopy to the virtual machine's /path/in/vm/directory.

5.3 Installation and management software

Installing software in a virtual machine is similar to installing it on a physical machine. First, multipass shellenter the virtual machine via , and then install it using the package management tool appropriate for the virtual machine operating system.

For example, use to install the software in an Ubuntu virtual machine apt:

multipass shell my-vm
sudo apt update
sudo apt install package-name

This will install the specified package in the virtual machine.

6. Multi-nodes and clusters

6.1 Communication between multiple virtual machines

In Multipass, you can easily create multiple virtual machine instances and make them communicate with each other. Each virtual machine has a unique name, such as my-vm1, my-vm2etc. To communicate between virtual machines, you can use the following steps:

  1. Make sure the virtual machine is running:
multipass start my-vm1
multipass start my-vm2
  1. Get the IP address of the virtual machine:
multipass info my-vm1
multipass info my-vm2

Note the IP address of each virtual machine.

  1. Test the connection on a virtual machine using pingor other network tools:
ping <my-vm2-IP-address>

This will show the network connectivity between virtual machines.

6.2 Create and manage virtual machine clusters

Using Multipass, you can easily create virtual machine clusters. By connecting multiple virtual machines into the same virtual network, you can simulate a real cluster environment. The following are the general steps for creating a virtual machine cluster:

  1. Create a virtual machine cluster:
multipass launch --name my-vm1
multipass launch --name my-vm2

Create two virtual machines named my-vm1and my-vm2.

  1. Connect the virtual machine to the same virtual network:
multipass connect my-vm1
multipass connect my-vm2

This will connect to the console of each virtual machine and perform the necessary network configuration.

  1. Communicate between virtual machines:

Using the method mentioned previously, test the network connection between the virtual machines to make sure they can communicate with each other.

  1. Simulate cluster behavior:

Install the required software on each virtual machine, configure the cluster environment, and simulate the behavior of the actual cluster.

With these steps, you can easily create a virtual machine cluster in Multipass to test and develop clustered applications.

7. Snapshots and backups

7.1 Create a virtual machine snapshot

In Multipass, you can create a snapshot of a virtual machine to save the current state of the virtual machine. This is useful for creating backups before making major changes. Here are some basic steps for using snapshots:

  1. Stop the virtual machine:
multipass stop my-vm
  1. Create a snapshot:
multipass snapshot my-vm

This will create a my-vmsnapshot of the virtual machine named .

  1. View the snapshot list:
multipass info my-vm

This will display the virtual machine's information, including a list of snapshots.

7.2 Restoring and deleting snapshots

  1. To restore a snapshot:
multipass restore my-vm snapshot-name

This will restore the virtual machine to the specified snapshot state.

  1. Delete a snapshot:
multipass delete my-vm snapshot-name

This will delete the specified snapshot.

7.3 Backup and restore of virtual machines

If you want to fully back up a virtual machine so you can migrate it to another system or restore it to a different state, you can perform the following steps:

  1. Stop the virtual machine:
multipass stop my-vm
  1. Copy the virtual machine directory:

Copy the virtual machine's data directory, which is usually located in the Multipass data storage location.

  1. Restore the virtual machine on the new system:

Copy the backed up virtual machine directory to the new system and execute the following command:

multipass import --name my-vm /path/to/copied-vm

This will create a virtual machine on the new system.

These methods allow you to easily create and manage snapshots of virtual machines in Multipass, and perform backup and restore operations.

8. Integration with cloud platform

Multipass provides the ability to integrate with cloud platforms, allowing users to create and manage Multipass virtual machines on the cloud.

8.1 Integration of Multipass and cloud service providers

  1. Log in to cloud account:

Before you begin, make sure you are logged into your cloud account in Multipass. You can use the following command to log in to the specified cloud service provider:

multipass cloud login <cloud-provider>

where <cloud-provider>is the cloud service provider you selected, for example aws, azure, or gcp.

  1. Create a virtual machine on the cloud:
multipass launch --name my-cloud-vm --cloud <cloud-provider>

This will create a virtual machine instance on the cloud platform with the name of my-cloud-vmand cloud service provider of <cloud-provider>.

8.2 Create and manage Multipass virtual machines on the cloud

Multipass also supports the creation and management of Multipass virtual machines on the cloud platform. Here are some basic commands:

  • List virtual machines in the cloud:
multipass list --cloud <cloud-provider>

This will display a list of Multipass virtual machines running on the cloud provider.

  • Connect to a virtual machine on the cloud:
multipass shell <cloud-vm-name> --cloud <cloud-provider>

This will connect to the specified named virtual machine on the cloud.

  • Delete a virtual machine on the cloud:
multipass delete <cloud-vm-name> --cloud <cloud-provider>

This will delete the virtual machine of the specified name on the cloud.

Through these commands, you can easily create, manage, and connect Multipass virtual machines on the cloud platform.

9. Frequently Asked Questions and Performance Optimization

9.1 Frequently Asked Questions and Solutions

When using Multipass, you may encounter some common problems.

  • Problem: Unable to start virtual machine.

    • Solution: Ensure that the host system supports hardware virtualization and has BIOS/UEFI settings enabled. Check the Multipass log for detailed error information.
  • Problem: The virtual machine cannot connect to the internet.

    • Solution: Check the virtual machine network configuration to ensure that NAT is configured correctly. A restart of the virtual machine or Multipass may be required.
  • Problem: Unable to start virtual machine on cloud platform.

    • Solution: Make sure you have configured your cloud platform account correctly and logged in. Check your cloud provider's documentation for more information.

9.2 Performance tuning tips and best practices

Some tips and best practices to improve Multipass virtual machine performance include:

  • Use hardware virtualization: Make sure the host system has hardware virtualization enabled to improve virtual machine performance.

  • Allocate resources appropriately: Adjust the memory and CPU configuration of the virtual machine as needed to ensure that the virtual machine has sufficient resources.

  • Use local images: Try to use local images instead of downloading from the cloud to improve startup speed.

  • Clean up virtual machines regularly: Delete virtual machine instances that are no longer needed to free up resources and improve performance.

Through these tips, you can better optimize the performance of the Multipass virtual machine and ensure that it can run more efficiently during development and testing.

10. Which should I use, Multipass or VMware?

Choosing Multipass or VMware depends on your specific needs, use cases, and personal preferences.

10.1 Usage scenarios

Multipass
  1. Lightweight development environment: Multipass is a lightweight virtual machine management tool suitable for quickly creating and managing development environments.
  2. Developer use: For developers, Multipass provides a simple command line interface, suitable for quickly setting up and testing different development environments locally.
VMware
  1. Enterprise-level virtualization: VMware is a mature and feature-rich virtualization platform suitable for enterprise-level environments, providing more powerful virtualization functions and management tools.
  2. Production environment: If you need to run business-critical applications in a production environment, VMware may be a better fit because of its greater stability and reliability.

10.2 Functionality and performance

Multipass
  1. Lightweight: Multipass is relatively lightweight, takes up less system resources, and is suitable for running multiple virtual machine instances in environments with limited resources.
  2. Quick startup and operation: Provides the ability to quickly create and start virtual machines, suitable for developers to quickly iterate and test.
VMware
  1. Comprehensive virtualization capabilities: VMware provides more comprehensive virtualization capabilities, including advanced network configuration, storage management, snapshots and backups.
  2. Performance and Stability: In production environments, VMware generally provides higher performance and stability and supports large-scale virtualization deployments.

10.3 Cost

Multipass
  1. Free and Open Source: Multipass is open source software, free to use, and runs on different operating systems.
VMware
  1. Commercial License: Some advanced features provided by VMware may require the purchase of a commercial license. In an enterprise environment, there may be some costs involved.

10.4 User experience

Multipass
  1. Simple command line interface: Multipass provides a simple and powerful command line interface, suitable for users who like to operate through the command line.
VMware
  1. Graphical User Interface (GUI): VMware provides an intuitive graphical user interface for those who prefer to use visual tools.

Considering the above factors, if you are a developer looking for a lightweight virtualization solution and like to operate through the command line, Multipass may be a good choice. If you are in an enterprise environment and need more comprehensive virtualization capabilities and are more focused on performance and stability, then VMware may better meet your needs.

Guess you like

Origin blog.csdn.net/weixin_43025343/article/details/135286842