You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/content/en/04-administration-guide/10-replication/03-remote-cluster/01-replicateFrom/_index.md
+52-3Lines changed: 52 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,18 +7,67 @@ description: This section details the cluster cascading replication.
7
7
8
8
The `replicateFrom` feature is explained in the [SGCluster CRD]({{% relref "06-crd-reference/01-sgcluster/#sgclusterspecreplicatefrom" %}}) but here is a practical guide to accomplish the setup.
9
9
10
-
Since `replicateFrom` works through the Patroni [*Standby Cluster* concept](https://patroni.readthedocs.io/en/latest/standby_cluster.html), when using streaming replication, it is required that the main cluster leader member is accessible from the new cluster replica. Based on the DC architecture or k8s Cloud provider, enabling connections to the WAN must be done. Beforehand, consider that the k8s service should be ready to expose the cluster service.
10
+
Since `replicateFrom` works through the Patroni [*Standby Cluster* concept](https://patroni.readthedocs.io/en/latest/standby_cluster.html), when using streaming replication, it is required that the main cluster leader member or a simple stand alone Postgres server, is accessible from the new cluster replica. Based on the DC architecture or k8s Cloud provider, enabling connections to the WAN must be done. Beforehand, consider that in k8s a service should be ready to expose the cluster service.
11
+
12
+
StackGres requires to setup 3 users in the `replicateFrom` spec using the specific keys `superuser`, `replication`, and `authenticator` (that may be the same user in the source server) in order to properly functioning. The 3 (or 2 or 1) users must exists in the main cluster that is being replicated. To create each of those users you can fallow the next commad examples:
13
+
14
+
* Superuser username:
15
+
```
16
+
CREATE ROLE postgres;
17
+
```
18
+
* Superuser password:
19
+
```
20
+
ALTER ROLE postgres WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLICATION BYPASSRLS PASSWORD '***';
21
+
```
22
+
* Replication username:
23
+
```
24
+
CREATE ROLE replicator;
25
+
```
26
+
* Replication password:
27
+
```
28
+
ALTER ROLE replicator WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN REPLICATION NOBYPASSRLS PASSWORD '***';
29
+
```
30
+
* Authenticator username:
31
+
```
32
+
CREATE ROLE authenticator;
33
+
```
34
+
* Authenticator password:
35
+
```
36
+
ALTER ROLE authenticator WITH SUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD '***';
37
+
```
38
+
39
+
> More details can be found in the [CRD reference]({{% relref "06-crd-reference/01-sgcluster/#sgclusterspecconfigurationscredentialsusers"%}})
11
40
12
41
Once access is granted, the next command can be used to test the connection:
13
42
14
43
```sh
15
44
psql -U <USER> -p 5433 -h <HOST> -d <database>
16
45
```
17
46
18
-
Then, the new Stackgres Cluster will require the credentials for the user that will connect to the main Cluster, the classical way is by using a Postgres user named "replication" or similar. Since credentials are being present here, it should be saved into `secrets`.
47
+
Then, the new StackGres Cluster will require the credentials for the users that will connect to the main Cluster. Since credentials are being present here, it should be saved into a `Secret`.
48
+
Te next example helps to understand how to create it, using the same names from the example above:
19
49
50
+
```yaml
51
+
apiVersion: v1
52
+
data:
53
+
authenticator-password: ***
54
+
authenticator-username: authenticator
55
+
replication-password: ***
56
+
replication-username: replicator
57
+
superuser-password: ***
58
+
superuser-username: postgres
59
+
kind: Secret
60
+
metadata:
61
+
labels:
62
+
app: StackGresCluster
63
+
stackgres.io/cluster-name: my-db
64
+
name: mysecrets-db
65
+
namespace: my-namespace
66
+
type: Opaque
67
+
EOF
68
+
```
20
69
21
-
It the new remote Stackgres deployment, where a new Stackgres Cluster will be created as Standby Leader, equal CRDs are needed after creating it. Create them accordingly as follows:
70
+
In the new remote StackGres deployment, where a new StackGres Cluster will be created as Standby Leader, equal CRDs are required before proceed. Create them accordingly as follows:
22
71
23
72
- Namespace
24
73
- StorageClass - Setting up the same storage or better performance is strongly recommended.
0 commit comments