当前位置:网站首页>kvm部署
kvm部署
2022-08-02 12:11:00 【沐辰晨兮】
环境说明:
IP:192.168.149.10
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[[email protected] ~]# setenforce 0
[[email protected] ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[[email protected] ~]# curl -o /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
[[email protected] ~]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[[email protected] ~]# sed -i 's/^enabled=.*/enabled=1/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[[email protected] ~]# yum -y install epel-release vim wget net-tools unzip zip gcc gcc-c++

验证CPU是否支持KVM;如果结果中有vmx(Intel)或svm(AMD)字样,就说明CPU的支持的
egrep -o 'vmx|svm' /proc/cpuinfo
//kvm安装
[[email protected] ~]# 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

//启动服务 并检查服务信息
[[email protected] ~]# systemctl start libvirtd
[[email protected] ~]# systemctl enable libvirtd
[[email protected] ~]# lsmod|grep kvm
[[email protected] ~]# virsh -c qemu:///system list
[[email protected]calhost ~]# virsh --version
[[email protected] ~]# virt-install --version
[[email protected] ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
[[email protected] ~]# ll /usr/bin/qemu-kvm
[[email protected] ~]# lsmod |grep kvm
[[email protected] ~]# brctl show

Web界面安装
[[email protected] ~]# yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx python-devel
//从github上下载webvirtmgr代码

[[email protected] ~]# cd /usr/local/src/
[[email protected] src]# git clone git://github.com/retspen/webvirtmgr.git
安装webvirtmgr //检查sqlite3是否安装
[[email protected] src]# cd webvirtmgr/
[[email protected] webvirtmgr]# pip install -r requirements.txt
[[email protected] webvirtmgr]# python
Python 2.7.5 (default, Nov 16 2020, 22:23:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> exit()

/初始化帐号信息
[[email protected] webvirtmgr]# python 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'): //指定超级管理员帐号用户名,默认留空为root
Email address: [email protected] //设置超级管理员邮箱
Password:1 //设置超级管理员密码
Password (again):1 //再次输入超级管理员密码
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 6 object(s) from 1 fixture(s)

//拷贝web网页至指定目录
并做免密登录
[[email protected] webvirtmgr]# mkdir /var/www
[[email protected] webvirtmgr]# cp -r /usr/local/src/webvirtmgr/ /var/www/
[[email protected] webvirtmgr]# chown -R nginx.nginx /var/www/webvirtmgr/
[[email protected] webvirtmgr]# ssh-keygen -t rsa
[[email protected] webvirtmgr]# ssh-copy-id 192.168.149.10

//端口转发
[[email protected] webvirtmgr]# ssh 192.168.149.10 -L localhost:8000:localhost:8000 -L localhost:6080:localhost:60
[[email protected] ~]# ss -antl
//配置nginx
[[email protected] ~]# vim /etc/nginx/nginx.conf
文件41行修改内容为localhost
[[email protected] ~]# vim /etc/nginx/conf.d/webvirtmgr.conf
修改配置文件 在其中添加以下内容

[[email protected] ~]# vim /var/www/webvirtmgr/conf/gunicorn.conf.py
查看即可 无需修改

//重启nginx
[[email protected] ~]# systemctl start nginx
[[email protected] ~]# ss -antl

//设置supervisor
[[email protected] ~]# vim /etc/supervisord.conf 注意:需对齐到文件最前面

//启动supervisor并设置开机自动启动
[[email protected] ~]# systemctl start supervisord
[[email protected] ~]# systemctl enable supervisord
[[email protected] ~]# systemctl status supervisord
//配置nginx用户
[[email protected] ~]# su - nginx -s /bin/bash
-bash-4.2$ touch ~/.ssh/config && echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> ~/.ssh/config
-bash-4.2$ chmod 0600 ~/.ssh/config
-bash-4.2$ ssh-copy-id [email protected]

[[email protected] ~]# vim /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
添加以下内容

[[email protected] ~]# chown -R root.root /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
[[email protected] ~]# systemctl restart nginx
[[email protected] ~]# systemctl restart libvirtd
![]()
验证web界面结果

用户名为root 密码为虚拟机密码











//确保bind绑定的是本机的8000端口\
边栏推荐
- 【The 6th Strong Net Cup CTF-Wp】
- Likou 977-Squaring of ordered arrays - brute force method & double pointer method
- Do you really understand the business process service BPass?
- 第十四章 手动创建 REST 服务(二)
- Jest 测试框架 beforeEach 的设计原理解析
- Chapter 11 Documents
- Learning Experience Sharing Seven: YOLOv5 Code Chinese Comments
- Likou 35 - search for insertion position - binary search
- Thymeleaf
- Create your own app applet ecosystem with applet containers
猜你喜欢

受邀出席Rust开发者大会|Rust如何助力量化高频交易?

今日睡眠质量记录85分

面积曲线AUC(area under curve)

1.3快速生成树协议RSTP
![[kali-information collection] (1.8) ARP reconnaissance tool _Netdiscover](/img/04/f477cd8726d147b892f6050d46c312.png)
[kali-information collection] (1.8) ARP reconnaissance tool _Netdiscover

DTG-SSOD:最新半监督检测框架,Dense Teacher(附论文下载)

Process finished with exit code 1

力扣704-二分查找

CCF论文会议 IEEE 如何查询某个会议期刊的所有文章

Crack detection technology based on deep learning
随机推荐
go语言的接口
运行yum报错Error: Cannot retrieve metalink for reposit
Likou 704 - binary search
How to set up wireless PPI communication between Weiluntong touch screen and S7-200smart?
1.3快速生成树协议RSTP
云原生(三十) | Kubernetes篇之应用商店-Helm介绍
Idea 全局搜索(idea如何全局搜索关键字)
手撸架构,网络 面试36问
【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗
The ex-boyfriend bought chili water and threatened to rob his daughter. Can the woman apply for a personal safety protection order?
【Acunetix-忘记密码】
ansible module --yum module
MyCat2 introduction and installation and basic use
SuperSlide系列之轮播图
AQS-AbstractQueuedSynchronizer
8大软件供应链攻击事件概述
三种实现分布式锁的方式
免费的中英文翻译软件-自动批量中英文翻译软件推荐大全
MyCat2的介绍与安装以及基本使用
How to connect TDengine through DBeaver?