![]() Stop the postgres service on the slave server with the systemctl command below. The Postgres database server will run under the IP address of the server, not a localhost IP. And this server will only have a READ permission to the database. The SLAVE server has IP address 10.0.15.11. MASTER server configuration has been completed. ![]() ![]() CREATE USER replica REPLICATION LOGIN ENCRYPTED PASSWORD check the new user with ' du' query below, and you will see the replica user with replication privileges. su - postgres psqlĬreate new ' replica' user with password ' replica with postgres query below. We will create a new user named ' replica' with password ' Please choose a secure password here for your setup! Log in to the postgres user and access the postgres front-end terminal psql. PostgreSQL is running under the IP address 10.0.15.10, check it with netstat command. # Localhost host all all 0.0.0.0/0 md5 # PostgreSQL Master IP address host replication replica 10.0.15.10/32 md5 # PostgreSQL SLave IP address host replication replica 10.0.15.11/32 md5 Paste configuration below to the end of the line. Next, edit pg_hba.conf file for authentication configuration. mkdir -p /var/lib/postgresql/9.6/main/archive/ chmod 700 /var/lib/postgresql/9.6/main/archive/ chown -R postgres:postgres /var/lib/postgresql/9.6/main/archive/ Create a new archive directory, change the permission and change the owner to the postgres user. In the nf file, the archive mode is enabled, so we need to create a new directory for the archive. max_wal_senders = 2 wal_keep_segments = 10įor the application name, uncomment 'synchronous_standby_names' line and change the value to the name ' pgslave001'. archive_mode = on archive_command = 'cp %p /var/lib/postgresql/9.6/main/archive/%f'įor the 'Replication' settings, in this tutorial we use 2 servers only, master and slave, uncomment the ' wal_sender' line and change value to 2, and for the ' wal_keep_segments' value is 10. synchronous_commit = localĮnable archiving mode and change the archive_command option to the command 'cp %p /var/lib/postgresql/9.6/main/archive/%f'. Uncomment and change value line as below. wal_level = hot_standbyįor the synchronization level, we will use local sync. Uncomment 'wal_level' line and change value to the ' hot_standby'. Uncomment 'listen_addresses' line and change the value to the master server IP address ' 10.0.15.10'. Go to the postgres configuration directory ' /etc/postgresql/9.6/main' and edit the nf file with vim. The master server will have permission for the READ and WRITE to the database, and perform streaming replication to the slave server. The master server has the IP address 10.0.15.10, and the postgres service will run under that IP with default port. ![]() sudo passwd postgres Step 2 - Configure the PostgreSQL MASTER Server In the next step, we have to configure a password for the postgres user.įrom the root account, log in to the postgres user with the su command, then access the postgres front-end terminal psql. sudo systemctl enable postgresqlīy default, PostgreSQL is running on the localhost (127.0.0.1) IP address with port 5432 on Ubuntu, check it with netstat command. If the installation has been completed, add it to start automatically at boot time. sudo apt-get install -y postgresql-9.6 postgresql-contrib-9.6 Next, install the PosgreSQL 9.6 package with the apt command below.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |