In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to manage the KVM virtual environment through the command line under Linux". The editor shows you the operation process through the actual case, the operation method is simple and fast, and the practicality is strong. I hope this article "how to manage the KVM virtual environment through the command line under Linux" can help you solve the problem.
KVM is a fully functional virtualization solution on x86 hardware platform under Linux, including a loadable kernel module kvm.ko providing and virtualizing core architecture and processor specification module. Using KVM allows multiple virtual machines, including Linux and Windows, to have private hardware, including network cards, disks and graphics adapter cards.
Step 1: configure the storage pool
The Virsh command line tool is a user interface that manages the virsh client domain. It can run the given command and its parameters on the command line. We will use it to create a storage pool for our KVM environment. For more information about this tool, use the following command:
# man virsh
1. Define a new storage pool
You can use the command virsh with pool-define-as to define a new storage pool. You need to specify the name, type and type parameters. In this case, we take the name as Spool1 and the type as directory. By default, you can provide five parameters for this type:
Source-hostsource-pathsource-devsource-nametarget
For directory types, we need to specify the path to the storage pool with the last parameter "target", and we can populate the other parameters with "-".
# virsh pool-define-as Spool1 dir-"/ mnt/personal-data/SPool1/"
two。 View a list of created storage pools
To view all our storage pools in the environment, use the following command:
# virsh pool-list-all
3. Construct a storage pool
Now let's construct the storage pool, using the following command to construct the storage pool we just defined.
# virsh pool-build Spool1
4. Activate and start the storage pool
Activate and start the storage pool we just created and constructed with the virsh command with the pool-start parameter.
# virsh pool-start Spool1
5. View storage pool statu
To view the status of the storage pool in the environment, use the following command:
# virsh pool-list-all
You will find that the state of Spool1 has become activated.
6. Configure automatic start
Configure Spool1 so that it can be self-started by the libvirtd service every time.
# virsh pool-autostart Spool1
7. View the latest information
Finally, let's take a look at our new storage pool information:
# virsh pool-info Spool1
As you can see, Spool1 is ready to stand by, so let's try to create a storage volume to use it.
Step 2: configure the storage volume / disk image
Now that it's your turn to qemu-img, create a new disk image in Spool1 with the disk command. For more details, you can check the man manual.
# man qemu-img
1. Create a storage volum
We should specify "create, check,..." after the qemu-img command. And so on, the disk image format, the path and size of the disk image you want to create.
# qemu-img create-f raw / mnt/personal-data/SPool1/SVol1.img 10G
two。 View storage volume information
You can get some information about your new disk image by using the qemu-img command with info. Warning: do not use the qemu-img command to modify an image that is being used by a running virtual machine or any other process, as it will be corrupted.
Step 3: create a virtual machine
1. Create
In the final step, we will use the virt-install command to create the virtual machine, virt-install is a command-line tool for creating a new KVM virtual machine, which uses the "libvirt" hypervisor library. For more details, you can also check the man manual:
# man virt-install
To create a new KVM virtual machine, you need to use commands with all of the following information.
Name: the name of the virtual machine. Disk Location: location of the disk image. Graphics: how to connect to VM, usually SPICE. Vcpu: the number of virtual CPU. Ram: the amount of allocated memory in megabytes. Location: specify the installation source path. Network: specifies a virtual network, usually a virbr0 bridge. Virt-install-name=rhel7-disk path=/mnt/personal-data/SPool1/SVol1.img-graphics spice-vcpu=1-ram=1024-location=/run/media/dos/9e6f605a-f502-4e98-826e-e6376caea288/rhel-server-7.0-x86_64-dvd.iso-network bridge=virbr0
two。 Creation process
The next step is the installation process of the virtual machine system, so I won't go into detail.
This is the end of the content about "how to manage the KVM virtual environment through the command line under Linux". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.