{"id":160862,"date":"2019-10-26T12:03:29","date_gmt":"2019-10-26T04:03:29","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=160862"},"modified":"2019-10-17T11:04:29","modified_gmt":"2019-10-17T03:04:29","slug":"kvm-manage-platform-deploy","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/kvm-manage-platform-deploy.html","title":{"rendered":"\u5b9e\u64cd\uff1aKVM\u865a\u62df\u5316\u7ba1\u7406\u5e73\u53f0\u90e8\u7f72"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u547d\u4ee4\u64cd\u4f5c\u867d\u7136\u76f4\u63a5\u660e\u4e86\uff0c\u4f46\u603b\u5f52\u4e0d\u662f\u90a3\u4e48\u7684\u65b9\u4fbf\u5feb\u6377\uff0c\u5e76\u4e14\u7ba1\u7406\u4e5f\u4e0d\u65b9\u4fbf\uff0c\u67e5\u4e86\u4e0b\u5173\u4e8eKVM\u7684\u7ba1\u7406\u5e73\u53f0\u7cfb\u7edf\uff0c\u53d1\u73b0\u4e86WebVirtMgr \u8fd9\u4e2a\u5f00\u6e90\u8f6f\u4ef6\uff0c\u7b80\u5355\u5199\u4e0b\u5b89\u88c5\u8fc7\u7a0b\u548c\u9047\u7740\u7684\u95ee\u9898\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u7cfb\u7edf\u73af\u5883\u4ee5\u53ca\u51c6\u5907\u5de5\u4f5c<\/strong><\/div>\n

1.centos 7_64\u4f4d\u7cfb\u7edf\uff0c\u5173\u95edselinux \u3002<\/p>\n

2.\u5df2\u7ecf\u6210\u529f\u5b89\u88c5KVM\u5e76\u521b\u5efa\u4e86VM\u865a\u62df\u673a\u3002<\/p>\n

3.\u5b89\u88c5epel-release \u6e90\u3002<\/p>\n

4.\u5b89\u88c5\u5bf9\u5e94\u4f9d\u8d56\u5173\u7cfb\uff0c\u4e0b\u8f7dWebVirtMgr \u5e76\u4e14\u5b89\u88c5nginx\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u3002<\/p>\n

WebVirtMgr \u5b89\u88c5\u90e8\u7f72<\/strong><\/div>\n
\u5b89\u88c5Python\u73af\u5883\u3001pip \u5de5\u5177\u4ee5\u53canginx<\/strong><\/span><\/div>\n

epel\u6e90\u5efa\u8bae\u4f7f\u7528\u56fd\u5185\u955c\u50cf\uff1a \u300acentos \u66f4\u6362yum\u6e90\u300b<\/p>\n

\r\n[root@kvm home] yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx   #nginx\u6ca1\u6709\u8fc7\u591a\u7684\u9700\u6c42\uff0c\u6240\u4ee5yum\u5b89\u88c5\u5373\u53ef\r\n<\/pre>\n
\u5b89\u88c5WebVirtMgr<\/strong><\/span><\/div>\n
\r\n[root@kvm home] git clone git:\/\/github.com\/retspen\/webvirtmgr.git\r\n[root@kvm home] cd webvirtmgr\r\n[root@kvm webvirtmgr] pip install -r requirements.txt\r\n<\/pre>\n

\u4e0a\u9762\u7684\u547d\u4ee4\u4f1a\u5b89\u88c5Django \u7b49\u7ec4\u4ef6\uff0c\u9ed8\u8ba4\u4e0b\u8f7d\u901f\u5ea6\u8f83\u6162\uff0c\u5efa\u8bae\u5148\u66ff\u6362pip\u6e90\u4e3a\u56fd\u5185\u6e90\uff1apip\u66f4\u6362\u4e3a\u56fd\u5185\u6e90;\u5982\u679c\u6709\u51fa\u73b0\u4e0b\u9762\u63d0\u793a\u4fe1\u606f\u662f\u7531\u4e8esqlite \u6ca1\u6709\u5b89\u88c5\uff0c\u9700\u8981\u5b89\u88c5\u540e\u518d\u91cd\u65b0\u7f16\u8bd1Python\u3002<\/p>\n

\r\ndjango.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3\r\n[root@kvm7 home] yum -y install sqlite-devel\r\n<\/pre>\n

\u540c\u6b65\u6570\u636e\u5e93<\/p>\n

\r\n[root@kvm webvirtmgr] .\/manage.py syncdb  #\u4f1a\u63d0\u793a\u521b\u5efaDjango \u8fde\u63a5\u6570\u636e\u5e93\u8d26\u53f7\u5bc6\u7801\u7b49\u4fe1\u606f\r\n[root@kvm webvirtmgr] .\/manage.py collectstatic #\u540c\u6b65\u9879\u76ee\u6587\u4ef6\r\n[root@kvm webvirtmgr] .\/manage.py createsuperuser   #\u914d\u7f6ewebvirtmgr \u767b\u5f55\u8d26\u53f7\r\n<\/pre>\n
nginx \u914d\u7f6e<\/strong><\/div>\n
\r\n[root@kvm webvirtmgr] vim \/etc\/nginx\/conf.d\/webvirtmgr.conf\r\n \r\nserver {\r\n    listen 80 ;\r\n    server_name kvm.cnyunwei.cc;\r\n    access_log \/var\/log\/nginx\/webvirtmgr_access_log; \r\n \r\n    location \/static\/ {\r\n        root \/home\/webvirtmgr\/webvirtmgr; \r\n        expires max;\r\n    }\r\n \r\n    location \/ {\r\n        proxy_pass http:\/\/127.0.0.1:8000;\r\n        proxy_set_header X-Real-IP $remote_addr;\r\n        proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;\r\n        proxy_set_header Host $host:$server_port;\r\n        proxy_set_header X-Forwarded-Proto $scheme;\r\n        proxy_connect_timeout 600;\r\n        proxy_read_timeout 600;\r\n        proxy_send_timeout 600;\r\n        client_max_body_size 1024M; \r\n    }\r\n}\r\n<\/pre>\n
\r\n[root@kvm webvirtmgr] nginx -t  #\u68c0\u6d4b\u914d\u7f6e\u662f\u5426\u6b63\u786e\r\nnginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful\r\n[root@kvm webvirtmgr] service nginx restart\r\n<\/pre>\n
Supervisor \u914d\u7f6e<\/strong><\/div>\n

Python \u9879\u76ee\u9ed8\u8ba4\u662f\u65e0\u6cd5\u76f4\u63a5\u5728\u540e\u53f0\u8fd0\u884c\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7Supervisor \u7ba1\u7406\u7a0b\u5e8f\u8fdb\u884c\u63a7\u5236\u3002<\/p>\n

centos 7\u5b89\u88c5\u7684Supervisor \u914d\u7f6e\u53ef\u4ee5\u5728\/etc\/supervisord.d\/\u521b\u5efaxxx.ini \u6587\u4ef6\uff0ccentos 6\u76f4\u63a5\u5728\/etc\/supervisord.conf \u4e2d\u589e\u52a0\u914d\u7f6e\u3002<\/p>\n

\r\n[root@kvm webvirtmgr] vim \/etc\/supervisord.d\/webvirtmgr.ini\r\n[program:webvirtmgr]\r\ncommand=\/usr\/bin\/python \/home\/webvirtmgr\/manage.py run_gunicorn -c \/home\/webvirtmgr\/conf\/gunicorn.conf.py\r\ndirectory=\/home\/webvirtmgr\r\nautostart=true\r\nautorestart=true\r\nlogfile=\/var\/log\/supervisor\/webvirtmgr.log\r\nlog_stderr=true\r\nuser=nginx\r\n \r\n[program:webvirtmgr-console]\r\ncommand=\/usr\/bin\/python \/home\/webvirtmgr\/console\/webvirtmgr-console\r\ndirectory=\/home\/webvirtmgr\r\nautostart=true\r\nautorestart=true\r\nstdout_logfile=\/var\/log\/supervisor\/webvirtmgr-console.log\r\nredirect_stderr=true\r\nuser=nginx\r\n<\/pre>\n

\u4e4b\u524d\u53cd\u590d\u6d4b\u8bd5\uff0csupervisor \u8fdb\u7a0b\u65e0\u6cd5\u542f\u52a8\u8be5\u9879\u76ee\uff0cPython \u6ca1\u6709\u76d1\u542c\u7aef\u53e3\uff0c\u67e5\u770b\u65e5\u5fd7\u4e5f\u6ca1\u6709\u5177\u4f53\u7684\u62a5\u9519\u4fe1\u606f\uff0c\u67e5\u4e86\u5f88\u4e45\u518d\u770b\u914d\u7f6e\u4fe1\u606f\u7684\u65f6\u5019\u53d1\u73b0user=nginx \u8fd9\u4e2a\u503c\uff0c\u60f3\u5230\u4e86webvirtmgr \u9879\u76ee\u7684\u6743\u9650\u662froot \u8d26\u6237\uff0cnginx \u8d26\u6237\u6ca1\u6709\u6267\u884c\u6743\u9650\uff0c\u91cd\u7f6e\u8d26\u6237\u4e3anginx\u540e\u89e3\u51b3\u3002<\/p>\n

\r\n[root@kvm home]  chown nginx.nginx -R webvirtmgr\/\r\n[root@kvm home]  service supervisord restart\r\n<\/pre>\n

\u67e5\u770b\u7aef\u53e3\u76d1\u542c\u60c5\u51b5\uff1a<\/p>\n

\r\n[root@kvm  home]  netstat -tunlp | grep python\r\ntcp        0      0 127.0.0.1:8000              0.0.0.0:*                   LISTEN      1463\/python         \r\ntcp        0      0 0.0.0.0:6080                0.0.0.0:*                   LISTEN      1462\/python\r\n<\/pre>\n
\u914d\u7f6ewebvirtmgr \u8fde\u63a5KVM\u670d\u52a1\u5668<\/strong><\/div>\n

webvirtmgr \u8fde\u63a5kvm\u6709\u4e24\u79cd\u65b9\u5f0f\uff1aSSH\u548cTCP,TCP\u6a21\u5f0f\u6700\u4e3a\u7b80\u5355\u65b9\u4fbf\uff0c\u8fd9\u91cc\u5df2tcp\u8fde\u63a5\u4e3a\u4f8b\u3002<\/p>\n

\u8bbe\u7f6elibvirtd \u670d\u52a1\u76d1\u542c<\/strong><\/span><\/div>\n

\u5728kvm\u670d\u52a1\u5668\u4e0a\u53d6\u6d88libvirtd \u670d\u52a1\u914d\u7f6e\u6587\u4ef6LIBVIRTD_ARGS \u524d\u7684\u6ce8\u91ca\u3000\/etc\/sysconfig\/libvirtd<\/p>\n

\r\n[root@kvm home]  cp \/etc\/sysconfig\/libvirtd{,_bak}  #\u5148\u5907\u4efd\u539f\u6587\u4ef6\u518d\u64cd\u4f5c\r\n[root@kvm home]  vim \/etc\/sysconfig\/libvirtd\r\nLIBVIRTD_ARGS=\"--listen\"\r\n<\/pre>\n
\u914d\u7f6elibvirt \u670d\u52a1<\/strong><\/span><\/div>\n

\/etc\/libvirt\/libvirtd.conf \u5141\u8bb8\u901a\u8fc7tcp\u65b9\u5f0f\u901a\u8baf\uff0c\u4fee\u6539\u4ee5\u4e0b\u53c2\u6570\uff1a<\/p>\n

\r\n[root@kvm home] cp  \/etc\/libvirt\/libvirtd.conf{,_bak}  #\u5148\u5907\u4efd\u539f\u6587\u4ef6\u518d\u64cd\u4f5c\r\n[root@kvm home] vim \/etc\/libvirt\/libvirtd.conf\r\nlisten_tcp = 1  #\u5141\u8bb8tcp\u76d1\u542c\r\ntcp_port = \"16509\"  #\u5f00\u653etcp\u7aef\u53e3\r\nlisten_addr = \"0.0.0.0\"  #\u76d1\u542c\u5730\u5740\u4fee\u6539\u4e3a0.0.0.0\r\nauth_tcp = sasl  #\u914d\u7f6etcp\u901a\u8fc7sasl\u8ba4\u8bc1\r\nlisten_tls = 0  #\u53d6\u6d88CA\u8ba4\u8bc1\u529f\u80fd\r\n<\/pre>\n
\u542f\u52a8\u670d\u52a1\u3001\u521b\u5efalibvirt\u7ba1\u7406\u7528\u6237<\/strong><\/span><\/div>\n
\r\n[root@kvm home] service libvirtd start\r\n[root@kvm home] saslpasswd2 -a libvirt admin #\u521b\u5efa\u7528\u6237admin \r\n<\/pre>\n

\u5728\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u7684\u65f6\u5019\u51fa\u73b0\u8fc7\u7528sed\u547d\u4ee4\u76f4\u63a5\u66ff\u6362\u914d\u7f6e\u6587\u4ef6\u540e\u5bfc\u81f4libvirt\u65e0\u6cd5\u542f\u52a8\uff0c\u8fd8\u597d\u4e4b\u524d\u5907\u4efd\u4e86\u6587\u4ef6\uff0c\u901a\u8fc7vim \u7f16\u8f91\u5668\u624b\u52a8\u67e5\u627e\u4fee\u6539\u540e\u6b63\u5e38\u542f\u52a8\uff0c\u6240\u4ee5\u5bf9\u914d\u7f6e\u6587\u4ef6\u7684\u7f16\u8f91\u4fee\u6539\u524d\u8fdb\u884c\u5907\u4efd\u662f\u591a\u4e48\u91cd\u8981\u7684\u4e8b\u60c5\u3002<\/p>\n

\"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

1.centos 7_64\u4f4d\u7cfb\u7edf\uff0c\u5173\u95edselinux \u3002 2.\u5df2\u7ecf\u6210\u529f\u5b89\u88c5KVM\u5e76\u521b\u5efa\u4e86VM\u865a\u62df\u673a\u3002 3.\u5b89\u88c5 […]<\/p>\n","protected":false},"author":668,"featured_media":38748,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-160862","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\/160862","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\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=160862"}],"version-history":[{"count":9,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160862\/revisions"}],"predecessor-version":[{"id":161614,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160862\/revisions\/161614"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/38748"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=160862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=160862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=160862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}