Master - slave replication?

Поиск
Список
Период
Сортировка
От Bjørn T Johansen
Тема Master - slave replication?
Дата
Msg-id 20161026131744.3ad51333@arch-btj.norsvin.local
обсуждение исходный текст
Ответы Re: Master - slave replication?  (Thomas Kellerer <spam_eater@gmx.net>)
Список pgsql-general
I have a database that I would like to replicate in case of hardware failure on this server. So I gather I just need a
streamingreplication (warm 
standby?) and I found a howto describing how to set it up, that looks like this:

Binary Replication in 7 Steps

This 6-step guide, and all of the examples in this tutorial, assume that you have a master server at 192.168.0.1 and a
standbyserver at 192.168.0.2 and that your database and its configuration files are installed at
/var/lib/postgresql/data.Replace those with whatever your actual server addresses and directories are. 
1. Edit postgresql.conf on the master to turn on streaming replication. Change these settings:
 listen_addresses = '*'
 wal_level = hot_standby
 max_wal_senders = 3
2. Edit pg_hba.conf on the master in order to let the standby connect.
 host  replication   all   192.168.0.2/32      trust
3. Edit postgresql.conf on the standby to set up hot standby. Change this line:
 hot_standby = on
4. Create or edit recovery.conf on the standby to set up replication and standby mode. Save a file in the standby's
datadirectory, called recovery.conf, with the following lines: 
 standby_mode = 'on'
 primary_conninfo = 'host=192.168.0.1'
5. Shut down both the master and standby, and copy the files. You want to copy most but not all files between the two
servers,excluding the configuration files and the pg_xlog directory. An example rsync script would be: 
 rsync -av --exclude pg_xlog --exclude postgresql.conf data/* 192.168.0.2:/var/lib/postgresql/data/
6. Start the standby first, so that they can't get out of sync. (Messages will be logged about not being able to
connectto the primary server, that's OK.) 
7. Start the master.


Is this all that is needed to get a working master - slave replication? (It just looks too easy... :) )
Do I need to enable archive mode for this to work or?

Never done this before, so just trying to be sure I understand this right... :)


Regards,

BTJ

--
-----------------------------------------------------------------------------------------------
Bjørn T Johansen

btj@havleik.no
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------


В списке pgsql-general по дате отправления:

Предыдущее
От: Gary Evans
Дата:
Сообщение: Re: Locking question
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: Master - slave replication?