kvmweb管理工具_KVM web管理工具——WebVirtMgr(一)
一 webvirtmgr管理服務(wù)器配置
1 install ?epel 源,git,gcc等軟件
sudo yum -y install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
sudo yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
2 Install python requirements and setup Django environment
git clone git://github.com/retspen/webvirtmgr.git
cd webvirtmgr
sudo pip install -r requirements.txt
./manage.py syncdb
./manage.py collectstatic ? ?---配置數(shù)據(jù)庫(kù)的賬號(hào)
創(chuàng)建一個(gè)超級(jí)用戶:
./manage.py createsuperuser ? --配置webvirtmgr 登錄賬號(hào)
3 配置nginx
cd ..
sudo mv webvirtmgr /var/www/
在 /etc/nginx/conf.d/下 創(chuàng)建webvirtmgr.conf 文件:
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 $scheme;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
client_max_body_size 1024M; # Set higher depending on your needs
}
}
在nginx主配置文件中的http域內(nèi)添加下面的配置
sudo vim /etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf;
將default.conf重命名
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
重啟nginx:
sudo service nginx restart ? 或者 ? ?/etc/init.d/nginx restart
selinux 設(shè)置:
將selinux 關(guān)閉
setenforce 0
vim /etc/selinux/config
SELINUX=disabled
或不關(guān)閉selinux但需添加下面的策略
/usr/sbin/setsebool httpd_can_network_connect true
4 配置 Supervisor
sudo ?chkconfig supervisord on
在/etc/supervisord.conf末尾加入下面的配置:
vim /etc/supervisord.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
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
重啟supervisord
sudo service supervisord restart
--------到這里webvirtmgr配置完成-----
二 webvirtmgr服務(wù)器(服務(wù)端)與kvm服務(wù)器(客服端)連接配置
1)webvirtmgr與kvm之間使用ssh方式連接管理
1 在webvirtmgr服務(wù)器(服務(wù)端)上:
cd /home/
mkdir nginx
chown nginx.nginx nginx/
chmod 700 nginx/ -R
su - nginx -s /bin/bash
ssh-keygen ? ---期間輸入yes后直接回車,回車
touch ~/.ssh/config && echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> ~/.ssh/config
chmod 0600 ~/.ssh/config
2 在kvm(客服端)服務(wù)器上配置webvirt用戶
useradd webvirtmgr
echo "123456" | passwd --stdin webvirtmgr
groupadd libvirt
usermod -G libvirt -a webvirtmgr
3 在webvirtmgr服務(wù)器(服務(wù)端)上,將ssh-key上傳到kvm服務(wù)器上
su - nginx -s /bin/bash
ssh-copy-id ? webvirtmgr@192.168.0.23
4 在kvm(客服端)服務(wù)器上配置 libvirt ssh授權(quán)
vim /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
[Remote libvirt SSH access]
Identity=unix-user:webvirtmgr
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes
chown -R webvirtmgr.webvirtmgr /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
重啟 libvirtd 服務(wù)
/etc/init.d/libvirtd restart
2)webvirtmgr與kvm之間使用tcp方式連接管理
1)Libvirtd服務(wù)監(jiān)聽配置
修改/etc/sysconfig/libvirtd文件,去掉下面一行的注釋,使Libvirt服務(wù)處于監(jiān)聽狀態(tài):
vim /etc/sysconfig/libvirtd
LIBVIRTD_ARGS="--listen"
2)配置Libvirt服務(wù)
配置Libvirt服務(wù),允許通過tcp方式通訊,修改/etc/libvirt/libvirtd.conf:
#允許tcp監(jiān)聽
listen_tcp = 1
#開放tcp端口
tcp_port = "16509"
#監(jiān)聽地址修改為0.0.0.0
listen_addr = "0.0.0.0"
#配置tcp通過sasl認(rèn)證
auth_tcp = sasl
#取消CA認(rèn)證功能
listen_tls = 0
啟動(dòng)服務(wù):
service libvirtd start
3)創(chuàng)建libvirt管理用戶
saslpasswd2 -a libvirt admin
總結(jié)
以上是生活随笔為你收集整理的kvmweb管理工具_KVM web管理工具——WebVirtMgr(一)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 开发管理 CheckLists(1) -
- 下一篇: 一个初学者困惑的Oracle的认证问题