webvirtmgr 安裝記錄

環境:

ubuntu-16.04.5-server-amd64

服務器ip 192.168.10.128

使用163源

更新源

apt-get update
apt-get upgrade

官網:
https://github.com/retspen/webvirtmgr

安裝kvm過程

官網文檔

https://github.com/retspen/webvirtmgr/wiki/Setup-Host-Server

curl http://retspen.github.io/libvirt-bootstrap.sh | sudo sh

成功時提示

Processing triggers for systemd (229-4ubuntu21.22) ...
 *  INFO: Found function install_ubuntu_post
 * DEBUG: POST_INSTALL_FUNC=install_ubuntu_post
 *  INFO: Running install_ubuntu_post()
 *  INFO: Found function daemons_running_ubuntu
 * DEBUG: DAEMONS_RUNNING_FUNC=daemons_running_ubuntu
 *  INFO: Running daemons_running_ubuntu()

查看是否啓動成功

sudo service libvirt-bin status

安裝WebVirtMgr

官方文檔

https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr

安裝依賴包

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

下載代碼

cd ~
git clone git://github.com/retspen/webvirtmgr.git
cd webvirtmgr

安裝依賴

sudo pip install -r requirements.txt

同步數據庫

./manage.py syncdb

生成配置文件

 ./manage.py collectstatic

運行模式(兩種)

開發模式

創建目錄

mkdir -p /var/www/webvirtmgr/images

啓動nonvc ,會監聽 6080 端口

python ./console/webvirtmgr-console

啓動服務

./manage.py runserver 0:8000

瀏覽器訪問
http://192.168.10.128:8000

服務模式

拷貝代碼到 /var/www/ 目錄下

cd ..
sudo mv webvirtmgr /var/www/

在 /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 $scheme;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        client_max_body_size 1024M; # Set higher depending on your needs 
    }
}

註釋掉 /etc/nginx/sites-enabled/default 的內容

重啓nginx

sudo service nginx restart

處理權限

sudo chown -R nginx:nginx /var/www/webvirtmgr

使用 supervisor 管理 webvirtmgr
在 /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

重啓 supervisor

sudo service supervisor stop
sudo service supervisord start

瀏覽器訪問
http://192.168.10.128

使用流程

  1. 登錄
  2. 添加連接(選擇local Socket)
  3. 進入連接
  4. 選擇存儲池
  5. 創建存儲(一個目錄卷)
  6. 創建鏡像
  7. 創建存儲(一個iso鏡像卷)
  8. 選擇上傳鏡像
  9. 創建虛擬機實例(磁盤鏡像,網絡池)
  10. 選擇實例
  11. 連接iso鏡像
  12. 啓動實例
  13. 連接實例

圖片上傳真麻煩,不能複製粘貼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章