centos虚拟化管理平台WebVirtMgr部署

1.1、安装依赖包

[root@bogon ]# yum install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx -y
1.2、从git-hub中下载相关的webvirtmgr代码
[root@bogon ]# cd /usr/local/src/
[root@bogon ]# git clone git://github.com/retspen/webvirtmgr.git
1.3、安装webvirtmgr
[root@bogon ]# cd webvirtmgr/
[root@bogon webvirtmgr]# pip install -r requirements.txt
如果pip没有安装 ,先安装一下
首先安装epel扩展源:
  yum -y install epel-release
  更新完成之后,就可安装pip:
  yum -y install python-pip
1.4、检查sqlite3 (备注:自带不需要安装,导入模块检查一下。)
[root@bogon webvirtmgr]# python
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import sqlite3
exit()

1.5、初始化账号
[root@bogon webvirtmgr]# pwd
/usr/local/src/webvirtmgr
[root@bogon webvirtmgr]# ./manage.py syncdb
WARNING:root:No local_settings file found.
Creating tables …
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table servers_compute
Creating table instance_instance
Creating table create_flavor

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’): admin
Email address: 12345678@qq.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL …
Installing indexes …
Installed 6 object(s) from 1 fixture(s)
1.6、拷贝web到 相关目录
[root@bogon webvirtmgr]# mkdir -pv /var/www
[root@bogon webvirtmgr]# cp -Rv /usr/local/src/webvirtmgr /var/www/webvirtmgr
1.7、设置ssh
[root@bogon webvirtmgr]# ssh-keygen -t rsa //产生公私钥
[root@bogon webvirtmgr]# ssh-copy-id 192.168.168.139 //由于这里webvirtmgr和kvm服务部署在同一台机器,所以这里本地信任。如果kvm部署在其他机器,那么这个是它的ip
[root@bogon webvirtmgr]# ssh 192.168.168.139 -L localhost:8000:localhost:8000 -L localhost:6080:localhost:60
1.8、编辑nginx配置文件(如果没有nignx,先安装,)
#添加这行代码: include /etc/nginx/conf.d/*.conf;
[root@bogon etc]# cd /etc/nginx/
[root@bogon nginx]# mv nginx.conf /tmp
[root@bogon nginx]# cp nginx.conf.default nginx.conf
#编辑配置文件
[root@bogon nginx]# cd /etc/nginx/
[root@bogon nginx]# vi nginx.conf
[root@bogon nginx]# cat nginx.conf

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
#log_format main '$remote_addr - r e m o t e u s e r [ remote_user [ remoteuser[time_local] “KaTeX parse error: Expected 'EOF', got '#' at position 16: request" ' #̲ …status b o d y b y t e s s e n t " body_bytes_sent " bodybytessent"http_referer” ’
# ‘“ h t t p u s e r a g e n t " " http_user_agent" " httpuseragent""http_x_forwarded_for”’;

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}


# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

}
#添加 /etc/nginx/conf.d/webvirtmgr.conf 配置文件
[root@bogon nginx]# vi /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 h o s t : host: host:server_port;
proxy_set_header X-Forwarded-Proto $remote_addr;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
client_max_body_size 1024M; # Set higher depending on your needs
}
}
#重启nginx服务
systemctl restart nginx
1.9、修改防火墙规则
#修改防火墙规则
[root@ops ~]# vim /etc/sysconfig/selinux

SELINUX=disabled

#临时生效
[root@ops ~]# setenforce 0
setenforce: SELinux is disabled

#查看状态
[root@ops ~]# getenforce
Disabled

#直接执行这行
/usr/sbin/setsebool httpd_can_network_connect true
2.0、授权
[root@bogon nginx]# chown -R nginx:nginx /var/www/webvirtmgr
2.1、设置 supervisor (如果iptables防火墙开启的话,就必须要开通80、8000、6080端口访问)
[root@bogon nginx]# vi /etc/supervisord.conf
[program:webvirtmgr]
command=/usr/bin/python2 /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py //启动8000端口
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/python2 /var/www/webvirtmgr/console/webvirtmgr-console //启动6080端口(这是控制台vnc端口)
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx
#检查
[root@bogon nginx]# cat /var/www/webvirtmgr/conf/gunicorn.conf.py //确保下面bind绑定的是本机的8000端口,这个在nginx配置中定义了,被代理的端口
bind = ‘127.0.0.1:8000’
#设置开机启动
#如果提示supervisor未安装重新安装,[root@bogon ~]# yum -y install supervisor
[root@bogon ~]# systemctl enable supervisord.service
#设置开机加载

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在CentOS 7上进行KVM虚拟化部署,可以按照以下步骤进行操作: 1. 首先,部署KVM环境。这可以通过安装libvirt、virt和qemu-kvm等软件包来实现。 2. 将CentOS 7的ISO镜像拉入宿主机。这可以通过将ISO镜像文件复制到宿主机上的任意位置来完成。 3. 使用VMM GUI或命令行工具(如virt-install)创建KVM虚拟机。在创建虚拟机时,需要指定虚拟机的名称、内存大小、CPU数量和磁盘路径等参数。 4. 确保虚拟机的网络使用桥接模式,这样虚拟机可以与宿主机和其他虚拟机进行通信。 5. 可以在虚拟机关机状态下创建快照,以便在需要时可以恢复到该状态。这可以通过VMM GUI或命令行工具来完成。 需要注意的是,虚拟机的定义文件通常存储在`/etc/libvirt/qemu/`目录中。如果需要克隆虚拟机,可以复制定义文件并进行相应的修改。 总结起来,CentOS 7 KVM虚拟化部署的步骤包括:部署KVM环境、拉入ISO镜像、创建虚拟机、配置网络和创建快照。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [CentOS部署kvm虚拟化机器](https://blog.csdn.net/weixin_45052781/article/details/125988357)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [Centos7 安装KVM](https://blog.csdn.net/justlpf/article/details/126720554)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值