环境:
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
使用流程
- 登录
- 添加连接(选择local Socket)
- 进入连接
- 选择存储池
- 创建存储(一个目录卷)
- 创建镜像
- 创建存储(一个iso镜像卷)
- 选择上传镜像
- 创建虚拟机实例(磁盘镜像,网络池)
- 选择实例
- 连接iso镜像
- 启动实例
- 连接实例
图片上传真麻烦,不能复制粘贴