请直接去网盘下载安装说明文档,下面的缺乏图片,下载后可以直接安装
百度网盘:
[链接:https://pan.baidu.com/s/12W_AnM9GZ8I6qkwc_8IOXQ
提取码:1234
设备:Centos7服务器
网络:可访外网
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cmShyDHB-1654595487562)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps1.jpg)]
部署前请确保你的CPU虚拟化功能已开启。分为两种情况:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-88om88hH-1654595487564)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps2.png)]虚拟机要关机设置CPU虚拟化
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VnQtIGNZ-1654595487564)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps3.png)]物理机要在BIOS里开启CPU虚拟化
验证方式:
cat /proc/cpuinfo | egrep 'vmx|svm'
结果:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-h19PITQG-1654595487565)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps4.jpg)]
如果结果有过滤出vmx或者svm的关键字代表支持虚拟化,vmx是Intel的CPU,svm是 AMD的CPU。
查看是否已加载kvm
lsmod | grep kvm
# 若未加载则执行
modprobe kvm
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zIRz1wpU-1654595487565)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps5.jpg)]
关闭selinux
避免后续出现各种问题,如果可以则也可关闭防火墙
查看状态
getenforce
下图为已开启
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yej7jH15-1654595487566)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps6.jpg)]
# 临时关闭
setenforce 0
# 永久关闭(需要重启)
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
将准备好的文件 CentOS7-Base-163.repo 上传至/etc/yum.repos.d/ ,为的是安装python-pip依赖
结果如下:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-c7g2yLpi-1654595487566)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps7.jpg)]
更新yum源
yum clean all
yum makecache
结果:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0TK1q0Pk-1654595487566)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps8.jpg)]
安装kvm依赖
yum -y install epel-release.noarchyum -y install qemu-kvm qemu-kvm-tools qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils libguestfs-tools
检查依赖是否正确
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-BnNo7o7I-1654595487566)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps9.jpg)]
查看网卡
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZSqhhvtK-1654595487567)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps10.jpg)]
当前使用的是ens33
复制ens33为 br0 为后期虚拟网卡做准备
cd /etc/sysconfig/network-scripts/
cp ifcfg-ens33 ifcfg-br0
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PppTKGB1-1654595487567)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps11.jpg)]
修改ifcfg-br0为以下内容:
TYPE=Bridge
BOOTPROTO=static
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=10.0.1.207
PREFIX=24
GATEWAY=10.0.1.1
DNS1=114.114.114.114
修改ifcfg-ens33为:
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
BRIDGE=br0
NM_CONTROLLED=no
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AErz14TF-1654595487567)(C:\Users\lenovo\AppData\Roaming\Typora\typora-user-images\image-20220607160458884.png)]
重启网络
systemctl restart network
查看网络状况
ip a
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-4AsczF7h-1654595487568)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps13.jpg)]
启动服务 libvirtd
systemctl enable --now libvirtd
做软连接
[root@kvm network-scripts]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
[root@kvm network-scripts]# ll /usr/bin/qemu-kvm
结果如下:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-4YMmHgNo-1654595487568)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps14.jpg)]
##注意centos7和8上安装的包名有差异
yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx python-devel
将准备好的webvirtmgr-master.zip 上传至 /usr/local/src/ 解压,文件夹webvirtmgr-master改为webvirtmgr
cd /usr/local/src/
unzip webvirtmgr-master.zip
mv webvirtmgr-master webvirtmgr
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2Cs0nVxW-1654595487568)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps15.jpg)]
cd webvirtmgr/
pip install -i https://pypi.douban.com/simple -r requirements.txt 或者 pip install -r requirements.txt
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-mgfsBl9T-1654595487569)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps16.jpg)]
检查sqlite3是否安装
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZKL39Rvd-1654595487569)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps17.jpg)]
初始化账号
./manage.py syncdb
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3Md9wVbl-1654595487569)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps18.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-H2wF6UCJ-1654595487569)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps19.jpg)]
[root@kvm webvirtmgr]# mkdir /var/www
[root@kvm webvirtmgr]# cp -r /usr/local/src/webvirtmgr /var/www/
[root@kvm webvirtmgr]# chown -R nginx.nginx /var/www/webvirtmgr/
[root@kvm webvirtmgr]# ll /var/www/
总用量 4
drwxr-xr-x. 19 nginx nginx 4096 6月 7 14:30 webvirtmgr
ssh-keygen -t rsa
ssh-copy-i ip地址
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-7v9bhXVd-1654595487570)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps20.jpg)]
ssh 10.0.1.207 -L localhost:8000:localhost:8000 -L localhost:6080:localhost:60
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NbZc2FK8-1654595487570)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps21.jpg)]
vi /etc/nginx/nginx.conf
修改为一下内容
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user root; # 如果不是公有云,将 user 改为 root,否则需要花费大量时间解决权限问题。
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
# 注释掉该文件中的所有 server 配置,注意不要误将最后一个 } 注释掉了
# server {
# listen 80 default_server;
# listen [::]:80 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
配置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;
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 $remote_addr;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
client_max_body_size 1024M;
}
}
启动nginx 并加入自启动
[root@kvm ~]# systemctl restart nginx.service
[root@kvm ~]# systemctl enable nginx.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@kvm ~]#
[root@kvm ~]# vim /etc/supervisord.conf
##在最下面加入
[program:webvirtmgr]
command=/usr/bin/python2 /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/python2 /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
##重启supervisor
systemctl restart supervisord.service
systemctl enable supervisord.service
ss -antl
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LwfabMIo-1654595487570)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps22.jpg)]
[root@kvm ~]# su - nginx -s /bin/bash
-bash-4.2$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/nginx/.ssh/id_rsa):
Created directory '/var/lib/nginx/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/lib/nginx/.ssh/id_rsa.
Your public key has been saved in /var/lib/nginx/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:M+HR5xKs4wmYOFyfzvOJmridq/5cEYIOh81LkvnQA/Q nginx@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|o. |
| O.. o |
|B OEo . o + . |
| X = = + + + |
| B o = S . . |
| . o + = . |
| = o |
| + + + . |
| .=+Oo. o |
+----[SHA256]-----+
-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@192.168.10.100
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/var/lib/nginx/.ssh/id_rsa.pub"
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Warning: Permanently added '192.168.10.100' (ECDSA) to the list of known hosts.
root@192.168.10.100's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.10.100'"
and check to make sure that only the key(s) you wanted were added.
-bash-4.2$ exit
logout
[root@localhost ~]#
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6Sp9Divw-1654595487571)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps23.jpg)]
[root@kvm~]# systemctl restart nginx.service
[root@kvm~]# systemctl restart supervisord.service
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-5bqZUVqP-1654595487571)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps24.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VWBHj0TC-1654595487571)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps25.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1082TPWo-1654595487571)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps26.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1ZEPIFTq-1654595487572)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps27.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-74nrrCGm-1654595487572)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps28.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-g4kWNpNT-1654595487572)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps29.jpg)]
CentOS-7-x86_64-DVD-2009.iso
将镜像源上传至 /var/lib/libvirt/images
这里我使用ftp上传
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-N34k0oRm-1654595487572)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps30.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-lZqCHqgK-1654595487573)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps31.jpg)]
添加虚拟机镜像(就是虚拟机存储所有信息的区,一台虚拟化一个区)
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-5q6oynN7-1654595487573)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps32.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NMlzPRSB-1654595487574)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps33.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ogZFQJoh-1654595487574)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps34.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nTz0xhWH-1654595487574)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps35.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sZpGVyig-1654595487574)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps36.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-BYRkwGV8-1654595487575)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps37.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-dl3v97Ha-1654595487575)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps38.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RrnspqWN-1654595487575)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps39.jpg)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1afXFcAv-1654595487575)(file:///C:\Users\lenovo\AppData\Local\Temp\ksohtml11056\wps40.jpg)]
es
这里我使用ftp上传
[外链图片转存中…(img-N34k0oRm-1654595487572)]
[外链图片转存中…(img-lZqCHqgK-1654595487573)]
添加虚拟机镜像(就是虚拟机存储所有信息的区,一台虚拟化一个区)
[外链图片转存中…(img-5q6oynN7-1654595487573)]
[外链图片转存中…(img-NMlzPRSB-1654595487574)]
[外链图片转存中…(img-ogZFQJoh-1654595487574)]
[外链图片转存中…(img-nTz0xhWH-1654595487574)]
[外链图片转存中…(img-sZpGVyig-1654595487574)]
[外链图片转存中…(img-BYRkwGV8-1654595487575)]
[外链图片转存中…(img-dl3v97Ha-1654595487575)]
[外链图片转存中…(img-RrnspqWN-1654595487575)]
[外链图片转存中…(img-1afXFcAv-1654595487575)]