-
-
Save phan2410/271ef0fa8ccdedd330693d192b6df907 to your computer and use it in GitHub Desktop.
Revisions
-
aleksasiriski revised this gist
Feb 25, 2024 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,4 +43,9 @@ postgresql: 3. Apply the YAML and wait for all nodes to restart 4. Connect to the database using generated SuperUser secret (use kubectl proxy to forward the connection) 5. Run `ALTER DATABASE template1 REFRESH COLLATION VERSION;` 6. Run these two commands on ALL of the databases in the cluster: ``` REINDEX DATABASE <db_name>; ALTER DATABASE <db_name> REFRESH COLLATION VERSION; ``` 7. Optionally disable SuperUser if there's no need for it -
aleksasiriski revised this gist
Feb 24, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,8 +29,8 @@ postgresql: 3. Find out on which node the first pod is running, ssh into it and `cd` into the dir which holds the pgdata volume (`/var/lib/rancher/k3s/storage/pvc-*/pgdata`) 4. Inside pgdata volume edit `postgresql.conf`: - change `hba_file` path from `/var/lib/postgresql/15/main/pg_hba.conf` to `/var/lib/postgresql/data/pgdata/pg_hba.conf` - change `ident_file` path from `/var/lib/postgresql/15/main/pg_ident.conf` to `/var/lib/postgresql/data/pgdata/pg_ident.conf` - add `include 'custom.conf'` at the end of the file - add `include 'override.conf'` at the end of the file -
aleksasiriski revised this gist
Feb 4, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ postgresql: 1. Configure cnpg cluster to connect to Patroni via pgbasebackup and use that source-db as bootstrap and replica mode 2. After starting the cluster in replica mode, first init pod should succeed but afterwards the first cnpg pod will fail to start 3. Find out on which node the first pod is running, ssh into it and `cd` into the dir which holds the pgdata volume (`/var/lib/rancher/k3s/storage/pvc-*/pgdata`) 4. Inside pgdata volume edit `postgresql.conf`: - change pg_hba path from `/var/lib/postgresql/15/main/pg_hba.conf` to `/var/lib/postgresql/data/pgdata/pg_hba.conf` -
aleksasiriski revised this gist
Feb 4, 2024 . 1 changed file with 20 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,12 +7,13 @@ - Empty files called `custom.conf` and `override.conf` inside pgdata folder on all nodes (folder where `postgresql.conf` is) - User named strictly `streaming_replica` with REPLICATION ROLE attached (if it's not `streaming_replica` cnpg will fail because it needs that user to exist) - Patroni dynamic config: ```yaml postgresql: parameters: listen: "*" max_wal_senders: 5 unix_socket_directories: "/controller/run" pg_hba: - host replication replicator 127.0.0.1/32 md5 # ...other lines for patroni replication... @@ -23,21 +24,23 @@ postgresql: ## Creating cloudnative-pg cluster in replica mode 1. Configure cnpg cluster to connect to Patroni via pgbasebackup and use that source-db as bootstrap and replica mode 2. After starting the cluster in replica mode, first init pod should succeed but afterwards the first cnpg pod will fail to start 3. Find out on which node the first pod is running, ssh into it and `cd` into the dir which holds the pgdata volume 4. Inside pgdata volume edit `postgresql.conf`: - change pg_hba path from `/var/lib/postgresql/15/main/pg_hba.conf` to `/var/lib/postgresql/data/pgdata/pg_hba.conf` - change pg_ident path from `/var/lib/postgresql/15/main/pg_ident.conf` to `/var/lib/postgresql/data/pgdata/pg_ident.conf` - add `include 'custom.conf'` at the end of the file - add `include 'override.conf'` at the end of the file 5. Restart the pod and it should start up correctly, after it all of the other pods will replicate from the first one as well ## Using the new cnpg-cluster 1. Disable replica mode 2. Enable SuperUser access 3. Apply the YAML and wait for all nodes to restart 4. Connect to the database using generated SuperUser secret (use kubectl proxy to forward the connection) 5. Run `ALTER DATABASE template1 REFRESH COLLATION VERSION;` 6. Optionally disable SuperUser if there's no need for it -
aleksasiriski revised this gist
Feb 4, 2024 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ postgresql: - host all all 0.0.0.0/0 md5 ``` ## Creating cloudnative-pg cluster in replica mode 1) Configure cnpg cluster to connect to Patroni via pgbasebackup and use that source-db as bootstrap and replica mode 2) After starting the cluster in replica mode, first init pod should succeed but afterwards the first cnpg pod will fail to start @@ -31,4 +31,13 @@ postgresql: - change pg_ident path from `/var/lib/postgresql/15/main/pg_ident.conf` to `/var/lib/postgresql/data/pgdata/pg_ident.conf` - add `include 'custom.conf'` at the end of the file - add `include 'override.conf'` at the end of the file 5) Restart the pod and it should start up correctly, after it all of the other pods will replicate from the first one as well ## Using the new cnpg-cluster 1) Disable replica mode 2) Enable SuperUser access 3) Apply the YAML and wait for all nodes to restart 4) Connect to the database using generated SuperUser secret (use kubectl proxy to forward the connection) 5) Run `ALTER DATABASE template1 REFRESH COLLATION VERSION;` 6) Optionally disable SuperUser if there's no need for it -
aleksasiriski revised this gist
Feb 2, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,7 @@ ## Prerequisites - Stable connection to Patroni cluster from cnpg nodes - Same major PostgreSQL version (for example 15.1, cnpg image tag needs to correspond to that) - Empty files called `custom.conf` and `override.conf` inside pgdata folder on all nodes (folder where `postgresql.conf` is) - User named strictly `streaming_replica` with REPLICATION ROLE attached (if it's not `streaming_replica` cnpg will fail because it needs that user to exist) - Patroni dynamic config: -
aleksasiriski revised this gist
Feb 2, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ postgresql: 1) Configure cnpg cluster to connect to Patroni via pgbasebackup and use that source-db as bootstrap and replica mode 2) After starting the cluster in replica mode, first init pod should succeed but afterwards the first cnpg pod will fail to start 3) Find out on which node the first pod is running, ssh into it and `cd` into the dir which holds the pgdata volume 4) Inside pgdata volume edit `postgresql.conf`: - change pg_hba path from `/var/lib/postgresql/15/main/pg_hba.conf` to `/var/lib/postgresql/data/pgdata/pg_hba.conf` - change pg_ident path from `/var/lib/postgresql/15/main/pg_ident.conf` to `/var/lib/postgresql/data/pgdata/pg_ident.conf` -
aleksasiriski revised this gist
Feb 2, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ postgresql: ## Creating cloudnative-pg cluster 1) Configure cnpg cluster to connect to Patroni via pgbasebackup and use that source-db as bootstrap and replica mode 2) After starting the cluster in replica mode, first init pod should succeed but afterwards the first cnpg pod will fail to start 3) Find on which node the first pod is starting, ssh into it and `cd` into the dir which holds the pgdata volume 4) Inside pgdata volume edit `postgresql.conf`: - change pg_hba path from `/var/lib/postgresql/15/main/pg_hba.conf` to `/var/lib/postgresql/data/pgdata/pg_hba.conf` -
aleksasiriski revised this gist
Feb 2, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ postgresql: ## Creating cloudnative-pg cluster 1) Configure cnpg cluster to connect to Patroni via pgbasebackup and use that source-db as bootstrap and replica mode 2) After started the cluster in replica mode, first init pod should succeed but afterwards the first cnpg pod will fail to start 3) Find on which node the first pod is starting, ssh into it and `cd` into the dir which holds the pgdata volume 4) Inside pgdata volume edit `postgresql.conf`: -
aleksasiriski created this gist
Feb 2, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ # Migrate Patroni PostgreSQL cluster to cloudnative-pg ## Prerequisites - Stable connection to Patroni cluster from cnpg nodes - Empty files called `custom.conf` and `override.conf` inside pgdata folder on all nodes (folder where `postgresql.conf` is) - User named strictly `streaming_replica` with REPLICATION ROLE attached (if it's not `streaming_replica` cnpg will fail because it needs that user to exist) - Patroni dynamic config: ```yaml postgresql: parameters: listen: '*' max_wal_senders: 5 unix_socket_directories: '/controller/run' pg_hba: - host replication replicator 127.0.0.1/32 md5 # ...other lines for patroni replication... - host replication streaming_replica 0.0.0.0/0 md5 - host all all 127.0.0.1/32 md5 - host all all 0.0.0.0/0 md5 ``` ## Creating cloudnative-pg cluster 1) Configupre cnpg cluster to connect to Patroni via pgbasebackup and use that source-db as bootstrap and replica mode 2) After started the cluster in replica mode, first init pod should succeed but afterwards the first cnpg pod will fail to start 3) Find on which node the first pod is starting, ssh into it and `cd` into the dir which holds the pgdata volume 4) Inside pgdata volume edit `postgresql.conf`: - change pg_hba path from `/var/lib/postgresql/15/main/pg_hba.conf` to `/var/lib/postgresql/data/pgdata/pg_hba.conf` - change pg_ident path from `/var/lib/postgresql/15/main/pg_ident.conf` to `/var/lib/postgresql/data/pgdata/pg_ident.conf` - add `include 'custom.conf'` at the end of the file - add `include 'override.conf'` at the end of the file 5) Restart the pod and it should start up correctly, after it all of the other pods will replicate from the first one as well