站点更新:2018-11-04 21:53:37

This commit is contained in:
ehlxr 2018-11-04 21:53:37 +08:00
parent a037b0fffc
commit 20557604de
3 changed files with 27 additions and 13 deletions

14
Vagrantfile vendored
View File

@ -2,14 +2,14 @@ Vagrant.configure("2") do |config|
# 定义虚拟机数量 # 定义虚拟机数量
vms = Array(1..5) vms = Array(1..5)
vms.each do |i| vms.each do |i|
config.vm.define "vg#{i}" do |cfg| config.vm.define "vm#{i}" do |cfg|
# 设置虚拟机的 Box # 设置虚拟机的 Box
cfg.vm.box = "centos-7.2-ehlxr" cfg.vm.box = "centos-7.5-ehlxr"
# 不检查 box 更新 # 不检查 box 更新
cfg.vm.box_check_update = false cfg.vm.box_check_update = false
# 设置虚拟机的主机名 # 设置虚拟机的主机名
cfg.vm.hostname="vg#{i}.node" cfg.vm.hostname="vm.node#{i}"
# cfg.vm.network "forwarded_port", guest: 80, host: 8080 # cfg.vm.network "forwarded_port", guest: 80, host: 8080
# hostonly # hostonly
@ -27,13 +27,13 @@ Vagrant.configure("2") do |config|
vb.cpus = 1 vb.cpus = 1
# 名称指的是在 VirtualBox 中显示的名称 # 名称指的是在 VirtualBox 中显示的名称
vb.name = "vghost#{i}" vb.name = "vmhost#{i}"
end end
# 增加各节点 host 配置插件安装vagrant plugin install vagrant-hosts # 增加各节点 host 配置插件安装vagrant plugin install vagrant-hosts
cfg.vm.provision :hosts do |provisioner| cfg.vm.provision :hosts do |provisioner|
vms.each do |x| vms.each do |x|
provisioner.add_host "192.168.3.10#{x}", ["vg#{x}.node"] provisioner.add_host "192.168.3.10#{x}", ["vm.node#{x}"]
end end
end end
@ -43,9 +43,9 @@ Vagrant.configure("2") do |config|
cfg.ssh.insert_key = "true" cfg.ssh.insert_key = "true"
# do NOT check the correct additions version when booting this machine插件安装vagrant plugin install vagrant-vbguest # do NOT check the correct additions version when booting this machine插件安装vagrant plugin install vagrant-vbguest
cfg.vbguest.auto_update = false # cfg.vbguest.auto_update = false
cfg.vm.synced_folder "/Users/ehlxr/works/Vagrant/vm_share", "/root/" cfg.vm.synced_folder "/Users/ehlxr/works/Vagrant/vm_share", "/root/", type: "virtualbox"
cfg.vm.synced_folder "/Users/ehlxr/works/Vagrant", "/vagrant", disabled: true cfg.vm.synced_folder "/Users/ehlxr/works/Vagrant", "/vagrant", disabled: true
# 开机运行命令 # 开机运行命令

16
base/Vagrantfile vendored
View File

@ -2,8 +2,22 @@
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
config.vm.box = "centos-7.2" config.vm.box = "centos-7.2"
config.vm.network "private_network", ip: "192.168.3.3" config.vm.network "private_network", ip: "192.168.3.3"
config.vm.hostname="vm.node"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = false
# Customize the amount of memory on the VM:
vb.memory = "1024"
vb.cpus = 1
# 名称指的是在 VirtualBox 中显示的名称
vb.name = "vmhost-base"
end
config.vbguest.auto_update = false config.vbguest.auto_update = false
config.vm.synced_folder "/Users/ehlxr/works/Vagrant", "/vagrant" config.vm.synced_folder "/Users/ehlxr/works/Vagrant", "/vagrant", type: "virtualbox"
# 自定义初始化执行脚本 # 自定义初始化执行脚本
config.vm.provision "shell", path: "../config/init.sh" config.vm.provision "shell", path: "../config/init.sh"

View File

@ -38,11 +38,11 @@ sed -i 's/^PasswordAuthentication.*/PasswordAuthentication\ yes/g' /etc/ssh/sshd
echo -e "\033[1;33mConfig dns...\033[0m" echo -e "\033[1;33mConfig dns...\033[0m"
cp /vagrant/config/resolv.conf /etc/ cp /vagrant/config/resolv.conf /etc/
# echo -e "\033[1;33mUpdating kernel...\033[0m" echo -e "\033[1;33mUpdating kernel...\033[0m"
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
# yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y
# grub2-set-default 0 grub2-set-default 0
echo -e "\033[1;33mInstall docker...\033[0m" echo -e "\033[1;33mInstall docker...\033[0m"
wget -qO- https://get.docker.com | sh wget -qO- https://get.docker.com | sh