【覚書】Ubuntu 14.04 に「KVM」とWeb管理が出来る「WebVirtmgr」を入れてみる
[bash] $ apt-get install git python-pip python-libvirt python-libxml2 novnc supervisor nginx $ apt-get install kvm libvirt-bin bridge-utils virt-manager $ mkdir ~/src $ cd ~/src $ git clone git://github.com/retspen/webvirtmgr.git $ cd webvirtmgr $ sudo pip install -r requirements.txt $ ./manage.py syncdb #ログインユーザーを作る $ ./manage.py collectstatic $ ./manage.py createsuperuser #ルートユーザーを作る ユーザー名はrootとかに $ cd .. $ mv webvirtmgr /var/www/ $ vim /etc/nginx/sites-enabled/default の中を全部コメントアウト [/bash]
[bash] $ vim /etc/nginx/conf.d/webvirtmgr.conf
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 } } [/bash]
[bash] $ service sudo nginx restart
$ sudo chown -R www-data:www-data /var/www [/bash]
[bash] $ vim /etc/supervisor/conf.d/webvirtmgr.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 [/bash]
[bash] $ sudo service supervisor restart [/bash]
[bash] libvirtmgr の設定 Webvirtmgrとの連携
vim /etc/default/libvirt-bin
listen_tls = 0 listen_tcp = 1 listen_addr = "127.0.0.1" [/bash]
[bash] $ sudo apt-get install sasl2-bin $ saslpasswd2 -a libvirt ユーザ名 $ sasldblistusers2 -f /etc/libvirt/passwd.db $ sudo service libvirt-bin restart [/bash]
[bash] 接続出来るか確認する
& sudo virsh -c qemu+tcp://127.0.0.1/system nodeinfo
Please enter your authentication name: ユーザ名 Please enter your password: パスワード
CPU モデル: x86_64 CPU: 8 CPU 周波数: 3158 MHz CPU ソケット数: 2 ソケットあたりのコア数: 4 コアあたりのスレッド数: 1 NUMA セル数: 1 メモリー容量: 16429092 KiB
こうなれば成功
[/bash]
右上の「Add Conection」からこんな感じにする。 Labelに大文字が使えないのとIPはlocalhostだとエラーが出る。
こんな感じに緑色になってたら成功
Webvirtmgr上から仮想建てれたり、コンソールが使えたりするので便利