Linux System Learning 12th Day-<< Engineer Technology >>

Source: Internet
Author: User
Tags yum repolist

Overview of Virtualization
? Virtualization Resource Management
–x a physical resource--y logical resource
– Degree of implementation: full, partial, hardware-assisted (CPU)


To create a new virtual machine manually:
Virtual machine Name: Example
Network type selection: private1


#########################################################


? Using the Virt-manager Client tool


To operate on a real machine:

? View KVM Node (server) Information
–virsh NodeInfo
? List virtual machines
–virsh list [--all]
? View information for a specified virtual machine
–virsh Dominfo Virtual machine name
? Set the specified virtual machine to run automatically
–virsh autostart [--disable] Virtual machine name

? Run | restart | Close the specified virtual machine
–virsh Start|reboot|shutdown Virtual machine name
? Force shutdown of the specified virtual machine
–virsh Destroy virtual machine name

#######################################################
Setting up local yum in virtual machine example

1. Mount the disc
[Root@a ~]# Mount/dev/cdrom/dvd

2. Client Files
[Root@a ~]# Cat/etc/yum.repos.d/dvd.repo
[DVD]
Name=dvd
Baseurl=file:///dvd
Enabled=1
Gpgcheck=0

#####################################################

? Using preset groupings for the RHEL7 software warehouse

–yum Groups list [hidden] [group name] ...
–yum groups Info [group name] ...
–yum groups install [group name] ...
–yum groups Remove [group name] ...


[Root@a ~]# yum Groups install
virtualization\ Client
virtualization\ Hypervisor
virtualization\ Platform
virtualization\ Tools

########################################################
Desktop icons

/usr/share/applications/


Right-click-----icon---------> Copy to---------->home-------> Desktop


######################################################

Start the LIBVIRTD service side
? LIBVIRTD providing a service interface for managing virtual machines


######################################################

In Linux, the KVM virtual machine consists of:

– An XML configuration file (virtual machine Profile): Defines the name of the virtual machine, UUID, CPU, internal
Various parameter settings such as storage, virtual disk, network card, etc.
/etc/libvirt/qemu/*.xml

– Disk image file: Saves the virtual machine's operating system and document data,
The mirror path depends on the definition in the XML configuration file
/var/lib/libvirt/images/

[[Email protected] Desktop]# ls/etc/libvirt/qemu/
[[Email protected] Desktop]# ls/var/lib/libvirt/images/

[[Email protected] Desktop]# du-sh/var/lib/libvirt/images/

Details: template Virtual Machine example, note delete Channel device

#######################################################
Create a new virtual machine by example a virtual machine

1. Turn off the example virtual machine
[Email protected] Desktop]# Virsh Destroy example
2. Copying a copy of the disk file via example virtual machine
[[Email protected] Desktop]# cd/var/lib/libvirt/images/
[Email protected] images]# qemu-img info example.qcow2
[email protected] images]# CP example.qcow2 Test01.qcow2
3. Copy the virtual machine description file via example virtual machine
[Email protected] images]# cd/etc/libvirt/qemu/
[[email protected] qemu]# ls
[email protected] qemu]# CP example.xml Test01.xml
[Email protected] qemu]# vim Test01.xml
Virtual machine name, UUID, virtual machine disk file, Nic Mac

[Email protected] qemu]# Uuidgen

4. Import new virtual machine information
# Virsh Define/etc/libvirt/qemu/test01.xml #导入虚拟机信息
# Virsh List--all

##########################################################
Exporting an XML configuration file
– View: Virsh dumpxml Virtual machine name
– Backup: Virsh dumpxml virtual machine name > virtual machine name. xml


Adjusting the configuration of a virtual machine
– Edit: Virsh Edit Virtual machine name

#########################################################

Cow copy on write, quickly rebuild virtual machine

1. Virtual machine disk files, fast generation

? Copy on write, copying on write
– Direct mapping of the data contents of the original disk
– When the old data of the original disk has been modified, the old data is automatically stored
Into the front-end disk
– Modifications to the front-end disk are not written back to the original disk

2.qemu-img specifying the original disk via the-B option multiplexing

–qemu-img create-f qcow2-b Original disk front end disk

1. Turn off the virtual machine
[Email protected]/]# Virsh Destroy example

2. Creating a front-end disk
# qemu-img Create-f qcow2-b/var/lib/libvirt/images/example.qcow2/var/lib/libvirt/images/test02.qcow2

3. Generate a new virtual machine profile
[Email protected]/]# cd/etc/libvirt/qemu/
[email protected] qemu]# CP example.xml Test02.xml
[Email protected] qemu]# vim Test02.xml

Virtual machine name, UUID, virtual machine disk file, Nic Mac

[Email protected] qemu]# Uuidgen

4. Import new virtual machine information
# Virsh Define/etc/libvirt/qemu/test02.xml #导入虚拟机信息
# Virsh List--all

###########################################################

Offline access to virtual machines
? Using the Guestmount tool
– Supports offline mounting of raw, QCOW2 format virtual machine disks
– You can modify the document on disk directly in the case of a virtual machine
– Easy to customize, repair, and script maintenance for virtual machines

# guestmount-a/var/lib/libvirt/images/example.qcow2-i/mnt/


###################################################

1) Production environment can be labeled/.unconfigured, convenient for new virtual machines
Configuration (equivalent to factory settings, prompting user initialization)


#######################################################
Building a new teaching environment

1. Generate two virtual machines in the real machine
[[Email protected] Desktop]# CLONE-VM7
Enter VM Number:8
[[Email protected] Desktop]# CLONE-VM7
Enter VM Number:9

2. Modify the virtual machine name, a another B

Virtual Machine A:
Host Name: svr7.tedu.cn
IP Address: 192.168.4.7/24

Virtual Machine B:
Host Name: pc207.tedu.cn
IP Address: 192.168.4.207/24

Construction of 3.Yum Warehouse

Real-machine Yum server, Web shared disc all content
[[Email protected] Desktop]# MKDIR/VAR/WWW/HTML/RHEL7
[[Email protected] Desktop]# LS/VAR/WWW/HTML/RHEL7
[[Email protected] Desktop]# MOUNT/ISO/RHEL-SERVER-7.2-X86_64-DVD.ISO/VAR/WWW/HTML/RHEL7

[[Email protected] Desktop]# LS/VAR/WWW/HTML/RHEL7
[[Email protected] Desktop]# Firefox 127.0.0.1/rhel7
[[Email protected] Desktop]# Vim/etc/fstab

/iso/rhel-server-7.2-x86_64-dvd.iso/var/www/html/rhel7 iso9660 Defaults 0 0

[[Email protected] Desktop]# umount/var/www/html/rhel7/
[[Email protected] Desktop]# ls/var/www/html/rhel7/
[[Email protected] Desktop]# mount-a
[[Email protected] Desktop]# ls/var/www/html/rhel7/

Client: Virtual machine a vs. virtual machine B

Virtual Machine A
[Email protected] ~]# Vim/etc/yum.repos.d/dvd.repo
[DVD]
Name=dvd
Baseurl=http://192.168.4.254/rhel7
Enabled=1
Gpgcheck=0

[email protected] ~]# Yum repolist


With remote copy data, between different hosts of the network

SCP Local Path User name @ each other's IP address: The path of the other party

Scp/etc/yum.repos.d/dvd.repo [Email PROTECTED]:/ETC/YUM.REPOS.D


##########################################################
Virtual Machine A
Virtual Machine B


Linux System Learning 12th Day-<< Engineer Technology >>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.