{"id":131326,"date":"2018-12-30T10:17:10","date_gmt":"2018-12-30T02:17:10","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=131326"},"modified":"2018-12-24T09:15:01","modified_gmt":"2018-12-24T01:15:01","slug":"virtualization-technology-kvm","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/virtualization-technology-kvm.html","title":{"rendered":"\u865a\u62df\u5316\u6280\u672fKVM\u7684\u642d\u5efa"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nKVM \u662f\u57fa\u4e8e\u865a\u62df\u5316\u6269\u5c55\uff08Intel VT \u6216\u8005 AMD-V\uff09\u7684 X86 \u786c\u4ef6\u7684\u5f00\u6e90\u7684 Linux \u539f\u751f\u7684\u5168\u865a\u62df\u5316\u89e3\u51b3\u65b9\u6848\u3002KVM \u4e2d\uff0c\u865a\u62df\u673a\u88ab\u5b9e\u73b0\u4e3a\u5e38\u89c4\u7684 Linux \u8fdb\u7a0b\uff0c\u7531\u6807\u51c6 Linux \u8c03\u5ea6\u7a0b\u5e8f\u8fdb\u884c\u8c03\u5ea6\uff1b\u865a\u673a\u7684\u6bcf\u4e2a\u865a\u62df CPU \u88ab\u5b9e\u73b0\u4e3a\u4e00\u4e2a\u5e38\u89c4\u7684 Linux \u8fdb\u7a0b\u3002\u8fd9\u4f7f\u5f97 KMV \u80fd\u591f\u4f7f\u7528 Linux \u5185\u6838\u7684\u5df2\u6709\u529f\u80fd\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u73af\u5883\uff1aRed Hat Enterprise Linux Server release 7.3<\/p>\n

1. \u9996\u5148\u8981\u914d\u7f6e\u597dyum\u6e90\uff0c\u68c0\u67e5\u5f53\u524dCPU\u662f\u5426\u652f\u6301KVM\u865a\u62df\u5316\u3002<\/strong><\/div>\n
Red Hat\u6216\u8005CentOS\r\n[root@localhost Desktop]# cat \/proc\/cpuinfo | egrep '(vmx|svm)'\r\n#\u5982\u679c\u8f93\u51fa\u7ed3\u679c\u4e2d\u5305\u542bvmx\uff0c\u5219\u8868\u793a\u91c7\u7528Intel\u865a\u62df\u5316\u6280\u672f\uff1b\u5982\u679c\u5305\u542bsvm\uff0c\u5219\u8868\u793a\u91c7\u7528AMD\u865a\u62df\u5316\u6280\u672f\uff1b\u5982\u679c\u6ca1\u6709\u4efb\u4f55\u8f93\u51fa\uff0c\u8868\u793a\u5f53\u524d\u7684CPU\u4e0d\u652f\u6301KVM\u865a\u62df\u5316\u6280\u672f\u3002\u8fd8\u53ef\u4ee5\u7528grep -E 'svm|vmx' \/proc\/cpuinfo\u548cegrep --color -i \"svm|vmx\" \/proc\/cpuinfo\u6765\u68c0\u67e5\u3002\r\n \r\nUbuntu\u7cfb\u7edf\u4e2d\u67e5\u770b\r\napt-get install cpu-checker\r\nkvm-ok\r\n \r\n\u4ee5\u4e0b\u7ed3\u679c\u8bf4\u660e\u652f\u6301VT\r\nINFO: \/dev\/kvm exists\r\nKVM acceleration can be used\r\n \r\n\u4ee5\u4e0b\u7ed3\u679c\u8bf4\u660e\u4e0d\u652f\u6301VT\r\nINFO: Your CPU does not support KVM extensions\r\nKVM acceleration can NOT be used\r\n<\/pre>\n
2. \u5b89\u88c5\u865a\u62df\u5316\u8f6f\u4ef6\u5305<\/strong><\/div>\n
[root@localhost Desktop]# yum install -y qemu-kvm qemu-img\r\n#Ubuntu\u7528apt-get install -y virt-manager\u6765\u5b89\u88c5                                            \r\n \r\n[root@localhost Desktop]# lsmod | grep kvm\r\n#\u9a8c\u8bc1KVM\u6a21\u5757\u662f\u5426\u6210\u529f\u52a0\u8f7d\r\nkvm_intel             170181  0\r\nkvm                   554609  1 kvm_intel\r\nirqbypass              13503  1 kvm\r\n#\u5982\u679c\u8f93\u51fa\u4ee5\u4e0a\u7ed3\u679c\uff0c\u5219\u8868\u793aKVM\u6a21\u5757\u5df2\u7ecf\u6210\u529f\u52a0\u8f7d\u3002\r\n[root@localhost Desktop]# virsh -c qemu:\/\/\/system list\r\n#\u9a8c\u8bc1libvirtd\u670d\u52a1\u662f\u5426\u6b63\u5e38\u542f\u52a8\r\n Id    Name                           State\r\n#\u5982\u679c\u5df2\u7ecf\u6210\u529f\u542f\u52a8\uff0c\u5219\u4f1a\u8f93\u51fa\u4ee5\u4e0a\u7ed3\u679c\uff1b\u5982\u679c\u51fa\u73b0\u9519\u8bef\uff0c\u5219\u8868\u793alibvirtd\u670d\u52a1\u6ca1\u6709\u6210\u529f\u542f\u52a8\u3002\r\n<\/pre>\n
3. \u5b89\u88c5\u865a\u62df\u673a<\/strong><\/div>\n
[root@localhost Desktop]# virt-manager\r\n\"\"\r\n\"\"\r\n\"\"\r\n\"\"\r\n\"\"\r\n#\u5982\u679c\u9ed8\u8ba4\u7684storage\u4e0d\u80fd\u7528\uff0c\u90a3\u4e48\u5c31\u9009\u62e9\u521b\u5efa\u81ea\u5b9a\u4e49\u7684storage\r\n\"\"<\/pre>\n

\u914d\u7f6e\u597d\u76f8\u5173\u53c2\u6570\uff0c\u51c6\u5907\u88c5\u7cfb\u7edf\uff1a<\/p>\n

\"\"<\/p>\n

\u6b63\u5728\u5b89\u88c5\uff1a<\/p>\n

\"\"<\/p>\n

\u5b89\u88c5\u5b8c\u6210\uff0c\u51c6\u5907\u91cd\u542f\uff1a<\/p>\n

\"\"<\/p>\n

\u5b89\u88c5\u6210\u529f!<\/p>\n

\"\"<\/p>\n

\u5728\u5bbf\u4e3b\u4e0a\u67e5\u770b\u865a\u62df\u673a<\/strong><\/div>\n
[root@localhost ~]# virsh list --all\r\n Id    Name                           State\r\n----------------------------------------------------\r\n -     rhel7.3                        shut off\r\n \r\n[root@localhost ~]# virsh start rhel7.3\r\nDomain rhel7.3 started\r\n \r\n[root@localhost ~]# virsh list --all\r\n Id    Name                           State\r\n----------------------------------------------------\r\n 6     rhel7.3                        running\r\n \r\n \r\n[root@localhost ~]# virsh destroy rhel7.3\r\nDomain rhel7.3 destroyed\r\n \r\n[root@localhost ~]# virsh list --all\r\n Id    Name                           State\r\n----------------------------------------------------\r\n -     rhel7.3                        shut off\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u73af\u5883\uff1aRed Hat Enterprise Linux Server release 7.3 Red Hat\u6216 […]<\/p>\n","protected":false},"author":63,"featured_media":131329,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-131326","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/131326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=131326"}],"version-history":[{"count":10,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/131326\/revisions"}],"predecessor-version":[{"id":144389,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/131326\/revisions\/144389"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/131329"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=131326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=131326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=131326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}