设为首页 收藏本站
查看: 1434|回复: 0

[经验分享] WebVirtMgr

[复制链接]

尚未签到

发表于 2015-4-10 11:40:49 | 显示全部楼层 |阅读模式
  I really need a web-based tool to manage kvm hosts.
  Search "kvm web" and found "Management Tools - KVM" ( http://www.linux-kvm.org/page/Management_Tools ).
  Well, WebVirtMgr( https://github.com/retspen/webvirtmgr ) looks pretty good. Try it.
  WebVirtMgr is a libvirt-based Web interface for managing virtual machines. It allows you to create and configure new domains, and adjust a domain's resource allocation. A VNC viewer over a SSH tunnel presents a full graphical console to the guest domain. KVM is currently the only hypervisor supported.
  I prepared three servers for the test, one for WebVirtMgr  and two for kvm host.
  
  WebVirtMgr Server Installation
Test server: Centos 6.3 x86_64, ip address 192.168.150.201, hostname ms-centos, username root.
1. Get Fedora EPEL
root@ms-centos:~$ rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
2.Install packages needed
root@ms-centos:~$ yum -y install git python-virtinst httpd mod_python mod_wsgi Django
3.Get webvirtmgr code
root@ms-centos:~$ git clone git://github.com/retspen/webvirtmgr.git
4.Initial webvirtmgr
root@ms-centos:~$ ./webvirtmgr/manage.py syncdb
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'admin'): wvmadmin
E-mail address: wvmadmin@domain.local
Password: 123456
Password (again): 123456
Superuser created successfully.
....
Creating tables ...
Installing custom SQL ...
Installing indexes ...
No fixtures found.
If you want to create another user, 'fred' for example:
[iyunv@ms-centos ~]# ./webvirtmgr/manage.py createsuperuser
Username (Leave blank to use 'root'): fred
E-mail address: fred@domain.local
Password: 654321
Password (again): 654321
Superuser created successfully.

5.Adjust iptables (TCP port 8000 is for app test. In production, use port 80.)
root@ms-centos:~$ vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
root@ms-centos:~$ service iptables restart
6.Run app for test:
[iyunv@ms-centos ~]# ./webvirtmgr/manage.py runserver 192.168.150.201:8000
Validating models...
0 errors found
Django version 1.3.4, using settings 'webvirtmgr.settings'
Development server is running at http://192.168.150.201:8000/
Quit the server with CONTROL-C.
  
  Now browse 'http://192.168.150.201:8000' to try.
Login with the user you created during './webvirtmgr/manage.py syncdb'.
Here we user wvmadmin with password 123456.
DSC0000.png
  
  
Dashboard
DSC0001.png
  Click "Add Connection" to manage kvm host servers.
Of course, you can NOT connect to the kvm host with your host's linux user.
Let's click the "Host Server Setup" link and see what to do for the host.

Host Server Setup
Test server: Ubuntu Server 12.04, ipaddress 192.168.150.202, hostname ms2-ubuntu, username serveruser.
  1. Install packages
serveruser@ms2-ubuntu:~$ sudo apt-get install kvm libvirt-bin sasl2-bin bridge-utils
......
update-rc.d: warning: saslauthd stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (1)
* To enable saslauthd, edit /etc/default/saslauthd and set START=yes
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
serveruser@ms2-ubuntu:~$
serveruser@ms2-ubuntu:~$ sudo vi /etc/default/saslauthd
# Should saslauthd run automatically on startup? (default: no)
START=yes
  Start saslauthd
serveruser@ms2-ubuntu:~$ sudo service saslauthd start
* Starting SASL Authentication Daemon saslauthd                         [ OK ]
serveruser@ms2-ubuntu:~$ sudo service saslauthd status
* Checking SASL Authentication Daemon saslauthd                         [ OK ]
2.Add the option -l in the file /etc/default/libvirt-bin
libvirtd_opts="-d -l"
serveruser@ms2-ubuntu:~$ sudo vi /etc/default/libvirt-bin
3.The file /etc/libvirt/libvirtd.conf uncomment the line
#listen_tls = 0
#listen_tcp = 1
serveruser@ms2-ubuntu:~$ sudo vi /etc/libvirt/libvirtd.conf
4.The file /etc/libvirt/qemu.conf uncomment the line
#vnc_listen = "0.0.0.0"
serveruser@ms2-ubuntu:~$ sudo vi /etc/libvirt/qemu.conf
5.Restart libvirt-bin
serveruser@ms2-ubuntu:~$ sudo service libvirt-bin restart
libvirt-bin stop/waiting
libvirt-bin start/running, process 3091
If someting wrong with CA certificate appears, as shown in libvirt log. ( It's wired that one ubuntu server has it, and the other doesn't.)
serveruser@ms2-ubuntu:~$ sudo tail /var/log/libvirt/libvirtd.log
error : virNetTLSContextCheckCertFile:92 : Cannot read CA certificate '/etc/pki/CA/cacert.pem': No such file or directory
Found a solution here: http://wiki.libvirt.org/page/The_daemon_cannot_be_started
Should install CA certificate, like this:
serveruser@ms1-ubuntu:~$ sudo mkdir -p /etc/pki/CA
serveruser@ms1-ubuntu:~$ sudo openssl genrsa 1024 > cakey.pem
serveruser@ms1-ubuntu:~$ sudo openssl req -new -x509 -key cakey.pem -out /etc/pki/CA/cacert.pem -days 3655
Try:
serveruser@ms1-ubuntu:~$ sudo service libvirt-bin restart
libvirt-bin stop/waiting
libvirt-bin start/running, process 20268
Verify:
serveruser@ms1-ubuntu:~$ sudo service libvirt-bin status
libvirt-bin start/running, process 20268

6.Add a user 'wvm' using saslpasswd2 (This user is used for WebVirtMgr to connect to the kvm host.)
serveruser@ms2-ubuntu:~$ sudo saslpasswd2 -a libvirt wvm
Password:
Again (for verification):
See a list of all accounts
serveruser@ms2-ubuntu:~$ sudo sasldblistusers2 -f /etc/libvirt/passwd.db
wvm@ms2-ubuntu: userPassword
7.Test connection
clientuser@clienthost:~$ sudo apt-get install virt-manager
clientuser@clienthost:~$ virsh -c qemu+tcp://192.168.150.202/system
Please enter your authentication name: wvm
Please enter your password:
error: authentication failed: authentication failed
error: failed to connect to the hypervisor
A tip: The authentication name should be like: username@hostname
clientuser@clienthost:~$ virsh -c qemu+tcp://192.168.150.202/system
Please enter your authentication name: wvm@ms2-ubuntu
Please enter your password:
welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
      'quit' to quit
virsh #
  OK! Now, add your hosts to manage them through web. (to be continued.)
DSC0002.png
DSC0003.png
   DSC0004.png
  
  Next, I think I would like to do some i18n job for retspen, Chinese translation.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-55646-1-1.html 上篇帖子: KVM/QEMU桥接网络设置及kvm资料[zz] 下篇帖子: kvm 实际使用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表