1 Star 0 Fork 2

网络工作室/kvm

forked from ropon/kvm 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
kvmsetup.sh 2.84 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/bash
export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
ip=192.168.199.68
mip=172.16.199.68
Check_OS() {
if [ -n "$(grep 'Aliyun Linux release' /etc/issue)" -o -e /etc/redhat-release ]; then
OS=CentOS
[ -n "$(grep ' 7\.' /etc/redhat-release 2> /dev/null)" ] && CentOS_RHEL_version=7
[ -n "$(grep ' 6\.' /etc/redhat-release 2> /dev/null)" -o -n "$(grep 'Aliyun Linux release6 15' /etc/issue)" ] && CentOS_RHEL_version=6
[ -n "$(grep ' 5\.' /etc/redhat-release 2> /dev/null)" -o -n "$(grep 'Aliyun Linux release5' /etc/issue)" ] && CentOS_RHEL_version=5
elif [ -n "$(grep 'Amazon Linux AMI release' /etc/issue)" -o -e /etc/system-release ]; then
OS=CentOS
CentOS_RHEL_version=6
fi
}
Check_OS
[ $CentOS_RHEL_version -ne 7 ] && echo "Only not support CentOS7" && exit
egrep '(vmx|svm)' /proc/cpuinfo
[ $? -ne 0 ] && echo "Hardware virtualization is not supported" &&exit 1
if ! which wget > /dev/null ;then
yum install -y wget
fi
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum install -y net-tools vim lrzsz tree screen lsof tcpdump
systemctl disable firewalld
systemctl stop firewalld
systemctl disable NetworkManager
systemctl stop NetworkManager
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce 0
echo ' * - nofile 100000 ' >>/etc/security/limits.conf
yum update -y
hostnamectl --static set-hostname kvm-node1
cat > /etc/sysconfig/network-scripts/ifcfg-br0 <<EOF
TYPE="Bridge"
BOOTPROTO="static"
NAME="br0"
DEVICE="br0"
ONBOOT="yes"
IPADDR="${ip}"
NETMASK="255.255.255.0"
EOF
cat > /etc/sysconfig/network-scripts/ifcfg-br1 <<EOF
TYPE="Bridge"
BOOTPROTO="static"
NAME="br1"
DEVICE="br1"
ONBOOT="yes"
IPADDR="${nip}"
NETMASK="255.255.255.0"
EOF
mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.bak
mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth1.bak
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
TYPE="Ethernet"
BOOTPROTO="none"
NAME="eth0"
BRIDGE="br0"
DEVICE="eth0"
ONBOOT="yes"
EOF
cat > /etc/sysconfig/network-scripts/ifcfg-eth1 <<EOF
TYPE="Ethernet"
BOOTPROTO="none"
NAME="eth1"
BRIDGE="br1"
DEVICE="eth1"
ONBOOT="yes"
EOF
yum -y install kvm
lsmod | grep kvm
yum -y install python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-install virt-v2v libguestfs-tools acpid
cat > /etc/sysconfig/grub <<EOF
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb net.ifnames=0 biosdevname=0 quiet"
GRUB_DISABLE_RECOVERY="true"
EOF
grub2-mkconfig -o /boot/grub2/grub.cfg
[ $? -eq 0 ] && echo "Success,15s reboot."
sleep 15
reboot
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jf12458/kvm.git
git@gitee.com:jf12458/kvm.git
jf12458
kvm
kvm
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385