首页 » KVM虚拟化 » 使用centos7.5搭建kvm宿主机环境

使用centos7.5搭建kvm宿主机环境

 

全新系统centos7.5,这里是我在生产环境部署用的,这些都是核心内容,强烈建议读者一定要保存下来。

[[email protected] home]# cat kvm_deploy.sh

#!/bin/bash

#修改yum源为阿里云镜像源

yum -y install wget && echo "wget vim 安装成功" >> result.txt

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup && echo "官方yum源备份成功" >> result.txt

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo && echo "阿里云源安装成功" >> result.txt

yum install centos-release-openstack-queens -y && echo "OpenStack queen源安装完成 " >> result.txt

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && echo "EPEL源安装成功" >> result.txt

yum -y groupinstall 'Virtualization' 'Virtualization Client' 'Virtualization Platform' 'Virtualization Tools' groupinstall 'Base' 'Core' 'additional-debel' 'base' 'large-systems' 'storage-client-iscsi' 'system-management-snmp' &&echo "虚拟化需要的包完成" >> result.txt

yum -y install sshpass fping python-pip vim screen virt-* virsh* libvirt* libguest* openssh-askpass openssh-clients qemu-kvm libvirt python-virtinst virt-viewer virt-manager virt-install libvirt-python libguestfs-tools libguestfs-winsupport virt-top links nmon dejavu-lgc-sans-fonts dstat nload guestfish ncurses-devel && echo "相关组件安装完成" >> result.txt

yum groupinstall -y "Desktop" "Desktop platform" "Desktop platform Development" "Fonts" "General Purpose Desktop" "Graphical Administration Tools" "Graphics Creattion Tools" "Input Methods" "X Window System" "Chinese Support [zh]" "Internet Browser" &&echo "virt-manager图形化管理安装完成" >> result.txt

yum clean all &&echo "清除缓存完成" >> result.txt &&yum makecache && echo "yum缓存生成成功" >> result.txt

 

sed -i "s/enforcing/disabled/" /etc/selinux/config && echo "SeLinux已经关闭" >> result.txt

yum -y install libguest* libvirt* && echo "libguest和libvirt相关命令安装完成" >> result.txt

yum -y install virt-* && echo "virt-*相关命令安装完成" >> result.txt

 

systemctl start libvirtd.service && echo "libvirtd启动成功" >> result.txt

systemctl enable libvirtd.service && echo “"libvirtd设置开机启动" >> result.txt

chmod 755 /etc/rc.d/rc.local

echo 1 > /proc/sys/kernel/numa_balancing && echo "NUMA平衡策略开启成功" >> result.txt

echo "echo 1 > /proc/sys/kernel/numa_balancing " >> /etc/rc.d/rc.local && echo "NUMA平衡策略加入开机启动" >> result.txt

 

yum -y upgrade && echo " 升级系统所有包完成" >> result.txt

systemctl restart firewalld && echo "防火墙启动成功" >> result.txt

 

echo "系统重启使SELINUX生效" >> result.txt

sync&&shutdown -r now

 

 

原文链接:使用centos7.5搭建kvm宿主机环境,转载请注明来源!

0