云计算虚拟机技术-KVM安装
云计算虚拟机技术-KVM安装
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
身为运维的小伙伴估计大家都清楚KVM,因为在CentOS里面KVM还算很折腾的一个软件,早期CentOS使用的xen虚拟化,后因收购KVM,于是就把KVM替换掉了xen,因此KVM主键走入运维的眼帘。
我之前分析过连篇关于KVM的笔记,分别是:虚拟化技术之KVM和KVM使用入门。里面的操作环境都是基于CentOS6.x系列的。最近在CentOS7.x的操作系统上也捣鼓过一番,由此把倒腾的笔记记录一下,方便我日后查看。
一.开启虚拟机支持硬件虚拟化
1>.开启宿主机主板上的虚拟化支持
首先开启虚拟化,需要CPU支持虚拟化才行;
>.开机时按Del键或者F2键进入BIOS系统;
注:一般开机时系统下会有提示,根据提示按相应的键进入BIOS系统。 >.选择Configuratio选项卡,光标移到Intel Virtual Technology,按回车键,选择Enabled,按回车键;
注:主板不一样,BIOS中的菜单选项不一样,主要是找到Virtual或Virtualization将其设置为Enabled。
2>.启动虚拟机实例前配置
我们知道KVM在使用的时候必须是硬件支持虚拟化的,因此在使用之前,我们要确保我们使用的虚拟机实例是否支持硬件虚拟化技术。不推荐使用开源的virtualbox,因为它不支持在虚拟机再次使用虚拟化技术。而我推荐使用vmware workstation软件。因为他支持在虚拟机里面继续支持虚拟化操作。只需要我们在启动虚拟机实例时开启该功能即可,如下图所示。
3>.检查虚拟机实例是否支持硬件虚拟机技术
我们只需要在命令行中输入:“ grep --color -Ei "vmx|svm" /proc/cpuinfo ”如果有输出则说明支持硬件虚拟机技术,如果没有输出说明你当前环境是不支持硬件虚拟化的哟。(注意,其中vmx表示INTER系列CPU支持的类型,svm表示ADM系列CPU支持的类型。)
[root@node105 ~]# cat /etc/redhat-release
CentOS Linux release 7.2. (Core)
[root@node105 ~]#
[root@node105 ~]# grep --color -Ei "vmx|svm" /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi ept vpid fsgsbase tsc_adjust smep
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi ept vpid fsgsbase tsc_adjust smep
[root@node105 ~]#
[root@node105 ~]#
[root@node105 ~]# grep --color -Ei "vmx|svm" /proc/cpuinfo
4>.手动加载kvm内核
事实上只要你安装了CentOs6.x系列往后的任何操作系统版本,想使用KVM虚拟机不需要安装任何组件(因为KVM是一个内置模块),只要编译时这个模块被编译了,那么一定是支持相关虚拟化的,否则只能重新编译内核。
[root@node105 ~]# grep -i "kvm" /boot/config-3.10.-.el7.x86_64
CONFIG_KVM_GUEST=y
# CONFIG_KVM_DEBUG_FS is not set
CONFIG_HAVE_KVM=y
CONFIG_HAVE_KVM_IRQCHIP=y
CONFIG_HAVE_KVM_IRQFD=y
CONFIG_HAVE_KVM_IRQ_ROUTING=y
CONFIG_HAVE_KVM_EVENTFD=y
CONFIG_KVM_APIC_ARCHITECTURE=y
CONFIG_KVM_MMIO=y
CONFIG_KVM_ASYNC_PF=y
CONFIG_HAVE_KVM_MSI=y
CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT=y
CONFIG_KVM_VFIO=y
CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT=y
CONFIG_KVM=m
CONFIG_KVM_INTEL=m
CONFIG_KVM_AMD=m
CONFIG_KVM_MMU_AUDIT=y
# CONFIG_KVM_DEVICE_ASSIGNMENT is not set
[root@node105 ~]#
[root@node105 ~]#
[root@node105 ~]# modprobe kvm
[root@node105 ~]#
[root@node105 ~]# lsmod | grep kvm
kvm_intel
kvm kvm_intel
[root@node105 ~]#
[root@node105 ~]#
[root@node105 ~]# grep -i "kvm" /boot/config-3.10.0-327.el7.x86_64
二.KVM安装
1>.安装KVM相关管理工具
qemu-kvm是KVM在用户空间的管理工具。libvirt是用来管理KVM虚拟机的。
[root@node105 ~]# yum -y install qemu-kvm libvirt
.....
libvirt-daemon.x86_64 :4.5.-.el7_6. libvirt-daemon-config-network.x86_64 :4.5.-.el7_6.
libvirt-daemon-config-nwfilter.x86_64 :4.5.-.el7_6. libvirt-daemon-driver-interface.x86_64 :4.5.-.el7_6.
libvirt-daemon-driver-lxc.x86_64 :4.5.-.el7_6. libvirt-daemon-driver-network.x86_64 :4.5.-.el7_6.
libvirt-daemon-driver-nodedev.x86_64 :4.5.-.el7_6. libvirt-daemon-driver-nwfilter.x86_64 :4.5.-.el7_6.
libvirt-daemon-driver-qemu.x86_64 :4.5.-.el7_6. libvirt-daemon-driver-secret.x86_64 :4.5.-.el7_6.
libvirt-daemon-driver-storage.x86_64 :4.5.-.el7_6. libvirt-daemon-driver-storage-core.x86_64 :4.5.-.el7_6.
libvirt-daemon-driver-storage-disk.x86_64 :4.5.-.el7_6. libvirt-daemon-driver-storage-gluster.x86_64 :4.5.-.el7_6.
libvirt-daemon-driver-storage-iscsi.x86_64 :4.5.-.el7_6. libvirt-daemon-driver-storage-logical.x86_64 :4.5.-.el7_6.
libvirt-daemon-driver-storage-mpath.x86_64 :4.5.-.el7_6. libvirt-daemon-driver-storage-rbd.x86_64 :4.5.-.el7_6.
libvirt-daemon-driver-storage-scsi.x86_64 :4.5.-.el7_6. libvirt-libs.x86_64 :4.5.-.el7_6.
libvorbis.x86_64 :1.3.-.el7. libxcb.x86_64 :1.13-.el7
libxslt.x86_64 :1.1.-.el7 lvm2.x86_64 :2.02.-.el7_6.
lvm2-libs.x86_64 :2.02.-.el7_6. lz4.x86_64 :1.7.-.el7
lzop.x86_64 :1.03-.el7 netcf-libs.x86_64 :0.2.-.el7
nfs-utils.x86_64 :1.3.-0.61.el7 nmap-ncat.x86_64 :6.40-.el7
numad.x86_64 :0.5-.20150602git.el7 opus.x86_64 :1.0.-.el7
pciutils.x86_64 :3.5.-.el7 perl.x86_64 :5.16.-.el7_6
perl-Carp.noarch :1.26-.el7 perl-Encode.x86_64 :2.51-.el7
perl-Exporter.noarch :5.68-.el7 perl-File-Path.noarch :2.09-.el7
perl-File-Temp.noarch :0.23.-.el7 perl-Filter.x86_64 :1.49-.el7
perl-Getopt-Long.noarch :2.40-.el7 perl-HTTP-Tiny.noarch :0.033-.el7
perl-PathTools.x86_64 :3.40-.el7 perl-Pod-Escapes.noarch :1.04-.el7_6
perl-Pod-Perldoc.noarch :3.20-.el7 perl-Pod-Simple.noarch :3.28-.el7
perl-Pod-Usage.noarch :1.63-.el7 perl-Scalar-List-Utils.x86_64 :1.27-.el7
perl-Socket.x86_64 :2.010-.el7 perl-Storable.x86_64 :2.45-.el7
perl-Text-ParseWords.noarch :3.29-.el7 perl-Time-HiRes.x86_64 :1.9725-.el7
perl-Time-Local.noarch :1.2300-.el7 perl-constant.noarch :1.27-.el7
perl-libs.x86_64 :5.16.-.el7_6 perl-macros.x86_64 :5.16.-.el7_6
perl-parent.noarch :0.225-.el7 perl-podlators.noarch :2.5.-.el7
perl-threads.x86_64 :1.87-.el7 perl-threads-shared.x86_64 :1.43-.el7
pixman.x86_64 :0.34.-.el7 pulseaudio-libs.x86_64 :10.0-.el7
qemu-img.x86_64 :1.5.-.el7_6. qemu-kvm-common.x86_64 :1.5.-.el7_6.
quota.x86_64 :4.01-.el7 quota-nls.noarch :4.01-.el7
radvd.x86_64 :2.17-.el7 rdma-core.x86_64 :17.2-.el7
rpcbind.x86_64 :0.2.-.el7 seabios-bin.noarch :1.11.-.el7
seavgabios-bin.noarch :1.11.-.el7 sgabios-bin.noarch :.20110622svn-.el7
spice-server.x86_64 :0.14.-.el7_6. tcp_wrappers.x86_64 :7.6-.el7
unbound-libs.x86_64 :1.6.-.el7 usbredir.x86_64 :0.7.-.el7
yajl.x86_64 :2.0.-.el7 Updated:
selinux-policy.noarch :3.13.-.el7_6. systemd.x86_64 :-.el7_6. Dependency Updated:
cryptsetup-libs.x86_64 :2.0.-.el7 cyrus-sasl-lib.x86_64 :2.1.-.el7 dbus.x86_64 :1.10.-.el7 dbus-libs.x86_64 :1.10.-.el7
device-mapper.x86_64 :1.02.-.el7_6. device-mapper-libs.x86_64 :1.02.-.el7_6. gnutls.x86_64 :3.3.-.el7 krb5-libs.x86_64 :1.15.-.el7_6
libgudev1.x86_64 :-.el7_6. libnl3.x86_64 :3.2.-.el7 libselinux.x86_64 :2.5-14.1.el7 libselinux-python.x86_64 :2.5-14.1.el7
libselinux-utils.x86_64 :2.5-14.1.el7 libsemanage.x86_64 :2.5-.el7 libsepol.x86_64 :2.5-.el7 libtasn1.x86_64 :4.10-.el7
p11-kit.x86_64 :0.23.-.el7 p11-kit-trust.x86_64 :0.23.-.el7 pciutils-libs.x86_64 :3.5.-.el7 policycoreutils.x86_64 :2.5-.el7_6.
selinux-policy-targeted.noarch :3.13.-.el7_6. systemd-libs.x86_64 :-.el7_6. systemd-sysv.x86_64 :-.el7_6. Complete!
[root@node105 ~]#
[root@node105 ~]# yum -y install qemu-kvm libvirt
virt-install是KVM用来安装虚拟机用的。
[root@node105 ~]# yum -y install virt-install
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
* extras: ftp.sjtu.edu.cn
* updates: mirror.lzu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package virt-install.noarch :1.5.-.el7 will be installed
--> Processing Dependency: virt-manager-common = 1.5.-.el7 for package: virt-install-1.5.-.el7.noarch
--> Running transaction check
---> Package virt-manager-common.noarch :1.5.-.el7 will be installed
--> Processing Dependency: libvirt-python >= 0.7. for package: virt-manager-common-1.5.-.el7.noarch
--> Processing Dependency: libosinfo >= 0.2. for package: virt-manager-common-1.5.-.el7.noarch
--> Processing Dependency: python-requests for package: virt-manager-common-1.5.-.el7.noarch
--> Processing Dependency: python-ipaddr for package: virt-manager-common-1.5.-.el7.noarch
--> Processing Dependency: libxml2-python for package: virt-manager-common-1.5.-.el7.noarch
--> Processing Dependency: genisoimage for package: virt-manager-common-1.5.-.el7.noarch
--> Running transaction check
---> Package genisoimage.x86_64 :1.1.-.el7 will be installed
--> Processing Dependency: libusal = 1.1.-.el7 for package: genisoimage-1.1.-.el7.x86_64
--> Processing Dependency: libusal.so.()(64bit) for package: genisoimage-1.1.-.el7.x86_64
--> Processing Dependency: librols.so.()(64bit) for package: genisoimage-1.1.-.el7.x86_64
---> Package libosinfo.x86_64 :1.1.-.el7 will be installed
--> Processing Dependency: osinfo-db-tools for package: libosinfo-1.1.-.el7.x86_64
--> Processing Dependency: osinfo-db for package: libosinfo-1.1.-.el7.x86_64
---> Package libvirt-python.x86_64 :4.5.-.el7 will be installed
---> Package libxml2-python.x86_64 :2.9.-.el7_2. will be installed
--> Processing Dependency: libxml2 = 2.9.-.el7_2. for package: libxml2-python-2.9.-.el7_2..x86_64
---> Package python-ipaddr.noarch :2.1.-.el7 will be installed
---> Package python-requests.noarch :2.6.-.el7_1 will be installed
--> Processing Dependency: python-urllib3 >= 1.10.- for package: python-requests-2.6.-.el7_1.noarch
--> Processing Dependency: python-chardet >= 2.2.- for package: python-requests-2.6.-.el7_1.noarch
--> Running transaction check
---> Package libusal.x86_64 :1.1.-.el7 will be installed
---> Package libxml2.x86_64 :2.9.-.el7_1. will be updated
---> Package libxml2.x86_64 :2.9.-.el7_2. will be an update
---> Package osinfo-db.noarch :-.el7_6 will be installed
---> Package osinfo-db-tools.x86_64 :1.1.-.el7 will be installed
--> Processing Dependency: libarchive.so.()(64bit) for package: osinfo-db-tools-1.1.-.el7.x86_64
---> Package python-chardet.noarch :2.2.-.el7_1 will be installed
---> Package python-urllib3.noarch :1.10.-.el7 will be installed
--> Processing Dependency: python-six for package: python-urllib3-1.10.-.el7.noarch
--> Processing Dependency: python-ipaddress for package: python-urllib3-1.10.-.el7.noarch
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-urllib3-1.10.-.el7.noarch
--> Running transaction check
---> Package libarchive.x86_64 :3.1.-.el7_2 will be installed
---> Package python-backports-ssl_match_hostname.noarch :3.5.0.1-.el7 will be installed
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-.el7.noarch
---> Package python-ipaddress.noarch :1.0.-.el7 will be installed
---> Package python-six.noarch :1.9.-.el7 will be installed
--> Running transaction check
---> Package python-backports.x86_64 :1.0-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
virt-install noarch 1.5.-.el7 base k
Installing for dependencies:
genisoimage x86_64 1.1.-.el7 base k
libarchive x86_64 3.1.-.el7_2 base k
libosinfo x86_64 1.1.-.el7 base k
libusal x86_64 1.1.-.el7 base k
libvirt-python x86_64 4.5.-.el7 base k
libxml2-python x86_64 2.9.-.el7_2. base k
osinfo-db noarch -.el7_6 updates k
osinfo-db-tools x86_64 1.1.-.el7 base k
python-backports x86_64 1.0-.el7 base 5.8 k
python-backports-ssl_match_hostname noarch 3.5.0.1-.el7 base k
python-chardet noarch 2.2.-.el7_1 base k
python-ipaddr noarch 2.1.-.el7 base k
python-ipaddress noarch 1.0.-.el7 base k
python-requests noarch 2.6.-.el7_1 base k
python-six noarch 1.9.-.el7 base k
python-urllib3 noarch 1.10.-.el7 base k
virt-manager-common noarch 1.5.-.el7 base 1.2 M
Updating for dependencies:
libxml2 x86_64 2.9.-.el7_2. base k Transaction Summary
=============================================================================================================================================================================================
Install Package (+ Dependent packages)
Upgrade ( Dependent package) Total download size: 4.2 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(/): genisoimage-1.1.-.el7.x86_64.rpm | kB ::
(/): libosinfo-1.1.-.el7.x86_64.rpm | kB ::
(/): libarchive-3.1.-.el7_2.x86_64.rpm | kB ::
(/): libvirt-python-4.5.-.el7.x86_64.rpm | kB ::
(/): libxml2-2.9.-.el7_2..x86_64.rpm | kB ::
(/): libusal-1.1.-.el7.x86_64.rpm | kB ::
(/): osinfo-db-tools-1.1.-.el7.x86_64.rpm | kB ::
(/): libxml2-python-2.9.-.el7_2..x86_64.rpm | kB ::
(/): python-backports-1.0-.el7.x86_64.rpm | 5.8 kB ::
(/): python-backports-ssl_match_hostname-3.5.0.1-.el7.noarch.rpm | kB ::
(/): python-ipaddr-2.1.-.el7.noarch.rpm | kB ::
(/): python-ipaddress-1.0.-.el7.noarch.rpm | kB ::
(/): python-chardet-2.2.-.el7_1.noarch.rpm | kB ::
(/): python-requests-2.6.-.el7_1.noarch.rpm | kB ::
(/): python-six-1.9.-.el7.noarch.rpm | kB ::
(/): osinfo-db--.el7_6.noarch.rpm | kB ::
(/): python-urllib3-1.10.-.el7.noarch.rpm | kB ::
(/): virt-install-1.5.-.el7.noarch.rpm | kB ::
(/): virt-manager-common-1.5.-.el7.noarch.rpm | 1.2 MB ::
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 5.3 MB/s | 4.2 MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : libxml2-2.9.-.el7_2..x86_64 /
Installing : python-ipaddress-1.0.-.el7.noarch /
Installing : libxml2-python-2.9.-.el7_2..x86_64 /
Installing : libarchive-3.1.-.el7_2.x86_64 /
Installing : osinfo-db-tools-1.1.-.el7.x86_64 /
Installing : osinfo-db--.el7_6.noarch /
Installing : libosinfo-1.1.-.el7.x86_64 /
Installing : libvirt-python-4.5.-.el7.x86_64 /
Installing : python-six-1.9.-.el7.noarch /
Installing : python-backports-1.0-.el7.x86_64 /
Installing : python-backports-ssl_match_hostname-3.5.0.1-.el7.noarch /
Installing : python-urllib3-1.10.-.el7.noarch /
Installing : python-chardet-2.2.-.el7_1.noarch /
Installing : python-requests-2.6.-.el7_1.noarch /
Installing : libusal-1.1.-.el7.x86_64 /
Installing : genisoimage-1.1.-.el7.x86_64 /
Installing : python-ipaddr-2.1.-.el7.noarch /
Installing : virt-manager-common-1.5.-.el7.noarch /
Installing : virt-install-1.5.-.el7.noarch /
Cleanup : libxml2-2.9.-.el7_1..x86_64 /
Verifying : osinfo-db-tools-1.1.-.el7.x86_64 /
Verifying : libosinfo-1.1.-.el7.x86_64 /
Verifying : python-ipaddr-2.1.-.el7.noarch /
Verifying : python-urllib3-1.10.-.el7.noarch /
Verifying : libxml2-2.9.-.el7_2..x86_64 /
Verifying : libusal-1.1.-.el7.x86_64 /
Verifying : python-chardet-2.2.-.el7_1.noarch /
Verifying : python-requests-2.6.-.el7_1.noarch /
Verifying : libxml2-python-2.9.-.el7_2..x86_64 /
Verifying : libarchive-3.1.-.el7_2.x86_64 /
Verifying : python-backports-1.0-.el7.x86_64 /
Verifying : python-six-1.9.-.el7.noarch /
Verifying : libvirt-python-4.5.-.el7.x86_64 /
Verifying : virt-install-1.5.-.el7.noarch /
Verifying : python-ipaddress-1.0.-.el7.noarch /
Verifying : virt-manager-common-1.5.-.el7.noarch /
Verifying : genisoimage-1.1.-.el7.x86_64 /
Verifying : osinfo-db--.el7_6.noarch /
Verifying : python-backports-ssl_match_hostname-3.5.0.1-.el7.noarch /
Verifying : libxml2-2.9.-.el7_1..x86_64 / Installed:
virt-install.noarch :1.5.-.el7 Dependency Installed:
genisoimage.x86_64 :1.1.-.el7 libarchive.x86_64 :3.1.-.el7_2 libosinfo.x86_64 :1.1.-.el7 libusal.x86_64 :1.1.-.el7
libvirt-python.x86_64 :4.5.-.el7 libxml2-python.x86_64 :2.9.-.el7_2. osinfo-db.noarch :-.el7_6 osinfo-db-tools.x86_64 :1.1.-.el7
python-backports.x86_64 :1.0-.el7 python-backports-ssl_match_hostname.noarch :3.5.0.1-.el7 python-chardet.noarch :2.2.-.el7_1 python-ipaddr.noarch :2.1.-.el7
python-ipaddress.noarch :1.0.-.el7 python-requests.noarch :2.6.-.el7_1 python-six.noarch :1.9.-.el7 python-urllib3.noarch :1.10.-.el7
virt-manager-common.noarch :1.5.-.el7 Dependency Updated:
libxml2.x86_64 :2.9.-.el7_2. Complete!
[root@node105 ~]#
[root@node105 ~]# yum -y install virt-install
2>.启动libvirt服务
[root@node105 ~]# systemctl enable libvirtd
[root@node105 ~]#
[root@node105 ~]# systemctl start libvirtd
[root@node105 ~]#
[root@node105 ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun -- :: CST; 7s ago
Docs: man:libvirtd()
https://libvirt.org
Main PID: (libvirtd)
CGroup: /system.slice/libvirtd.service
├─ /usr/sbin/libvirtd
├─ /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
└─ /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper Feb :: node105.yinzhengjie.org.cn libvirtd[]: -- ::02.207+: : warning : virQEMUCapsLogProbeFailure: : Failed to probe capabilities for /usr/libexec...
Feb :: node105.yinzhengjie.org.cn libvirtd[]: -- ::02.257+: : warning : virLXCDriverCapsInit: : Failed to get host CPU cache info
Feb :: node105.yinzhengjie.org.cn dnsmasq[]: started, version 2.66 cachesize
Feb :: node105.yinzhengjie.org.cn dnsmasq[]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth
Feb :: node105.yinzhengjie.org.cn dnsmasq-dhcp[]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
Feb :: node105.yinzhengjie.org.cn dnsmasq[]: reading /etc/resolv.conf
Feb :: node105.yinzhengjie.org.cn dnsmasq[]: using nameserver 172.30.1.254#
Feb :: node105.yinzhengjie.org.cn dnsmasq[]: read /etc/hosts - addresses
Feb :: node105.yinzhengjie.org.cn dnsmasq[]: read /var/lib/libvirt/dnsmasq/default.addnhosts - addresses
Feb :: node105.yinzhengjie.org.cn dnsmasq-dhcp[]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Hint: Some lines were ellipsized, use -l to show in full.
[root@node105 ~]#
[root@node105 ~]#
[root@node105 ~]# systemctl start libvirtd
[root@node105 ~]# yum -y install net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
* extras: ftp.sjtu.edu.cn
* updates: mirror.lzu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 :2.0-0.24.20131004git.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
net-tools x86_64 2.0-0.24.20131004git.el7 base k Transaction Summary
=============================================================================================================================================================================================
Install Package Total download size: k
Installed size: k
Downloading packages:
net-tools-2.0-0.24.20131004git.el7.x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : net-tools-2.0-0.24.20131004git.el7.x86_64 /
Verifying : net-tools-2.0-0.24.20131004git.el7.x86_64 / Installed:
net-tools.x86_64 :2.0-0.24.20131004git.el7 Complete!
[root@node105 ~]#
[root@node105 ~]# yum -y install net-tools #安装常用的网络管理工具
[root@node105 ~]# ifconfig
eno16777736: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 172.30.1.105 netmask 255.255.255.0 broadcast 172.30.1.255
inet6 fe80::20c:29ff:fe38:e29c prefixlen scopeid 0x20<link>
ether :0c:::e2:9c txqueuelen (Ethernet)
RX packets bytes (73.4 MiB)
RX errors dropped overruns frame
TX packets bytes (2.5 MiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (340.0 B)
RX errors dropped overruns frame
TX packets bytes (340.0 B)
TX errors dropped overruns carrier collisions virbr0: flags=<UP,BROADCAST,MULTICAST> mtu 1500 #大家把眼力劲看向这里,这块网卡是由于咱们安装了libvirtd软件时创建了这块虚拟网卡!我们可以看到这块虚拟机的ip地址。
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether ::::: txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions [root@node105 ~]#
[root@node105 ~]#
3>.将你需要安装虚拟机的iso通过scp或者rz等工具上传到服务器上
[root@node105 ~]# ll -h /root/iso/
total 603M
-rw-r--r--. root root 603M May CentOS--x86_64-Minimal-.iso
[root@node105 ~]#
[root@node105 ~]#
4>.创建一个raw格式10G大小的虚拟机磁盘
[root@node105 ~]# ll -h /root/iso/
total 603M
-rw-r--r--. root root 603M May CentOS--x86_64-Minimal-.iso
[root@node105 ~]#
[root@node105 ~]# qemu-img create -f raw /home/yinzhengjie/CentOS--x86_64.raw 10G
Formatting '/home/yinzhengjie/CentOS-7-x86_64.raw', fmt=raw size=
[root@node105 ~]#
5>.创建虚拟机
[root@node105 ~]# virt-install --virt-type kvm \ #指定虚拟机的类型
> --name Yinzhengjie-CentOS--x86_64 \ #指定虚拟机的名称
> --ram \ #指定内存大小为1GB,默认单位是MB
> --cdrom=/root/iso/CentOS--x86_64-Minimal-.iso \ #指定光盘的路径
> --disk path=/home/yinzhengjie/CentOS--x86_64.raw \ #指定你创建磁盘的路径
> --network network=default \ #指定网络
> --graphics vnc,listen=0.0.0.0 \ #指定连接方式为VNC,监听模式指定所有的网卡
> --noautoconsole
6>.使用VNC连接工具链接到你的虚拟机上
7>.
8>.
云计算虚拟机技术-KVM安装的更多相关文章
- 云计算之KVM安装(二)
云计算之KVM安装(二) 调整虚拟机 虚拟化Intel使用的是intel VT-X AMD使用的是AMD-V 创建虚拟机步骤 1.准备虚拟机硬盘 2.需要系统iso镜像 3.需要安装一个vnc的客户端 ...
- CentOS7.2上用KVM安装虚拟机window10踩过的坑
最近两个星期一直在琢磨kvm安装window10操作系统,并且通过桥接模式与外界通信,经历了九九八十一难,终于搞定.下面就记录以下我们在探索的过程中踩过的坑. 安装KVM 1. 系统要求:需要一台可以 ...
- Linux的桌面虚拟化技术KVM(三)——KVM虚拟机克隆和快照
Linux的桌面虚拟化技术KVM(一)——新建KVM虚拟机 Linux的桌面虚拟化技术KVM(二)——远程桌面管理 (1).KVM虚拟机克隆 KVM虚拟克隆命令virt-clone [选项] 常用选项 ...
- Linux的桌面虚拟化技术KVM(四)——虚拟机镜像格式对比与转换
Linux的桌面虚拟化技术KVM(一)——新建KVM虚拟机 Linux的桌面虚拟化技术KVM(二)——远程桌面管理 Linux的桌面虚拟化技术KVM(三)——KVM虚拟机克隆和快照 (1).常用镜像格 ...
- 【原创】linux mint 17.3 kvm 安装windows7虚拟机
一.安装windows7虚拟机 linux mint 17.3是一个不错的桌面发行版本,我下载了 linux mint 17.3 for xfce 桌面版本,运行速度没得说,而且安装设置都挺简单,非常 ...
- kvm 安装 windows 虚拟机
作者:SRE运维博客 博客地址: https://www.cnsre.cn/ 文章地址:https://www.cnsre.cn/posts/211108848062/ 相关话题:https://ww ...
- 云计算与虚拟化KVM深度实践
徐亮伟, 江湖人称标杆徐.多年互联网运维工作经验,曾负责过大规模集群架构自动化运维管理工作.擅长Web集群架构与自动化运维,曾负责国内某大型电商运维工作. 个人博客"徐亮伟架构师之路&quo ...
- 虚拟化技术KVM
1>虚拟化技术: 计算机虚拟化技术是多种技术的综合实现,它包括硬件平台,操作系统,存储以及网络等,简单地说,虚拟化技术就是在单台主机上可以虚拟多个虚假主机,并可以在这些虚拟主机上运行不同的操作系 ...
- Linux虚拟化技术KVM、QEMU与libvirt的关系(转)
说明:个人理解,KVM是内核虚拟化技术,而内核是不能使用在界面上使用的,那么此时QEMU提供了用户级别的使用界面,相互辅助.当然,单独使用QEMU也是可以实现一整套虚拟机,不过QEMU+KVM基本是标 ...
随机推荐
- 轻量级浏览器Midori
导读 这是一个对再次回归的轻量级.快速.开源的 Web 浏览器 Midori 的快速回顾. 如果你正在寻找一款轻量级网络浏览器替代品,请试试 Midori. Midori是一款开源的网络浏览器,它更注 ...
- kebab HDU - 2883(按时间段建点)
题意: 有n个人去撸串,每个人都能决定自己的串上有几块肉,每一块肉都要花费一个单位时间才熟,烤炉一次能烤m块肉 给出每个人的起始时间.终止时间.要几串.每个串上有几块肉,问能否满足所有的人 (啥?题不 ...
- Ionic3 新增 Service
service是单例模式的 新增Service类 search.service.ts import {Injectable} from '@angular/core'; @Injectable() e ...
- 【cf849ABC】
849A - Odds and Ends 问能否将序列划分为奇数个长度奇数的奇数开头奇数结尾的子区间. 一开始想dp..不过没必要. const int N=201000; int n,a[N]; i ...
- android 读取EXcel 文件 读取文件内存卡的权限
android 采用Java的读取xls文件的方式实现. 需要导入第三方Jxl.jar 包. 代码改自 其他博主 : 这只摘录下 读取xls文件的部分代码,当然这个代码在安卓平台需要添加下面的权限 ...
- TypeError: __init__() got an unexpected keyword argument 't_command'
python .\manage.py migrate 报错如下 λ python .\manage.py migrateTraceback (most recent call last): File ...
- Mysql数据库操作笔记
如果数据库表字段存在,则删除该表 drop table if exists `table_name` 创建数据库表语句 create table `table_name`( `id` ) not n ...
- POJ-3436 ACM Computer Factory(网络流EK)
As you know, all the computers used for ACM contests must be identical, so the participants compete ...
- NOIP2018保卫王国
题目大意:给一颗有点权的树,每次规定两个点选还是不选,求这棵树的最小权点覆盖. 题解 ZZ码农题. 要用动态dp做,这题就是板子,然鹅并不会,留坑代填. 因为没有修改,所以可以静态倍增. 我们先做一遍 ...
- CentOS装个NTP时间同步服务器
服务端: driftfile /var/lib/ntp/drift restrict default nomodify notrap nopeer noquery restrict 127.0.0.1 ...