【Vagranfile】Create many vagrant servers in a time
-- 两个不错的 ansible vagrant
# https://github.com/r-trigo/postgres-repmgr-vagrant
# https://github.com/2ndquadrant-it/ansible-postgresql-barman-playground
Vagrant.configure("2") do |config|
(1..2).each do |n|
config.vm.define "node#{n}" do |define|
define.ssh.insert_key = false
define.vm.box = "generic/centos7"
define.vm.hostname = "node#{n}"
# define.vm.network :private_network, ip: "192.168.56.1#{n}"
define.vm.network :public_network, ip: "192.168.56.1#{n}", virtualbox__hostonly: "vboxnet0"
# if you would like to use port forwarding, uncomment the line below
define.vm.network :forwarded_port, guest: 5432, host: "543#{n}"
define.vm.provider :virtualbox do |v|
v.cpus = 1
v.memory = 2048
v.name = "node#{n}"
end
#config.vm.synced_folder "./", "/vagrant_data"
end
config.vm.provision "shell", inline: <<-SHELL
echo -e "Stage 1"
echo redhat | passwd root --stdin ;
echo -e "192.168.56.11 node1 " >>/etc/hosts
echo -e "192.168.56.12 node2 " >>/etc/hosts
sed -i 's/vault.centos.org/mirrors.aliyun.com/g' /etc/yum.repos.d/CentOS*
echo -e "Stage 2"
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum -y install epel-release yum-utils
# Install PostgreSQL:
sudo yum-config-manager --enable pgdg14
sudo yum install postgresql14-server postgresql14 -y
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
sudo systemctl enable postgresql-14
sudo systemctl start postgresql-14
echo -e "Stage 3"
sudo yum -y install repmgr_14*
echo -e " export PATH=/usr/pgsql-14/bin/:$PATH" >>/var/lib/pgsql/.bash_profile
SHELL
end
end
分类:
Vagrant
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· .NET Core 中如何实现缓存的预热?
· 三行代码完成国际化适配,妙~啊~
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?