@@ -597,7 +597,7 @@ The two main replication methods allowed are
597
597
598
598
599
599
# ## Database permissions and password authentication
600
- Replication uses a dedicated user ` REPLICATION_USER` . The role ${REPLICATION_USER}
600
+ Replication uses a dedicated user ` REPLICATION_USER` . The role ` ${REPLICATION_USER} `
601
601
uses the default group role ` pg_read_all_data` . You can read more about this
602
602
from the [PostgreSQL documentation](https://www.postgresql.org/docs/14/predefined-roles.html)
603
603
@@ -616,7 +616,7 @@ layer are saved, they are automatically propagated to the replicant. Note also t
616
616
replicant is read-only.
617
617
618
618
` ` ` shell
619
- docker run --name " streaming-replication" -e REPLICATION=true -e WAL_LEVEL=' replica' -d -p 25432:5432 kartoza/postgis:13.0
619
+ docker run --name " streaming-replication" -e REPLICATION=true -e WAL_LEVEL=' replica' -d -p 25432:5432 kartoza/postgis:14.3.2
620
620
` ` `
621
621
622
622
** Note** If you do not pass the env variable ` REPLICATION_PASS` a random password
@@ -635,20 +635,20 @@ we can't write new data to it. The whole database cluster will be replicated.
635
635
636
636
#### Database permissions
637
637
638
- Since we are using a role ${REPLICATION_USER}, we need to ensure that it has access to all
638
+ Since we are using a role ` ${REPLICATION_USER}` , we need to ensure that it has access to all
639
639
the tables in a particular schema. So if a user adds another schema called `data`
640
640
to the database `gis` he also has to update the permission for the user
641
- with the following SQL assuming the ${REPLICATION_USER} is called replicator
641
+ with the following SQL assuming the ` ${REPLICATION_USER}` is called replicator
642
642
643
643
```sql
644
644
ALTER DEFAULT PRIVILEGES IN SCHEMA data GRANT SELECT ON TABLES TO replicator;
645
645
```
646
646
647
- **NB ** You need to set up a strong password for replication otherwise the
648
- default password for ${REPLICATION_USER} will default to `replicator`
647
+ **Note ** You need to set up a strong password for replication otherwise the
648
+ default password for ` ${REPLICATION_USER}` will default to random generated string
649
649
650
- To experiment with the replication abilities, you can see a [docker-compose.yml](sample /replication/docker-compose.yml)
651
- sample. There are several environment variables that you can set, such as:
650
+ To experiment with the streaming replication abilities, you can see a [docker-compose.yml](replication_examples /replication/docker-compose.yml).
651
+ There are several environment variables that you can set, such as:
652
652
653
653
Master settings:
654
654
- **ALLOW_IP_RANGE**: A `pg_hba.conf` domain format which will allow specified host(s)
@@ -676,15 +676,15 @@ Slave settings:
676
676
- **REPLICATION_USER** User to initiate streaming replication
677
677
- **REPLICATION_PASS** Password for a user with streaming replication role
678
678
679
- To run the sample replication , follow these instructions:
679
+ To run the example streaming_replication , follow these instructions:
680
680
681
681
Do a manual image build by executing the `build.sh` script
682
682
683
683
```shell
684
684
./build.sh
685
685
```
686
686
687
- Go into the `sample/replication ` directory and experiment with the following Make
687
+ Go into the `replication_examples/streaming_replication ` directory and experiment with the following Make
688
688
command to run both master and slave services.
689
689
690
690
```shell
@@ -701,31 +701,31 @@ To view logs for master and slave respectively, use the following command:
701
701
702
702
```shell
703
703
make master-log
704
- make slave -log
704
+ make node -log
705
705
```
706
706
707
707
You can try experiment with several scenarios to see how replication works
708
708
709
709
#### Sync changes from master to replicant
710
710
711
711
You can use any postgres database tools to create new tables in master, by
712
- connecting using POSTGRES_USER and POSTGRES_PASS credentials using exposed port.
713
- In the sample , the master database was exposed on port 7777.
712
+ connecting using ` POSTGRES_USER` and ` POSTGRES_PASS` credentials using exposed port.
713
+ In the streaming_replication example , the master database was exposed on port 7777.
714
714
Or you can do it via command line, by entering the shell:
715
715
716
716
```shell
717
717
make master-shell
718
718
```
719
719
720
- Then made any database changes using psql.
720
+ Then make any database changes using psql.
721
721
722
722
After that, you can see that the replicant follows the changes by inspecting the
723
723
slave database. You can, again, use database management tools using connection
724
724
credentials, hostname, and ports for replicant. Or you can do it via command line,
725
725
by entering the shell:
726
726
727
727
```shell
728
- make slave -shell
728
+ make node -shell
729
729
```
730
730
731
731
Then view your changes using psql.
@@ -738,14 +738,14 @@ into slave environment and set `DESTROY_DATABASE_ON_RESTART: 'False'`.
738
738
739
739
After this, you can make changes to your replicant, but master and replicant will not
740
740
be in sync anymore. This is useful if the replicant needs to take over a failover master.
741
- However it is recommended to take additional action, such as creating a backup from the
741
+ However, it is recommended to take additional action, such as creating a backup from the
742
742
slave so a dedicated master can be created again.
743
743
744
744
#### Preventing replicant database destroy on restart
745
745
746
746
You can optionally set `DESTROY_DATABASE_ON_RESTART: ' False' ` after successful sync
747
747
to prevent the database from being destroyed on restart. With this setting you can
748
- shut down your replicant and restart it later and it will continue to sync using the existing
748
+ shut down your replicant and restart it later, and it will continue to sync using the existing
749
749
database (as long as there are no consistencies conflicts).
750
750
751
751
However, you should note that this option doesn' t mean anything if you didn' t
@@ -762,7 +762,7 @@ To activate the following you need to use the environment variable
762
762
docker run --name "logical-replication" -e WAL_LEVEL=logical -d kartoza/postgis:13.0
763
763
```
764
764
765
- For a detailed example see the docker-compose in the folder `sample /logical_replication`.
765
+ For a detailed example see the docker-compose in the folder `replication_examples /logical_replication`.
766
766
767
767
### Docker image versions
768
768
@@ -786,4 +786,4 @@ please consider taking out a [Support Level Agreeement](https://kartoza.com/en/s
786
786
- Rizky Maulana (rizky@kartoza.com)
787
787
- Admire Nyakudya (admire@kartoza.com)
788
788
789
- March 2021
789
+ April 2022
0 commit comments