WebVirtMgr可视化管理kvm虚拟机
一、WebVirtMgr
1.安装 WebVirtMgr
参考: WebVirtMgr官方参考手册
[root@kvm-node1 ~]# yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
[root@kvm-node1 ~]# yum -y install gcc python-devel git python-pip libvirt-python libxml2-python python-websockify supervisor nginx novnc
[root@kvm-node1 ~]# pip install numpy
2.安装要求和安装Python的Django环境
[root@kvm-node1 ~]# git clone git://github.com/retspen/webvirtmgr.git
[root@kvm-node1 ~]# cd webvirtmgr
[root@kvm-node1 webvirtmgr]# pip install -r requirements.txt
[root@kvm-node1 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 'root'):
Email address: 552408925@qq.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 6 object(s) from 1 fixture(s)
//添加额外的超级用户
[root@kvm-node1 webvirtmgr]# ./manage.py collectstatic
3.配置Nginx
[root@kvm-node1 webvirtmgr]# cd ..
[root@kvm-node1 ~]# mv webvirtmgr /var/www/
//在/etc/nginx/conf.d目录中添加webvirtmgr.conf
[root@kvm-node1 ~]# 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;
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;
}
}
//注意: 注释/etc/nginx/conf/nginx.conf文件中Server段
//设定目录权限
[root@kvm-node1 ~]# chown -R nginx:nginx /var/www/webvirtmgr
//启动nginx,并将其加入开机自启
[root@kvm-node1 ~]# systemctl start nginx
[root@kvm-node1 ~]# systemctl enable nginx
4.安装配置Supervisor
//创建文件/etc/supervisord.d/webvirtmgr.ini以下内容
[root@kvm-node1 ~]# vim /etc/supervisord.d/webvirtmgr.ini
[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
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=nginx
[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=nginx
5.启动supervisord并加入开机自启
[root@kvm-node1 ~]# systemctl start supervisord.service
[root@kvm-node1 ~]# systemctl enable supervisord.service
6.配置ssh认证SSH官方参考资料
[root@kvm-node1 ~]# su - nginx -s /bin/bash
-bash-4.2$ ssh-keygen
-bash-4.2$ touch ~/.ssh/config
-bash-4.2$ echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> ~/.ssh/config
-bash-4.2$ chmod 0600 ~/.ssh/config
-bash-4.2$ ssh-copy-id root@localhost




浙公网安备 33010602011771号