CENTOS7 KVM webvirtmgr安装
简单介绍
webvirtmgr是虚拟机的web管理控制台对于不太熟悉命令的同学可以用web的方式创建管理kvm虚拟机链接: link.
1.安装基础环境
先配置一个yum源
[kvm]
name=kvm
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://dl.fedoraproject.org/pub/epel/7/x86_64/
enable=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
安装基础软件包
yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
yum -y install gcc python-devel
pip install numpy
2.安装python环境和Django环境
git clone git://github.com/retspen/webvirtmgr.git
cd webvirtmgr
pip install -r requirements.txt #安装
./manage.py syncdb #初始化数据库
./manage.py collectstatic #拷贝一些需要的js文件
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: QQzjUUw* (Put: your password)
Password (again): QQzjUUw* (Put: confirm password)
Superuser created successfully.
./manage.py createsuperuser #创建超用户
3.修改nginx配置文件
cd ..
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/nginx.conf
将server域的内容全部注释掉
# server {
# listen 80 default_server;
# server_name localhost;
# root /usr/share/nginx/html;
#
# #charset koi8-r;
#
# #access_log /var/log/nginx/host.access.log main;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# # redirect server error pages to the static page /40x.html
# #
# error_page 404 /404.html;
# location = /40x.html {
# }
# # redirect server error pages to the static page /50x.html
# #
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
同时检查下有没有include /etc/nginx/conf.d/*.conf这一项
重启nginx
service nginx restart
关闭selinux和iptables
4.下载supervisord来管理进程
yum install supervisor
设置为开机启动
chkconfig supervisord on
安装设置supervisor
chown -R nginx:nginx /usr/local/webvirtmgr
创建文件/etc/supervisord.d/webvirtmgr.ini
[program:webvirtmgr]
command=/usr/bin/python /usr/local/webvirtmgr/manage.py run_gunicorn -c /usr/local/webvirtmgr/conf/gunicorn.conf.py
directory=/usr/local/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=nginx
[program:webvirtmgr-console]
command=/usr/bin/python /usr/local/webvirtmgr/console/webvirtmgr-console
directory=/usr/local/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx
启动supervisord
supervisord -c /etc/supervisord.conf
看看可以不可以访问web和能否通过web端访问虚拟机
使用tcp方式添加远程node
在所有宿主机上修改
修改/etc/sysconfig/libvirtd,开启两个配置项
LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf
LIBVIRTD_ARGS="--listen
修改libvirt的配置文件
vim /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
listen_addr = "0.0.0.0"
auth_tcp = "none"
添加libvirt的用户zl
saslpasswd2 -a libvirt zl
查看存在的用户
sasldblistusers2 -f /etc/libvirt/passwd.db
删除存在的用户
saslpasswd2 -a libvirt -d zl
此时从另一台机器上访问就可以啦
virsh -c qemu+tcp://IP_address/system nodeinfo/list
从webvirtmgr端添加就ok啦。
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞1
添加新评论0 条评论