{"id":7697,"date":"2020-05-23T19:48:46","date_gmt":"2020-05-23T11:48:46","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=7697"},"modified":"2020-05-23T19:48:47","modified_gmt":"2020-05-23T11:48:47","slug":"virsh","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/virsh","title":{"rendered":"virsh\u547d\u4ee4 – \u7ba1\u7406\u7528\u6237\u754c\u9762"},"content":{"rendered":"\n

virsh\u547d\u4ee4\u662f\u7ba1\u7406virsh\u6765\u5bbe\u57df\u7684\u4e3b\u754c\u9762\u3002\u8be5\u7a0b\u5e8f\u53ef\u7528\u4e8e\u521b\u5efa\u3001\u6682\u505c\u548c\u5173\u95ed\u57df\u3002\u5b83\u8fd8\u53ef\u7528\u4e8e\u5217\u51fa\u5f53\u524d\u57df\u3002<\/p>\n\n\n\n

Libvirt\u662f\u4e00\u4e2a\u4e0e\u865a\u62df\u5316\u4ea4\u4e92\u7684C\u5de5\u5177\u5305\u6700\u65b0\u7248\u672cLinux\uff08\u548c\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\uff09\u7684\u529f\u80fd\u3002\u5b83\u662fGNU\u4e0b\u7684\u514d\u8d39\u8f6f\u4ef6\u6267\u7167\u3002Linux\u64cd\u4f5c\u7cfb\u7edf\u7684\u865a\u62df\u5316\u610f\u5473\u7740\u80fd\u591f\u8fd0\u884c\u591a\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u4f8b\u540c\u65f6\u5728\u4e00\u4e2a\u786c\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5176\u4e2d\u57fa\u672c\u8d44\u6e90\u7531\u4e00\u4e2aLinux\u5b9e\u4f8b\u9a71\u52a8\u3002\u56fe\u4e66\u9986\u7684\u76ee\u6807\u662f\u63d0\u4f9b\u957f\u671f\u7a33\u5b9a\u7684C API\u3002\u5b83\u76ee\u524d\u652f\u6301Xen\u3001QEMU\u3001KVM\u3001LXC\u3001OpenVZ\u3001VirtualBox\u548cVMware ESX\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>virsh [\u53c2\u6570]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

nodememstats<\/td>\u83b7\u53d6KVM\u7ba1\u7406\u7a0b\u5e8f\uff08\u4e3b\u673a\uff09\u5185\u5b58\u4fe1\u606f<\/td><\/tr>
nodecpustats<\/td>\u83b7\u53d6KVM\u865a\u62df\u673a\u76d1\u63a7\u7a0b\u5e8fCPU\u4fe1\u606f<\/td><\/tr>
list --all<\/td>\u83b7\u53d6\u6765\u5bbe\u865a\u62df\u673a\u7684\u6570\u91cf\uff0c\u4e0e\u8fd0\u884c\u3001\u4fdd\u5b58\u3001\u5173\u95ed\u7b49\u72b6\u6001\u65e0\u5173<\/td><\/tr>
net-list<\/td>\u83b7\u53d6\u53ef\u7528\u4e8eKVM\u7ba1\u7406\u7a0b\u5e8f\u7684\u6240\u6709\u7f51\u7edc<\/td><\/tr>
dominfo<\/td>\u83b7\u53d6KVM\u5ba2\u6237\u673a\u7684\u786c\u4ef6\u4fe1\u606f<\/td><\/tr>
shutdown \u865a\u62df\u673a\u540d\u79f0<\/td>\u5173\u95ed\u865a\u62df\u673a<\/td><\/tr>
start \u865a\u62df\u673a\u540d\u79f0<\/td>\u542f\u52a8\u865a\u62df\u673a<\/td><\/tr>
reboot \u865a\u62df\u673a\u540d\u79f0<\/td>\u91cd\u542f\u865a\u62df\u673a<\/td><\/tr>
destroy<\/td>\u5f3a\u884c\u5173\u95ed\u6216\u6bc1\u574f\u673a\u5668<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u83b7\u53d6KVM\u7ba1\u7406\u7a0b\u5e8f\uff08\u4e3b\u673a\uff09\u5185\u5b58\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# virsh nodememstats<\/pre>\n\n\n\n

\u83b7\u53d6KVM\u865a\u62df\u673a\u76d1\u63a7\u7a0b\u5e8fCPU\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# virsh nodecpustats<\/pre>\n\n\n\n

\u83b7\u53d6\u6765\u5bbe\u865a\u62df\u673a\u7684\u6570\u91cf\uff0c\u4e0e\u8fd0\u884c\u3001\u4fdd\u5b58\u3001\u5173\u95ed\u7b49\u72b6\u6001\u65e0\u5173\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# virsh list --all<\/pre>\n\n\n\n

\u83b7\u53d6\u53ef\u7528\u4e8eKVM\u7ba1\u7406\u7a0b\u5e8f\u7684\u6240\u6709\u7f51\u7edc\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# virsh net-list<\/pre>\n","protected":false},"excerpt":{"rendered":"

virsh\u547d\u4ee4\u662f\u7ba1\u7406virsh\u6765\u5bbe\u57df\u7684\u4e3b\u754c\u9762\u3002\u8be5\u7a0b\u5e8f\u53ef\u7528\u4e8e\u521b\u5efa\u3001\u6682\u505c\u548c\u5173\u95ed\u57df\u3002\u5b83\u8fd8\u53ef\u7528\u4e8e\u5217\u51fa\u5f53\u524d\u57df\u3002 Libv […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/7697"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=7697"}],"version-history":[{"count":5,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/7697\/revisions"}],"predecessor-version":[{"id":7755,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/7697\/revisions\/7755"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=7697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=7697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=7697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}