Skip to content

Commit

Permalink
Go postgres10, repmgr4 (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
paunin authored and Dmitry Paunin committed Feb 15, 2018
1 parent 884d995 commit 0bb3c09
Show file tree
Hide file tree
Showing 72 changed files with 2,454 additions and 539 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,24 @@ Postgres streaming replication cluster for any docker environment (Kubernetes, D

### Docker images tags convention

Taking into account that PostDock project itself has versioning schema, all docker images produced by the repository have schema - `postdock/<component>:<postdock_version>-<component><component_version>`, where:
Taking into account that PostDock project itself has versioning schema, all docker images produced by the repository have schema - `postdock/<component>:<postdock_version>-<component><component_version>[-<sub_component><sub_component_version>[...]]`, where:

* `<component>` - can be one of the value from the set `postgres`, `postgres-extended`, `pgpool`, `barman`
* `<postdock_version>` - semantic version(without `bug-fix` component)
* `<component>` - can be one of the value from the set `postgres`, `postgres-extended`, `pgpool`, `barman`
* `<component_version>` - depends on component:
* `postgres` - major and minor version without dot in between(can be `95`,`96`,`100`,101)
* `pgpool` - major and minor version without dot in between(can be `33`,`36`)
* `postgres` - major and minor version without dot in between(can be `95`,`96`,`101`)
* `pgpool` - major and minor version of component without dot in between(can be `33`,`36`)
* `barman` - major version (can be `2`,`3`)
* `<sub_component>` - depends on component:
* for `postgres` - `repmgr`
* for `barman` - `postgres`
* `<sub_component_version>` - major and minor version of sub-component without dot in between(can be `33`,`36`)

Aliases are available:
Aliases are available **(not recommended to use for production)**:

* `postdock/<component>:latest-<component><component_version>` - refers to the latest release of the postdock and certain version of the component
* `postdock/<component>:latest` - refers to the latest release of the postdock and the component
* `postdock/<component>:latest-<component><component_version>[-<sub_component><sub_component_version>[...]]` - refers to the latest release of the postdock, certain version of the component, certain version of the sub-components(e.g. `postdock/postgres:latest-postgres101-repmgr32`,`postdock/postgres:latest-barman23-postgres101`)
* `postdock/<component>:latest` - refers to the latest release of the postdock and the latest versions of all the components and sub-components (e.g. `postdock/postgres:latest`)
* `postdock/<component>:edge` - refers to build of postdock from master with the latest version the component, and all sub-components (e.g. `postdock/postgres:edge`)

**There is no alias for `master` branch build**

Expand Down Expand Up @@ -233,8 +238,8 @@ Role | Name | Upstream | Connection String
## Useful commands

* Get map of current cluster(on any `postgres` node):
* `gosu postgres repmgr cluster show` - tries to connect to all nodes on request ignore status of node in `repmgr_$CLUSTER_NAME.repl_nodes`
* `gosu postgres psql $REPLICATION_DB -c "SELECT * FROM repmgr_$CLUSTER_NAME.repl_nodes"` - just select data from tables
* `gosu postgres repmgr cluster show` - tries to connect to all nodes on request ignore status of node in `$(get_repmgr_schema).$REPMGR_NODES_TABLE`
* `gosu postgres psql $REPLICATION_DB -c "SELECT * FROM $(get_repmgr_schema).$REPMGR_NODES_TABLE"` - just select data from tables
* Get `pgpool` status (on any `pgpool` node): `PGPASSWORD=$CHECK_PASSWORD psql -U $CHECK_USER -h localhost template1 -c "show pool_nodes"`
* In `pgpool` container check if primary node exists: `/usr/local/bin/pgpool/has_write_node.sh`

Expand Down
2 changes: 1 addition & 1 deletion doc/CONTRIBUTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Here you can see short list of actions you need to do

## Developer tips

* Don't modify Dockerfile-s directly - use [make.sh](../make/make.sh) to build them from [the templates](../src/includes.Dockerfile)
* Don't modify Dockerfile-s directly - use [make.sh](../make/make.sh) to build them from [the templates](../src/includes/dockerfile)
* Run tests before submitting a new pull request
* Check issues page on github and google before creating a new issue
80 changes: 80 additions & 0 deletions doc/DIFF_RM3_RM4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Nodes table

## Repmgr 3

```
SELECT * FROM repmgr_tms_cluster.repl_nodes;
id | type | upstream_node_id | cluster | name | conninfo | slot_name | priority | active
----+---------+------------------+-------------+---------+---------------------------------------------------------------------------------------------------------------------------+---------------+----------+--------
4 | standby | 2 | tms_cluster | node-bi | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node-bi-service dbname=replica_db port=5432 connect_timeout=2 | repmgr_slot_4 | 0 | t
2 | master | | tms_cluster | node2 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node2-service dbname=replica_db port=5432 connect_timeout=2 | repmgr_slot_2 | 100 | t
3 | standby | 2 | tms_cluster | node3 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node3-service dbname=replica_db port=5432 connect_timeout=2 | repmgr_slot_3 | 100 | t
1 | standby | 2 | tms_cluster | node1 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node1-service dbname=replica_db port=5432 connect_timeout=2 | repmgr_slot_1 | 100 | t
(4 rows)
```

## Repmgr 4

```
SELECT * FROM nodes;
node_id | upstream_node_id | active | node_name | type | location | priority | conninfo | repluser | slot_name | config_file
---------+------------------+--------+-----------+---------+----------+----------+-----------------------------------------------------------------------------------------------------------------+------------------+---------------+------------------
1 | | t | node1 | primary | default | 100 | user=replication_user password=replication_pass host=pgmaster dbname=replication_db port=5432 connect_timeout=2 | replication_user | repmgr_slot_1 | /etc/repmgr.conf
4 | 1 | t | node4 | standby | default | 200 | user=replication_user password=replication_pass host=pgslave3 dbname=replication_db port=5432 connect_timeout=2 | replication_user | repmgr_slot_4 | /etc/repmgr.conf
2 | 1 | t | node2 | standby | default | 100 | user=replication_user password=replication_pass host=pgslave1 dbname=replication_db port=5432 connect_timeout=2 | replication_user | repmgr_slot_2 | /etc/repmgr.conf
(3 rows)
```

# Show nodes table

## Repmgr 3

```
SELECT * FROM repmgr_tms_cluster.repl_show_nodes ;
id | conninfo | type | name | cluster | priority | active | upstream_node_name
----+---------------------------------------------------------------------------------------------------------------------------+---------+---------+-------------+----------+--------+--------------------
4 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node-bi-service dbname=replica_db port=5432 connect_timeout=2 | standby | node-bi | tms_cluster | 0 | t | node2
2 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node2-service dbname=replica_db port=5432 connect_timeout=2 | master | node2 | tms_cluster | 100 | t |
3 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node3-service dbname=replica_db port=5432 connect_timeout=2 | standby | node3 | tms_cluster | 100 | t | node2
1 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node1-service dbname=replica_db port=5432 connect_timeout=2 | standby | node1 | tms_cluster | 100 | t | node2
(4 rows)
```

## Repmgr 4

```
SELECT * FROM show_nodes;
node_id | node_name | active | upstream_node_id | upstream_node_name | type | priority | conninfo
---------+-----------+--------+------------------+--------------------+---------+----------+-----------------------------------------------------------------------------------------------------------------
1 | node1 | t | | | primary | 100 | user=replication_user password=replication_pass host=pgmaster dbname=replication_db port=5432 connect_timeout=2
4 | node4 | t | 1 | node1 | standby | 200 | user=replication_user password=replication_pass host=pgslave3 dbname=replication_db port=5432 connect_timeout=2
2 | node2 | t | 1 | node1 | standby | 100 | user=replication_user password=replication_pass host=pgslave1 dbname=replication_db port=5432 connect_timeout=2
(3 rows)
```

# Cluster Show

## Repmg 3

```
gosu postgres repmgr cluster show
INFO: connecting to database
Role | Name | Upstream | Connection String
----------+---------|----------|--------------------------------------------------------------------------------------------------------------------------
standby | node-bi | node2 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node-bi-service dbname=replica_db port=5432 connect_timeout=2
* master | node2 | | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node2-service dbname=replica_db port=5432 connect_timeout=2
standby | node3 | node2 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node3-service dbname=replica_db port=5432 connect_timeout=2
standby | node1 | node2 | user=replica_user password=replica_pass_55DhFu5 host=tms-db-node1-service dbname=replica_db port=5432 connect_timeout=2
```


## Repmg 4

```
gosu postgres repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Connection string
----+-------+---------+---------------+----------+----------+-----------------------------------------------------------------------------------------------------------------
1 | node1 | primary | * running | | default | user=replication_user password=replication_pass host=pgmaster dbname=replication_db port=5432 connect_timeout=2
2 | node2 | standby | ? unreachable | node1 | default | user=replication_user password=replication_pass host=pgslave1 dbname=replication_db port=5432 connect_timeout=2
4 | node4 | standby | ? unreachable | node1 | default | user=replication_user password=replication_pass host=pgslave3 dbname=replication_db port=5432 connect_timeout=2
```
187 changes: 0 additions & 187 deletions docker-compose/latest.yml

This file was deleted.

1 change: 1 addition & 0 deletions docker-compose/latest.yml
Loading

0 comments on commit 0bb3c09

Please sign in to comment.