As this architecture example, it needs 5 servers, a virtual IP to connect to the cluster.
https://i.redd.it/23bnddnl8y141.gif
Now want to use Vagrant to create servers on VMs. Here is the \`Vagrantfile\`:
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.define "db-primary" do |c|
c.vm.network "public_network", ip: "13.24.35.1"
c.vm.network :forwarded_port, host: 5432, guest: 5432, protocol: "tcp", auto_correct: true
end
config.vm.define "db-standby" do |c|
c.vm.network "public_network", ip: "13.24.35.2"
c.vm.network :forwarded_port, host: 5432, guest: 5432, protocol: "tcp", auto_correct: true
end
config.vm.define "pgpool1" do |c|
c.vm.network "public_network", ip: "13.24.35.3"
c.vm.network :forwarded_port, host: 9999, guest: 9999, protocol: "tcp", auto_correct: true
end
config.vm.define "pgpool2" do |c|
c.vm.network "public_network", ip: "13.24.35.4"
c.vm.network :forwarded_port, host: 9999, guest: 9999, protocol: "tcp", auto_correct: true
end
config.vm.define "pgpool3" do |c|
c.vm.network "public_network", ip: "13.24.35.5"
c.vm.network :forwarded_port, host: 9999, guest: 9999, protocol: "tcp", auto_correct: true
end
end
Is it to set a \`private\_network\` as below to the \`pgpool\` server? If it is, all of them are necessary?
c.vm.network "private_network", ip: "13.24.35.153"
Or create a new server to set this IP as virtual IP?
My Vagrant exposes one private IP on port 80 and then Nginx handles all the hostnames in config files. I have about 10 apps running on my VM all with different hostnames.
My hosts file (Windows host) contains all my hostnames and they all point to the VM’s exposed IP.
The apps on the VM can all see each other as if they were on the internet. That is, site1.test can make an http call to site3.test.
Vagrantfile:
#network
config.vm.network “private_network”, ip: “172.12.34.56”
# note: specify id: ssh to prevent vagrant also creating its own port 22 mapping
config.vm.network “forwarded_port”, guest: 22, host: 2222, id: “ssh”
# mysql
config.vm.network “forwarded_port”, guest: 3306, host: 3422
Windows Hosts file:
# vagrant ip
172.12.34.56 site1.test
172.12.34.56 site2.test
172.12.34.56 site3.test
You might not be using Nginx but in case you are, I have a config file for each hostname, example:
server {
listen 80;
listen [::]:80;
server_name site1.test;
root /websites/site1.test/public;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
But I’m sure the same idea works with Apache, et al.