代码拉取完成,页面将自动刷新
#!/bin/bash
set -xeuo pipefail
# !!!root权限执行
# VT是否启用了
egrep --color -i "svm|vmx" /proc/cpuinfo
[ -f yum-nexus.sh ] || cp ../../nexus/yum-nexus.sh .
[ -f env.sh ] || cp ../../env.sh .
chmod +x *.sh
[ -f yum-nexus.sh ] || exit 1
[ -f env.sh ] || exit 1
# 执行./yum-nexus.sh 和source引入的差别,export的变量需要这里也看到
source ./yum-nexus.sh
yum install -y bash-completion bash-completion-extras.noarch libvirt-bash-completion
#自有一些辅助软件包
yum install -y csmisc
yum install -y vagrant.x86_64
yum install -y libvirt
yum install -y qemu* kvm
yum install -y virt-manager
# vagrant kvm时需要
yum install -y rsync
#编译开发相关
yum install -y libvirt-devel zlib-devel.x86_64
yum install -y gcc gcc-c++ gdb
systemctl enable libvirtd
systemctl start libvirtd
# 嵌套虚拟化 https://ostechnix.com/how-to-enable-nested-virtualization-in-virtualbox/
:<<EOF
Starting from version 6.1, Oracle VirtualBox supports nested virtualization feature on host systems that run AMD and Intel CPUs. So make sure you have running the latest virtualbox version.
$ vboxmanage modifyvm "cent74-1708" --nested-hw-virt on
To enable nested feature on Intel CPUs, follow the command line way as described in the previous section.
Log in to the VM and run the following command to check if nested feature is enabled or not:
$ egrep --color -i "svm|vmx" /proc/cpuinfo
必须有vmx内容才行[intel系列, amd系列是svm]
EOF
# vagrant需要的插件的安装
# 插件列表 https://github.com/hashicorp/vagrant/wiki/Available-Vagrant-Plugins
# nexus3的私服地址
# https://github.com/vagrant-libvirt/vagrant-libvirt
# /opt/vagrant/embedded/lib/ruby/2.6.0/x86_64-linux/rbconfig.rb 中需要修改 -Wl,--compress-debug-sections=zlib
vagrant plugin install --plugin-clean-sources --plugin-source ${REPO_GEMS} --debug vagrant-libvirt || true
#centos7上编译出错,因此替换后再次安装,由于使用了缓存就可正常安装
sed -i "s/\-Wl,\-\-compress\-debug\-sections=zlib/ /" /opt/vagrant/embedded/lib/ruby/2.6.0/x86_64-linux/rbconfig.rb
vagrant plugin install --plugin-clean-sources --plugin-source ${REPO_GEMS} --debug vagrant-libvirt
#查看当前的插件
vagrant plugin list
:<<EOF
# vagrant plugin list
vagrant-libvirt (0.1.2, global)
EOF
# centos7的box 镜像下载 https://mirrors.ustc.edu.cn/centos-cloud/centos/7/vagrant/x86_64/images/
# centos7.4 -1708
# 下载文件到本地
# https://mirrors.ustc.edu.cn/centos-cloud/centos/7/vagrant/x86_64/images/CentOS-7-x86_64-Vagrant-1708_01.Libvirt.box
# vagrant box add --name centos7.4 CentOS-7-x86_64-Vagrant-1708_01.Libvirt.box
:<<EOF
# vagrant box list
centos7.4 (libvirt, 0)
export VAGRANT_DEFAULT_PROVIDER=libvirt
vagrant up --provider=libvirt --debug
EOF
# vagrant box add --name centos7.4 CentOS-7-x86_64-Vagrant-1708_01.Libvirt.box
# vagrant init centos7.4 https://mirrors.ustc.edu.cn/centos-cloud/centos/7/vagrant/x86_64/images/CentOS-7-x86_64-Vagrant-1708_01.Libvirt.box
vagrant box add --name centos7.4 ${REPO_FTP}/CentOS-7-x86_64-Vagrant-1708_01.Libvirt.box
vagrant box list|grep centos7.4|grep libvirt
# vagrant box add --name centos7.4 ftp://xxx.xxx.xxx.xxx/vagrant/CentOS-7-x86_64-Vagrant-1708_01.Libvirt.box
systemctl status libvirtd|grep active
lsmod|grep kvm
#工具软件复制HOST机器诊断
yum install -y iperf3.x86_64 iotop.noarch fio.x86_64 net-tools.x86_64 lsof.x86_64 dstat.noarch htop sysstat.x86_64 tcpdump.x86_64 iftop.x86_64 atop.x86_64 psmisc.x86_64
yum install -y tcpreplay.x86_64
# kvm vcpu unhandled rdmsr/wrmsr https://my.oschina.net/anglix/blog/504822
echo 1 > /sys/module/kvm/parameters/ignore_msrs
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。