KVM安装脚本

KVM安装脚本

  • 适用于CentOS7的系统
#!/bin/bash
# build by qiange
# this script for centos7

# 检测是否是centos系统
cat /etc/redhat-release | grep "CentOS"
if [ $? -ne 0 ];then
	echo -e "\033[33mSorry your machine not install docker-ce!\033[0m" && exit -1
fi

# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
sed -ri 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

# 检查cpu是否支持KVM
cat /proc/cpuinfo | grep vmx
if [ $? -ne 0 ];then
	echo -e "\033[33mSorry Your CPU not support KVM\033[0m" && exit -1
fi

# 加载KVM模块
lsmod | grep kvm
if [ $? -ne 0 ];then
	modprobe kvm && modprobe kvm-intel
	lsmod | grep kvm
	if [ $? -ne 0 ];then
		echo -e "\033[33mSorry Your KVM model not loading!\033[0m" && exit -1
	fi
fi

# 安装网桥管理工具
yum install -y bridge-utils
sleep 1
systemctl restart network


# 安装libvirt及其他的KVM所需要的安装包
yum install -y libvirt  virt-* qemu-*
sleep 3

# 启动libvirtd服务
systemctl start libvirtd
systemctl enable libvirtd

echo -e "\033[34mKVM 配置完成,请手动配置KVM网桥模式\033[0m"
posted @   廿九九  阅读(76)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示