1. 程式人生 > >web管理kvm ,安裝webvirtmgr

web管理kvm ,安裝webvirtmgr

ole cor grep blog program www. bool get git clone

原創博文
安裝配置KVM http://www.cnblogs.com/elvi/p/7718574.html
web管理kvm http://www.cnblogs.com/elvi/p/7718582.html
kvm系統安裝 http://www.cnblogs.com/elvi/p/7718623.html
KVM克隆&快照 http://www.cnblogs.com/elvi/p/7718628.html

web管理kvm ,安裝webvirtmgr

# web管理kvm ,安裝webvirtmgr

#安裝基礎組件
yum install epel-release
yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
#安裝數據庫
yum install sqlite python-sqlite* #WebVirtMgr安裝及初始化配置 cd /usr/local/src/ git clone git://github.com/retspen/webvirtmgr.git zip -r webvirtmgr.zip webvirtmgr #備份 #將WebVirtMgr復制到系統默認的web服務目錄: mkdir -pv /var/www cp -R /usr/local/src/webvirtmgr /var/www/ #cp -r webvirtmgr/ /var/www/ cd /var/www/webvirtmgr pip install -r requirements.txt #安裝Django .
/manage.py syncdb #django進行環境配置 ./manage.py collectstatic #生成配置文件 # ./manage.py createsuperuser #添加管理員賬號 kvm@kvm2017 # ./manage.py changepassword kvm #修改用戶kvm的密碼 ###############啟動django #參考http://itfish.net/article/58805.html cd /var/www/webvirtmgr ./manage.py runserver 0.0.0.0:8000 #訪問:http://x.x.x.x:8000 (用 ./manage.py createsuperuser創建的用戶)
# nginx代理配置文件 service httpd stop vim /etc/nginx/conf.d/kvm.conf # kvm web server { listen 80 default_server; server_name $hostname; #access_log /var/log/nginx/webvirtmgr_access_log; location /static/ { root /var/www/webvirtmgr/webvirtmgr; # or /srv instead of /var expires max; } location / { proxy_pass http://127.0.0.1:8000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Proto $remote_addr; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_send_timeout 600; client_max_body_size 1024M; # Set higher depending on your needs } } # mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak chkconfig nginx on /etc/init.d/nginx restart service nginx restart chown -R nginx:nginx /var/www/webvirtmgr ##############設置supervisor進程管理 cp /etc/supervisord.conf /etc/supervisord.conf.bak vim /etc/supervisord.conf #在文件末尾添加如下 ;#KVM [program:webvirtmgr] ;#啟動8000端口 command=/usr/bin/python /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py directory=/var/www/webvirtmgr autostart=true autorestart=true logfile=/var/log/supervisor/webvirtmgr.log log_stderr=true user=nginx [program:webvirtmgr-console] ;#啟動6080端口(這是控制臺vnc端口) command=/usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-console directory=/var/www/webvirtmgr autostart=true autorestart=true stdout_logfile=/var/log/supervisor/webvirtmgr-console.log redirect_stderr=true user=nginx ;#KVM grep bind /var/www/webvirtmgr/conf/gunicorn.conf.py #確保下面bind綁定的是本機的8000端口 # bind = 127.0.0.1:8000 #遠程無法訪問 sed -i "/^bind/cbind = ‘0.0.0.0:8000‘" /var/www/webvirtmgr/conf/gunicorn.conf.py |grep bind #supervisor以WEB方式監控管理進程 [inet_http_server] ;#port=127.0.0.1:9009修改為如下 port=*:9009 username=user password=123 # vim /etc/rc.local # /usr/sbin/setsebool httpd_can_network_connect true chkconfig supervisord on #設置開機啟動 /etc/init.d/supervisord restart #啟動進程 #報錯,重新安裝supervisor yum remove supervisor #卸載yum安裝的 yum install supervisor -y #pip install supervisor #安裝 #pip uninstall supervisor #卸載pip安裝的模塊 service supervisord restart lsof -i:8000 #查看端口是否啟動 service nginx restart ######################################### #KVM被管理端配置 #設置tcp ip鏈接 curl http://retspen.github.io/libvirt-bootstrap.sh | sudo sh sudo saslpasswd2 -a libvirt kvm #新建kvm用戶kvm@kvm sudo sasldblistusers2 -f /etc/libvirt/passwd.db #查看賬號 [email protected]: userPassword #sudo saslpasswd2 -a libvirt -d kvm #刪除賬號kvm virsh -c qemu+tcp://127.0.0.1/system nodeinfo #輸入賬戶@hostname+密碼驗證 #登錄web,Add Connection,TCP鏈接,填寫ip、用戶、密碼即可 ###設置ssh鏈接太麻煩…… ######################################################## #centos7 #安裝配置supervisord systemctl restart supervisord systemctl stop supervisord systemctl enable supervisord.service #開機啟動

web管理kvm ,安裝webvirtmgr