当前位置:网站首页>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端口\
边栏推荐
猜你喜欢
免费文档翻译-免费批量文档翻译软件推荐
CCF paper conference IEEE how to query all articles of a conference journal
CCF论文会议 IEEE 如何查询某个会议期刊的所有文章
Crack detection technology based on deep learning
Likou 58 - Left Rotation String
如何通过DBeaver 连接 TDengine?
[email protected] This version of tar is no longer supported, and will not receive"/>
npm WARN deprecated [email protected] This version of tar is no longer supported, and will not receive
QListView的使用
【第六届强网杯CTF-Wp】
jacoco的学习以及理解
随机推荐
第11章 文件
Likou 209 - String with the Minimum Length - Sliding Window Method
手撸架构,Redis面试41问
Thymeleaf
Problem solving in the process of using mosquitto
项目监控六大事项
如何搭建威纶通触摸屏与S7-200smart之间无线PPI通信?
jvmxmx和xms参数分析(设定优化校准)
匹配滤波(四种滤波器的幅频特性)
基于深度学习的裂缝检测技术
【The 6th Strong Net Cup CTF-Wp】
力扣209-长度最小的字符串——滑动窗口法
Seneor Exposure Basics
力扣27-移除元素——简单题
pyqt5连接MYSQL数据库问题
Failure Analysis | A SELECT statement crashes MySQL, what happened?
QListView的使用
ansible module --yum module
SQL function $TRANSLATE
借小程序容器打造自有App小程序生态