KVM 웹 관리툴(WebVirtMgr) 설치

KVM Management

KVM을 설치하고 관리 하기 위해 여러가지 방법이 있다.
대표적으로 CLI를 통해 관리하는 방법이 있지만 GUI를 통해 쉽고 편하게 관리 할 수 있는 툴이 상당히 많이 나와 있다.
http://kvm.et.redhat.com/page/Management_Tools 에 보면 여러가지 상용 혹은 오픈소스 관리툴들이 존재 한다.
그중 WebVirtMgr을 설치하는 방법에 대해 알아보겠다.


WebVirtMgr 소개

WebVirtMgr은 Apache Licence, Version 2.0을 따르는 libvirt 기반의 가상머신을 관리할 수 있는 웹 인터페이스를 제공하는 오픈소스이다.
vm들을 생성하고 설정하고 각 리소스들을 할당하는 등 일련의 작업들을 GUI환경에서 쉽고 편하게 할 수 있다.

http://retspen.github.io/


WebVirtMgr 설치

Packages 설치

$ sudo apt-get install git python-pip python-libvirt python-libxml2 novnc supervisor nginx

Python, Django Environment Setup

$ mkdir /var/www
$ cd /var/www
$ git clone git://github.com/retspen/webvirtmgr.git
$ cd webvirtmgr
$ sudo pip install -r requirements.txt
$ ./manage.py syncdb

user 정보를 입력.

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 (Put: yes)
Username (Leave blank to use 'admin'): admin (Put: your username or login)
E-mail address: username@domain.local (Put: your email)
Password: xxxxxx (Put: your password)
Password (again): xxxxxx (Put: confirm password)
Superuser created successfully.
$ ./manage.py collectstatic

superuser를 추가로 등록할때

$ ./manage.py createsuperuser

Setup Nginx

/etc/nginx/sites-availablewebvirtmgr 파일 생성 후 아래 내용을 붙여 넣는다.

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 $scheme;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        client_max_body_size 1024M; # Set higher depending on your needs
    }
}
$ sudo ln -s /etc/nginx/sites-available/webvirtmgr /etc/nginx/site-enabled/webvirtmgr
$ sudo unlink /etc/nginx/site-enabled/default
$ /etc/init.d/nginx start
$ sudo chown -R www-data:www-data /var/www/webvirtmgr

Setup Supervisor

다음 내용은 솔찍히 왜 하는지 모르겠다.?
공식 메뉴얼에 보면 novnc서비스를 중지하고 모든 runlevel에서 나열된 novnc스크립트를 제거 후… 어쩌구 저쩌구 나와있는데 @.@
심지어 novnc 스트립트도 없는데…
이부분이 어떤 영향을 끼칠지 모르겠지만 패스해도 별 문제는 없는것 같다.

$ sudo service novnc stop
$ sudo insserv -r novnc
$ sudo vi /etc/insserv/overrides/novnc
#!/bin/sh
### BEGIN INIT INFO
# Provides:          nova-novncproxy
# Required-Start:    $network $local_fs $remote_fs $syslog
# Required-Stop:     $remote_fs
# Default-Start:
# Default-Stop:
# Short-Description: Nova NoVNC proxy
# Description:       Nova NoVNC proxy
### END INIT INFO

/etc/supervisor/conf.dwebvirtmgr.conf 파일을 생성후 다음 내용을 붙여 넣는다.(이 부분 부터는 생략하면 안됨!)

[program:webvirtmgr]
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
stdout_logfile=/var/log/supervisor/webvirtmgr.log
redirect_stderr=true
user=www-data
[program:webvirtmgr-console]
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=www-data

Restart supervisor daemon

$ sudo service supervisor stop
$ sudo service supervisor start

KVM과 연결을 위한 인증 만들기

Note : KVM Host 서버에서 작업한다.

Install Packages

ubuntu

$ sudo apt-get install kvm libvirt-bin sasl2-bin

Configuration

ubuntu
/etc/default/libvirt-bin 파일에 -l옵션 추가

libvirtd_opts="-d -l"

centos
/etc/sysconfig/libvirtd 파일에 --listen옵션 추가

LIBVIRTD_ARGS="--listen"

공통
/etc/libvirt/libvirtd.conf 다음을 찾아서 주석을 제거해 준다.

listen_tls = 0
listen_tcp = 1

Restart libvirtd daemon

ubuntu

$ sudo service libvirt-bin restart

centos

systemctl restart libvirtd
또는
service libvirtd restart

User,Password 생성

saslpasswd2 명령어를 통해 admin이란 사용자를 생성하고 패스워드를 설정한다.

$ sudo saslpasswd2 -a libvirt admin
Password: xxxxxx
Again (for verification): xxxxxx

User 확인

$ sudo sasldblistusers2 -f /etc/libvirt/passwd.db
admin@localhost: userPassword

계정을 비활성화 하는 방법

saslpasswd2 명령어에 -d옵션을 주어 비활성화 한다.

$ sudo saslpasswd2 -a libvirt -d admin

Connection Test

$ virsh -c qemu+tcp://localhost/system nodeinfo
Please enter your authentication name: admin
Please enter your password:
CPU model:           x86_64
CPU(s):              8
CPU frequency:       1400 MHz
CPU socket(s):       1
Core(s) per socket:  8
Thread(s) per core:  1
NUMA cell(s):        1
Memory size:         32979144 KiB

여기까지 진행이 잘 됐으면 설치가 완료 된 것이고, 브라우져를 열고 접속을 해본다.

http://xxx.xxx.xxx.xxx

참고자료

  • https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr
  • https://www.webvirtmgr.net/docs/

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다