环境:
//关闭防火墙 [root@kvm ~]# systemctl stop firewalld [root@kvm ~]# vim /etc/selinux/config [root@kvm ~]# setenforce 0 setenforce: SELinux is disabled //配置桥接网络 [root@kvm ~]# nmcli connection add type bridge con-name br0 ifname br0 ipv4.addresses 192.168.72.131/24 ipv4.gateway 192.168.72.2 ipv4.dns 192.168.72.2 ipv4.method manual connection.autoconnect yes 连接 "br0" (dfa267d3-2db5-4747-bb99-b089dcd4c1b1) 已成功添加。 [root@kvm ~]# nmcli connection modify ens160 slave-type bridge master br0 connection.autoconnect yes [root@kvm ~]# systemctl restart NetworkManager [root@kvm ~]# nmcli connection down ens160;nmcli connection up ens160 [root@kvm ~]# ip a 1: lo:kvm web管理界面安装mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: mtu 1500 qdisc mq master br0 state UP group default qlen 1000 link/ether 00:0c:29:2e:a5:d7 brd ff:ff:ff:ff:ff:ff 3: br0: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:0c:29:2e:a5:d7 brd ff:ff:ff:ff:ff:ff inet 192.168.72.138/24 brd 192.168.72.255 scope global noprefixroute br0 valid_lft forever preferred_lft forever inet6 fe80::9ee9:87f6:6685:9252/64 scope link noprefixroute valid_lft forever preferred_lft forever [root@kvm ~]# //下载依赖包 [root@kvm ~]# yum -y install epel-release vim wget net-tools unzip zip gcc gcc-c++ //验证CPU是否支持KVM;如果结果中有vmx(Intel)或svm(AMD)字样,就说明CPU的支持的 [root@kvm ~]# egrep -o 'vmx|svm' /proc/cpuinfo vmx vmx vmx vmx //kvm安装 [root@kvm yum.repos.d]# yum -y install qemu-kvm qemu-kvm-common qemu-img virt-manager libvirt python3-libvirt libvirt-client virt-install virt-viewer libguestfs-tools //验证安装结果 [root@kvm ~]# lsmod|grep kvm kvm_intel 294912 0 kvm 786432 1 kvm_intel irqbypass 16384 1 kvm [root@kvm ~]# //测试并验证安装结果 [root@kvm ~]# virsh -c qemu:///system list Id 名称 状态 ---------------------------------------------------- [root@kvm ~]# virsh --version 4.5.0 [root@kvm ~]# virt-install --version 2.2.1 [root@kvm ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm [root@kvm ~]# ll /usr/bin/qemu-kvm lrwxrwxrwx. 1 root root 21 10月 20 01:04 /usr/bin/qemu-kvm -> /usr/libexec/qemu-kvm [root@kvm ~]# lsmod |grep kvm kvm_intel 294912 0 kvm 786432 1 kvm_intel irqbypass //查看网桥信息 [root@kvm ~]# brctl show bridge name bridge id STP enabled interfaces br0 8000.000c292ea5d7 yes ens160 virbr0 8000.525400618543 yes virbr0-nic
[root@kvm ~]# yum -y install git python3-pip python3-libvirt python3-libxml2 python3-websocket-client supervisor nginx python36-devel //从github上下载webvirtmgr代码 [root@kvm ~]# cd /usr/local/src/ [root@kvm src]# git clone git://github.com/retspen/webvirtmgr.git 正克隆到 'webvirtmgr'... //安装webvirtmgr [root@kvm src]# cd webvirtmgr/ [root@kvm webvirtmgr]# pip2 install -r requirements.txt //检查sqlite3是否安装 [root@kvm webvirtmgr]# ln -s /usr/bin/python2 /usr/bin/python [root@kvm webvirtmgr]# env python Python 2.7.18 (default, Jan 29 2021, 18:19:04) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> exit() [root@kvm webvirtmgr]# //初始化帐号信息 [root@kvm 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'): Email address: 1@2.com Password: Password (again): Superuser created successfully. Installing custom SQL ... Installing indexes ... Installed 6 object(s) from 1 fixture(s) [root@kvm webvirtmgr]# //拷贝web网页至指定目录 [root@kvm ~]# mkdir /var/www [root@kvm ~]# cp -r /usr/local/src/webvirtmgr /var/www/ [root@kvm ~]# chown -R nginx.nginx /var/www/webvirtmgr/ [root@kvm ~]# //生成密钥 [root@kvm ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:ObOqqW0Oc6gNxwOELvzqShREcKFvCPyj2ETzCBG0C6E root@kvm The key's randomart image is: +---[RSA 3072]----+ |O=o. | |==. | |E=o | |*=++ . | |+==o. S | |+*o.. + | |ooO.. . | |.=.*.. . | |=oo+=.. | +----[SHA256]-----+ [root@kvm ~]# ssh-copy-id 192.168.72.138 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '192.168.72.138 (192.168.72.138)' can't be established. ECDSA key fingerprint is SHA256:EczzC1cmnInKnDJezHx/wuaazyzEdTIrbIIDkqOkqLc. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@192.168.72.138's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh '192.168.72.138'" and check to make sure that only the key(s) you wanted were added. [root@kvm ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 32 192.168.122.1:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 0.0.0.0:111 0.0.0.0:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 128 [::]:111 [::]:* [root@kvm ~]# //配置端口转发 [root@kvm ~]# ssh 192.168.72.138 -L localhost:8000:localhost:8000 -L localhost:6080:localhost:60 Last login: Wed Oct 20 02:13:24 2021 from 192.168.72.1 [root@kvm ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 32 192.168.122.1:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 127.0.0.1:6080 0.0.0.0:* LISTEN 0 128 127.0.0.1:8000 0.0.0.0:* LISTEN 0 128 0.0.0.0:111 0.0.0.0:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 128 [::1]:6080 [::]:* LISTEN 0 128 [::1]:8000 [::]:* LISTEN 0 128 [::]:111 [::]:* [root@kvm ~]# //配置nginx [root@kvm ~]# vim /etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; 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; include /etc/nginx/conf.d/*.conf; server { listen 80; server_name localhost; include /etc/nginx/default.d/*.conf; location / { root html; index index.html index.htm; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } } [root@kvm ~]# 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; } } //确保bind绑定的是本机的8000端口 [root@kvm ~]# vim /var/www/webvirtmgr/conf/gunicorn.conf.py .....此处省略N行 bind = '0.0.0.0:8000' //确保此处绑定的是本机的8000端口,这个在nginx配置中定义了,被代理的端口 backlog = 2048 //重启nginx [root@kvm ~]# systemctl restart nginx [root@kvm ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 32 192.168.122.1:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 127.0.0.1:6080 0.0.0.0:* LISTEN 0 128 127.0.0.1:8000 0.0.0.0:* LISTEN 0 128 0.0.0.0:111 0.0.0.0:* LISTEN 0 128 0.0.0.0:80 0.0.0.0:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 128 [::1]:6080 [::]:* LISTEN 0 128 [::1]:8000 [::]:* LISTEN 0 128 [::]:111 [::]:* [root@kvm ~]# //设置supervisor [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并设置开机自启 [root@kvm ~]# systemctl start supervisord [root@kvm ~]# systemctl enable supervisord Created symlink /etc/systemd/system/multi-user.target.wants/supervisord.service → /usr/lib/systemd/system/supervisord.service. [root@kvm ~]# systemctl status supervisord ● supervisord.service - Process Monitoring a> Loaded: loaded (/usr/lib/systemd/system/s> Active: active (running) since Wed 2021-1> Main PID: 170059 (supervisord) Tasks: 2 (limit: 23789) Memory: 39.5M CGroup: /system.slice/supervisord.service ├─170059 /usr/bin/python3.6 /usr/> └─170300 /usr/bin/python2 /var/ww> 10月 20 02:32:05 kvm systemd[1]: Starting Pr> 10月 20 02:32:05 kvm systemd[1]: Started Pro> [root@kvm ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 32 192.168.122.1:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 127.0.0.1:6080 0.0.0.0:* LISTEN 0 128 127.0.0.1:8000 0.0.0.0:* LISTEN 0 128 0.0.0.0:111 0.0.0.0:* LISTEN 0 128 0.0.0.0:80 0.0.0.0:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 128 [::1]:6080 [::]:* LISTEN 0 128 [::1]:8000 [::]:* LISTEN 0 128 [::]:111 [::]:* [root@kvm ~]# //配置nginx用户 [root@kvm ~]# su - nginx 上一次登录:三 10月 20 02:34:23 EDT 2021pts/0 上 This account is currently not available. [root@kvm ~]# su - nginx -s /bin/bash 上一次登录:三 10月 20 02:34:53 EDT 2021pts/0 上 [nginx@kvm ~]$ 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:LJHgpsLYYaKk55g15GzqggH9zHo0GtMNtlYJwgsN7tg nginx@kvm The key's randomart image is: +---[RSA 3072]----+ |.+ . | |o +... . | |.=+oo.o. | |XOo+o oo | |BoE* =. S | |.Xo.X .. | |=..B . | |+ o . | |.. . | +----[SHA256]-----+ [nginx@kvm ~]$ touch ~/.ssh/config && echo -e "StrictHostKeyChecking=nonUserKnownHostsFile=/dev/null" >> ~/.ssh/config [nginx@kvm ~]$ chmod 0600 ~/.ssh/config [nginx@kvm ~]$ ssh-copy-id root@192.168.72.138 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/var/lib/nginx/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/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.72.138' (ECDSA) to the list of known hosts. root@192.168.72.138's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@192.168.72.138'" and check to make sure that only the key(s) you wanted were added. [nginx@kvm ~]$ [root@kvm ~]# vim /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla [Remote libvirt SSH access] Identity=unix-user:root Action=org.libvirt.unix.manage ResultAny=yes ResultInactive=yes ResultActive=yes [root@kvm ~]# vim /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla [root@kvm ~]# chown -R root.root /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla [root@kvm ~]# systemctl restart nginx [root@kvm ~]# systemctl restart libvirtd [root@kvm ~]#
访问
[root@kvm ~]# cd /var/lib/libvirt/images/ [root@kvm images]# ls CentOS-7-x86_64-DVD-1804-7.5.iso [root@kvm images]#
添加第二台主机
[root@web ~]# hostnamectl set-hostname kvm2 [root@web ~]# bash [root@kvm2 ~]# cd /etc/yum.repos.d/ [root@kvm2 yum.repos.d]# ls epel-modular.repo epel.repo epel-testing.repo xx.repo epel-playground.repo epel-testing-modular.repo redhat.repo [root@kvm2 yum.repos.d]# mount /dev/cdrom /mnt/ mount: /mnt: WARNING: device write-protected, mounted read-only. [root@kvm2 yum.repos.d]# cd [root@kvm2 ~]# cd /etc/sysconfig/network-scripts/ [root@kvm2 network-scripts]# ls ifcfg-ens160 [root@kvm2 network-scripts]# cp ifcfg-ens160 ifcfg-br0 [root@kvm2 network-scripts]# vim ifcfg-br0 [root@kvm2 network-scripts]# vi ifcfg-br0 [root@kvm2 network-scripts]# vi ifcfg-ens160 [root@kvm2 network-scripts]# yum -y install qemu-kvm qemu-kvm-tools qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils libguestfs-tools Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 上次元数据过期检查:17:10:42 前,执行于 2021年10月20日 星期三 04时25分09秒。 软件包 qemu-kvm-15:2.12.0-99.module+el8.2.0+5827+8c39933c.x86_64 已安装。 No match for argument: qemu-kvm-tools 软件包 qemu-img-15:2.12.0-99.module+el8.2.0+5827+8c39933c.x86_64 已安装。 软件包 virt-manager-2.2.1-3.el8.noarch 已安装。 软件包 libvirt-4.5.0-42.module+el8.2.0+6024+15a2423f.x86_64 已安装。 No match for argument: libvirt-python 软件包 libvirt-client-4.5.0-42.module+el8.2.0+6024+15a2423f.x86_64 已安装。 软件包 virt-install-2.2.1-3.el8.noarch 已安装。 软件包 virt-viewer-7.0-9.el8.x86_64 已安装。 软件包 libguestfs-tools-1:1.38.4-15.module+el8.2.0+5297+222a20af.noarch 已安装。 错误:没有任何匹配: qemu-kvm-tools libvirt-python [root@kvm2 network-scripts]# yum -y install qemu-kvm qemu-kvm-common qemu-img virt-manager libvirt python3-libvirt libvirt-client virt-install virt-viewer bridge-utils libguestfs-tools Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 上次元数据过期检查:17:11:26 前,执行于 2021年10月20日 星期三 04时25分09秒。 软件包 qemu-kvm-15:2.12.0-99.module+el8.2.0+5827+8c39933c.x86_64 已安装。 软件包 qemu-kvm-common-15:2.12.0-99.module+el8.2.0+5827+8c39933c.x86_64 已安装。 软件包 qemu-img-15:2.12.0-99.module+el8.2.0+5827+8c39933c.x86_64 已安装。 软件包 virt-manager-2.2.1-3.el8.noarch 已安装。 软件包 libvirt-4.5.0-42.module+el8.2.0+6024+15a2423f.x86_64 已安装。 软件包 python3-libvirt-4.5.0-2.module+el8.1.0+4066+0f1aadab.x86_64 已安装。 软件包 libvirt-client-4.5.0-42.module+el8.2.0+6024+15a2423f.x86_64 已安装。 软件包 virt-install-2.2.1-3.el8.noarch 已安装。 软件包 virt-viewer-7.0-9.el8.x86_64 已安装。 软件包 libguestfs-tools-1:1.38.4-15.module+el8.2.0+5297+222a20af.noarch 已安装。 依赖关系解决。 ========================================================================================================= 软件包 架构 版本 仓库 大小 ========================================================================================================= 安装: bridge-utils x86_64 1.7.1-2.el8 epel 40 k 事务概要 ========================================================================================================= 安装 1 软件包 总下载:40 k 安装大小:61 k 下载软件包: bridge-utils-1.7.1-2.el8.x86_64.rpm 126 kB/s | 40 kB 00:00 --------------------------------------------------------------------------------------------------------- 总计 7.5 kB/s | 40 kB 00:05 运行事务检查 事务检查成功。 运行事务测试 事务测试成功。 运行事务 准备中 : 1/1 安装 : bridge-utils-1.7.1-2.el8.x86_64 1/1 运行脚本: bridge-utils-1.7.1-2.el8.x86_64 1/1 验证 : bridge-utils-1.7.1-2.el8.x86_64 1/1 Installed products updated. 已安装: bridge-utils-1.7.1-2.el8.x86_64 完毕! [root@kvm2 network-scripts]# yum -y install vim wget net-tools unzip zip gcc gcc-c++ Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 上次元数据过期检查:17:11:55 前,执行于 2021年10月20日 星期三 04时25分09秒。 软件包 vim-enhanced-2:8.0.1763-13.el8.x86_64 已安装。 软件包 wget-1.19.5-8.el8_1.1.x86_64 已安装。 软件包 net-tools-2.0-0.51.20160912git.el8.x86_64 已安装。 软件包 unzip-6.0-43.el8.x86_64 已安装。 软件包 zip-3.0-23.el8.x86_64 已安装。 软件包 gcc-8.3.1-5.el8.x86_64 已安装。 软件包 gcc-c++-8.3.1-5.el8.x86_64 已安装。 依赖关系解决。 无需任何处理。 完毕! [root@kvm2 network-scripts]# ip a 1: lo:mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:2e:a5:d7 brd ff:ff:ff:ff:ff:ff inet 192.168.72.138/24 brd 192.168.72.255 scope global dynamic noprefixroute ens160 valid_lft 1482sec preferred_lft 1482sec inet6 fe80::2d22:fc96:1bdb:33f4/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: virbr0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:2d:79:02 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 4: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:2d:79:02 brd ff:ff:ff:ff:ff:ff [root@kvm2 network-scripts]# systemctl restart NetworkManager [root@kvm2 network-scripts]# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:2e:a5:d7 brd ff:ff:ff:ff:ff:ff inet 192.168.72.138/24 brd 192.168.72.255 scope global dynamic noprefixroute ens160 valid_lft 1463sec preferred_lft 1463sec inet6 fe80::2d22:fc96:1bdb:33f4/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: virbr0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:2d:79:02 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 4: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:2d:79:02 brd ff:ff:ff:ff:ff:ff 5: br0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 0a:91:4a:6b:7b:b4 brd ff:ff:ff:ff:ff:ff inet 192.168.72.138/24 brd 192.168.72.255 scope global noprefixroute br0 valid_lft forever preferred_lft forever [root@kvm2 network-scripts]# reboot 连接断开 连接成功 Last login: Wed Oct 20 21:32:22 2021 from 192.168.72.1 [root@kvm2 ~]# [root@kvm2 ~]# [root@kvm2 ~]# [root@kvm2 ~]# [root@kvm2 ~]# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: mtu 1500 qdisc mq master br0 state UP group default qlen 1000 link/ether 00:0c:29:2e:a5:d7 brd ff:ff:ff:ff:ff:ff 3: br0: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:0c:29:2e:a5:d7 brd ff:ff:ff:ff:ff:ff inet 192.168.72.138/24 brd 192.168.72.255 scope global noprefixroute br0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe2e:a5d7/64 scope link valid_lft forever preferred_lft forever 4: virbr0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:2d:79:02 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:2d:79:02 brd ff:ff:ff:ff:ff:ff [root@kvm2 ~]# systemctl start libvirtd [root@kvm2 ~]# systemctl enable libvirtd [root@kvm2 ~]# lsmod|grep kvm kvm_intel 294912 0 kvm 786432 1 kvm_intel irqbypass 16384 1 kvm [root@kvm2 ~]# virsh -c qemu:///system list Id 名称 状态 ---------------------------------------------------- [root@kvm2 ~]# virsh --version 4.5.0 [root@kvm2 ~]# virt-install --version 2.2.1 [root@kvm2 ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm [root@kvm2 ~]# ll /usr/bin/qemu-kvm lrwxrwxrwx 1 root root 21 10月 20 21:39 /usr/bin/qemu-kvm -> /usr/libexec/qemu-kvm [root@kvm2 ~]# brctl show bridge name bridge id STP enabled interfaces br0 8000.000c292ea5d7 no ens160 virbr0 8000.5254002d7902 yes virbr0-nic [root@kvm2 ~]# getenforce Disabled [root@kvm2 ~]# systemctl restart libvirtd [root@kvm2 ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:111 0.0.0.0:* LISTEN 0 32 192.168.122.1:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 [::]:111 [::]:* LISTEN 0 128 [::]:22 [::]:* [root@kvm2 ~]# systemctl stop firewalld [root@kvm2 ~]# setenforce 0 setenforce: SELinux is disabled [root@kvm2 ~]# cd /var/lib/libvirt/images [root@kvm2 images]#
web
[root@web ~]# ssh-copy-id root@192.168.72.138 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '192.168.72.138 (192.168.72.138)' can't be established. ECDSA key fingerprint is SHA256:EczzC1cmnInKnDJezHx/wuaazyzEdTIrbIIDkqOkqLc. ECDSA key fingerprint is MD5:ef:6c:6c:72:ad:fe:86:ec:ab:14:2e:95:97:83:cc:4a. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@192.168.72.138's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@192.168.72.138'" and check to make sure that only the key(s) you wanted were added. [root@web ~]# su - nginx -s /bin/bash 上一次登录:三 10月 20 21:25:05 CST 2021pts/0 上 -bash-4.2$ ssh-copy-id root@192.168.72.138 /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.72.138' (ECDSA) to the list of known hosts. root@192.168.72.138's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@192.168.72.138'" and check to make sure that only the key(s) you wanted were added. -bash-4.2$ exit 登出 [root@web ~]# systemctl restart nginx [root@web ~]# systemctl restart supervisord
在web界面添加
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)