Skip to content

Commit fcedf03

Browse files
Update README.md
1 parent 7e43a1e commit fcedf03

File tree

1 file changed

+53
-10
lines changed

1 file changed

+53
-10
lines changed

common/db/README.md

+53-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,60 @@
1-
### Generating Key Pair for DB
1+
### STEP 1 Generating Key Pair for DB
22

3-
1. RUN `ssh-keygen -t rsa` to generate a key pair
4-
2. Set value of `cat ~/.ssh/id_rsa | base64 -w 0` in DB_SSH_PRIVATE_KEY (change the location of private key in command if needed)
5-
3. Set value of `cat ~/.ssh/id_rsa.pub | base64 -w 0` in DB_SSH_PUBLIC_KEY (change the location of private key in command if needed)
3+
A. RUN `ssh-keygen -t rsa` to generate a key pair
4+
B. Set value of `cat ~/.ssh/id_rsa | base64 -w 0` in DB_SSH_PRIVATE_KEY (change the location of private key in command if needed)
5+
C. Set value of `cat ~/.ssh/id_rsa.pub | base64 -w 0` in DB_SSH_PUBLIC_KEY (change the location of private key in command if needed)
66

7-
### Steps to follow after the db container is started (only if you have enabled barman)
7+
### Step 2 Follow after the db container is started (only if you have enabled barman)
88

9-
1. Currently the ssh server doesn't start automatically, run `docker exec -it DB_CONTAINER_ID /usr/sbin/sshd` to start the ssh server inside the db container
9+
A. Currently the ssh server doesn't start automatically, run `docker exec -it DB_CONTAINER_ID /usr/sbin/sshd` to start the ssh server inside the db container
10+
B. Create barman and streaming_barman user in postgres to setup barman disaster recovery later.
11+
12+
`docker exec -it DB_CONTAINER_ID bash`
13+
14+
`su - postgres`
15+
16+
`createuser --superuser --replication -P barman` password you set will be needed to setup barman later.
17+
18+
`createuser --replication -P streaming_barman` password you set will be needed to setup barman later
19+
20+
Now exit from container using `exit` command twice.
21+
22+
C. Copy the public key of postgres user which is required to setup barman later, run `docker exec -it DB_CONTAINER_ID cat /var/lib/postgresql/.ssh/id_rsa.pub` to get the public key.
1023

11-
### Steps to setup Barman
24+
### Step 3 Follow to setup Barman.
25+
A. Switch to root user `sudo -i`
26+
B. Create a DNS entry in /etc/hosts file for postgres server.
1227

13-
1. Run `make setup-barman` to setup barman
28+
`vi /etc/hosts` edit the file and add `POSTGRES_IP mydb` replace POSTGRES_IP with actual IP address of postgres container/server and mydb with name you want to set this domain name is required while setting up barman.
29+
30+
C. Run `make setup-barman` in barman server to setup barman, provide the following value when asked :
31+
```
32+
- HOSTNAME/DOMAIN name of your server (e.g mydb.example.com , mydb) which you have set in previous step.
33+
- Database name for which backup needs to be created (e.g postgres or any database name).
34+
- Password of user 'barman' which was created while configuring barman user in STEP 2.B.
35+
- Password of user 'streaming_barman' which was created while configuring streaming_barman user in STEP 2.B.
36+
```
37+
38+
D. Switch to barman user and generate the barman key pair.
39+
40+
`su - barman`
41+
42+
`ssh-keygen -t rsa`
43+
44+
E. Add the postgres public key (refer to STEP 2.C) in .ssh/authorized_keys file located in barman's home directory.
45+
46+
`vi ~/.ssh/authorized_keys` paste the public key of postgres user.
47+
48+
F. Copy the public key of barman user and paste it in the postgres user's authorized_keys running in container
49+
50+
`cat ~/.ssh/id_rsa.pub` copy the content
51+
52+
#### STEP 4 connect to postgres container and add public key of barman to postgres user's authorized key.
53+
54+
`docker exec -it CONTAINER_ID bash`
55+
56+
`su - postgres`
57+
58+
`vi ~/.ssh/authorized_keys`
1459

15-
> [!NOTE]
1660

17-
> 1. We will require the public key generated here while we setup Barman

0 commit comments

Comments
 (0)