Skip to content

Instantly share code, notes, and snippets.

@matheusoliveira
Last active December 11, 2015 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matheusoliveira/62f702e15942117bbe69 to your computer and use it in GitHub Desktop.
Save matheusoliveira/62f702e15942117bbe69 to your computer and use it in GitHub Desktop.
  1. No postgresql.conf do primário:

    wal_level = 'hot_standby' max_wal_senders = 5

  2. Adicionar no pg_hba.conf do primário e reiniciar:

    local replication postgres trust

  3. Para secundário e limpar tudo (cuidado com o rm):

    $ pg_ctlcluster 9.4 main2 stop # para secundário $ rm -rf /var/lib/postgresql/9.4/main2/*

  4. Fazer cópia do primário para o secundário:

    $ pg_basebackup -P -R -D /var/lib/postgresql/9.4/main2/

  5. Configurar postgresql.conf no secundário (para aceitar conexões):

    hot_standby = on

  6. O arquivo /var/lib/postgresql/9.4/main2/recovery.conf já foi criado pelo parâmetro -R no passo 4, vale a pena estudá-lo e entendê-lo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment