当前位置:网站首页>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端口\
边栏推荐
猜你喜欢
用位运算为你的程序加速
Leek 151 - Reverse words in a string
Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单。
#夏日挑战赛#【FFH】OpenHarmony设备开发基础(三)编译依赖
JVM简介
An example of type3 voltage loop compensator taking Boost as an example
三种实现分布式锁的方式
DTG-SSOD: The latest semi-supervised detection framework, Dense Teacher (with paper download)
【kali-信息收集】(1.9)Metasploit+搜索引擎工具Shodan
看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!
随机推荐
放苹果(暑假每日一题 13)
大疆P4M云遮挡矫正
干测试这些年,去过阿里也去过小公司,给年轻测试员们一个忠告...
npm install报错npm ERR Could not resolve dependency npm ERR peer
项目监控六大事项
After Effects 教程,如何在 After Effects 中对蒙版进行动画绘制?
基于深度学习的裂缝检测技术
使用mosquitto过程中的问题解决
Process finished with exit code 1
go语言的接口
Metaverse "Drummer" Unity: Crazy expansion, suspense still exists
Problem solving in the process of using mosquitto
DTG-SSOD: The latest semi-supervised detection framework, Dense Teacher (with paper download)
simulink PID auto-tuning
Create your own app applet ecosystem with applet containers
numpy&pands 中的unique
redis cluster cluster, the ultimate solution?
学习经验分享之七:YOLOv5代码中文注释
MyCat2的介绍与安装以及基本使用
How to set up wireless PPI communication between Weiluntong touch screen and S7-200smart?