Skip to main content

How to install and run multiple Vagrant machines using single vagrant file

  This guide provides how to urn multiple machines with the fix of itmezone issues in vagrant

Pre-req :

Install latest vagrant
Install latest Oracle vmware.


before starting

  vagrant up or vagrant up pg1/2/3

  Install the below on vagrant windows machine :

  vagrant install plugin vagrant-timezone

  If windows 10 thrown some error then it might have caused last patch installation. Reboot the machine and try again.




*********************************************************************************************************

The below provides clean 3 node vagrant instllation with timezone fix

# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
echo I am provisioning...
date > /etc/vagrant_provisioned_at
SCRIPT

Vagrant.configure("2") do |config|


  if Vagrant.has_plugin?("vagrant-timezone")
    config.timezone.value = "America/New_York"
  end
  # ... other stuff


  config.vm.define "pg1" do |pg1|
    pg1.vm.box = "weiishann/centos7-pg11beta2"
    pg1.vm.hostname = 'pg1'
    pg1.vm.box_url = "weiishann/centos7-pg11beta2"

    pg1.vm.network :private_network, ip: "192.168.56.101"


    pg1.vm.provision :shell, :path => "Vagrant-setup/bootstrap.sh"

pg1.vm.network "forwarded_port", guest: 5432, host: 5430
   

    pg1.vm.provider :virtualbox do |v|
      v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
      v.customize ["modifyvm", :id, "--memory", 1024]
      v.customize ["modifyvm", :id, "--name", "pg1"]
    end
  end

  config.vm.define "pg2" do |pg2|
    pg2.vm.box = "weiishann/centos7-pg11beta2"
    pg2.vm.hostname = 'pg2'
    pg2.vm.box_url = "weiishann/centos7-pg11beta2"

    pg2.vm.network :private_network, ip: "192.168.56.102"


    pg2.vm.provision :shell, :path => "Vagrant-setup/bootstrap.sh"
pg2.vm.network "forwarded_port", guest: 5432, host: 5431
 

    pg2.vm.provider :virtualbox do |v|
      v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
      v.customize ["modifyvm", :id, "--memory", 1024]
      v.customize ["modifyvm", :id, "--name", "pg2"]
    end
  end
 
    config.vm.define "pg3" do |pg3|
    pg3.vm.box = "weiishann/centos7-pg11beta2"
    pg3.vm.hostname = 'pg3'
    pg3.vm.box_url = "weiishann/centos7-pg11beta2"
    pg3.vm.network :private_network, ip: "192.168.56.103"
    pg3.vm.provision :shell, :path => "Vagrant-setup/bootstrap.sh"
pg3.vm.network "forwarded_port", guest: 5432, host: 5433
    pg3.vm.provider :virtualbox do |v|
      v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
      v.customize ["modifyvm", :id, "--memory", 512]
      v.customize ["modifyvm", :id, "--name", "pg3"]
   end
    end
end

Comments

Popular posts from this blog

How to configure Barman along with One Node Wal Streaming.

How to configure Barman : Step 1 : Remove existing postgres Instllations if you have for safer side. sudo su root ==> yum remove postgres* & yum remove barman* step 2 : Install this on Both Prod & Backup servers. PostgreSQL 11 You can install the 2ndQuadrant's General Public RPM repository for PostgreSQL 11 by running the following instructions as a user with sudo privileges on the destination Linux server: curl https://dl.2ndquadrant.com/default/release/get/11/rpm | sudo bash The above command will run a shell script that will install the repository definition in your server. You can check the content of the script by running: curl https://dl.2ndquadrant.com/default/release/get/11/rpm | less Step 3 : Install EPEL depends on OS version on prod :  CentOS/RHEL - 7 rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm yum install postgresql11-server yum install postgresql11-contrib  ===> Th

PG Frequently used DBA Commands

************************************************************************************************************************************************** NOTE :  By default if You connect any DB in the Cluster with out specified User Name, Eventhough those DBs are owned by different users, then internally postgres will be the User and Public is the default Schema Name respective to that. If you create any tables after logging into DB, It will use Public Schema only since this will be the default search path. If you connect db along with particular user then, objects will be created to the respective corresponding schema pointed to the owner. Even you revoke Public Schema access to respective of all users or specified users, By default search path will be public only. But since public is revoked, it will look out who is the owner of the schema to own the object as owner. ALTER ROLE advuser IN DATABASE "Adventureworks"     SET search_path TO adv_s

PG Replication on 10 Master / Slave Configuration using traditional cp

How to do Streaming / Replication Setup on PG : ************************************* Stage 1 : Note down, In this Stage 1, The below example shows that Primary and Standby replication only..No fail over & Fail Back..           For failover , refer stage 2 and fail back refer stage 3 . Primary : Primary Side  : 192.168.100.11 Secondary   : 192.168.100.12 1. CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'replicator'; 2. Edit postgresql.conf as below ALTER SYSTEM SET wal_level TO 'replica';    Must be at least set to hot_standby  until version 9.5 or replica ALTER SYSTEM SET archive_mode TO 'ON'; ALTER SYSTEM SET max_wal_senders TO '3'; ALTER SYSTEM SET wal_keep_segments TO '10'; ALTER SYSTEM SET listen_addresses TO '*'; ALTER SYSTEM SET hot_standby TO 'ON'; ALTER SYSTEM SET archive_command TO 'cp %p /mnt/server/archivedir/%f';  You may not need archive_mode or archive_command or res