1
- # Demo
1
+ ### Demo: [ an example of postgres-checkup report ] ( https://gitlab.com/postgres-ai/postgres-checkup-tests/blob/master/1.1/md_reports/1_2019_05_30T18_32_32_+0000/0_Full_report.md ) (based on CI, single node).
2
2
3
- Auto-generated demonstration based on the code in the master
4
- branch (only single node analyzed): https://gitlab.com/postgres-ai-team/postgres-checkup-tests/tree/master/master .
5
- Go to ` md_reports/TIMESTAMP ` and then open ` 0_Full_report.md ` .
3
+ *** Disclaimer: Conclusions, Recommendations – work in progress.**
4
+ To treat the data correctly, you need deep Postgres knowledge. Each report
5
+ consists of 3 sections: Observations, Conclusions, and Recommendations.
6
+ Observations are filled automatically. As for Conclusions and Recommendations
7
+ sections, as of June 2019, only several reports have autogeneration for them.*
6
8
7
- # Disclaimer: This Tool is Designed for DBA Experts
8
-
9
- Each report consists of 3 sections: Observations, Conclusions, and Recommendations.
10
- As of March 2019, only Observations are filled automatically. To treat the data
11
- correctly, you need deep Postgres knowledge.
12
-
13
- You can get Conclusions, and Recommendations from the Postgres.ai team for free,
14
- send us your .json and .md with filled Observations sections:
[email protected] .
15
- Limited time only. We're a small team, so "restrictions apply".
16
9
17
10
# About
18
11
19
12
Postgres Checkup ([ postgres-checkup] ( https://gitlab.com/postgres-ai-team/postgres-checkup ) )
20
- is a new-generation diagnostics tool that allows users to collect deep analysis
21
- of the health of a Postgres database. It aims to detect and describe all current
22
- and potential issues in the fields of database performance, scalability, and
23
- security, providing advices how to resolve or prevent them.
24
-
25
- Compared to a monitoring system, postgres-checkup goes deeper into the analysis
26
- of the database system and environment. It combines numerous internal
27
- characteristics of the database with data about resources and OS, producing
28
- multiple comprehensive reports. These reports use formats which are easily
29
- readable both by humans and machines and which are extremely oriented to DBA
30
- problem-solving. Monitoring systems constantly collect telemetry, help to react
31
- to issues more quickly, and are useful for post-mortem analyses. At the same
32
- time, checkups are needed for a different purpose: detect issues at a very early
33
- stage, advising on how to prevent them. This procedure is to be done on a
34
- regular basis — weekly, monthly, or quarterly. Additionally, it is recommended
35
- to run it immediately before and after any major change in the database server.
13
+ is a new-generation diagnostics tool that allows users to do a deep analysis
14
+ of the health of Postgres databases. It helps to detect, predict and prevent
15
+ technical issues.
36
16
37
17
The three key principles behind postgres-checkup:
38
18
39
19
- * Unobtrusiveness* : postgres-checkup’s impact on the observing system is
40
20
close to zero. It does not use any heavy queries, keeping resource usage
41
- very low, and avoiding having the [ “observer effect.”] ( https://en.wikipedia.org/wiki/Observer_effect_(information_technology) )
21
+ very low, and avoiding having the [ “observer effect”] ( https://en.wikipedia.org/wiki/Observer_effect_(information_technology) ) .
22
+ postgres-checkup reports were successfully tested on real-world databases
23
+ containing 500,000+ tables and 1,000,000+ indexes.
42
24
43
25
- * Zero install* (on observed machines): it is able to analyze any Linux
44
- machine (including virtual machines), as well as Cloud Postgres instances
26
+ machine (including virtual machines), as well as cloud Postgres instances
45
27
(such as Amazon RDs or Google Cloud SQL), not requiring any additional setup
46
- or any changes. It does, hovewer, require a privileged access ( a DBA usually
47
- has it anyway) .
28
+ or any changes. It does, hovewer, require a privileged access that a DBA usually
29
+ has anyway.
48
30
49
- - * Complex analysis* : unlike most monitoring tools, which provide raw data,
31
+ - * Complex analysis* : unlike most monitoring tools, which provide just raw data,
50
32
postgres-checkup combines data from various parts of the system (e.g.,
51
33
internal Postgres stats are combined with knowledge about system resources
52
- in autovacuum setting and behavior analysis). Also, it analyzes the master
53
- database server together with all its replicas (e.g. to build the list of
54
- unused indexes).
34
+ in autovacuum setting and behavior analysis) joining the data into well-formatted
35
+ reports aimed to solve particular DBA problems. Also, it analyzes the master
36
+ database server together with all its replicas, which is neccessary in such
37
+ cases as index analysis or search for settings deviations.
55
38
56
39
# Reports Structure
57
40
@@ -71,25 +54,28 @@ Each report consists of three sections:
71
54
72
55
1 . "Observations": automatically collected data. This is to be consumed by
73
56
an expert DBA.
74
- 1 . "Conclusions": what we conclude from the Observations—what is good, what
75
- is bad (right now, it is to be manually filled for most checks) .
57
+ 1 . "Conclusions": what we conclude from the Observations, stated in plain English
58
+ in the form that is convenient for engineers who are not DBA experts .
76
59
1 . "Recommendations": action items, what to do to fix the discovered issues.
60
+
77
61
Both "Conclusions" and "Recommendations" are to be consumed by engineers who
78
- will make decisions what, how and when to optimize, and how to react to the
79
- findings.
62
+ will make decisions what, how and when to optimize.
80
63
81
64
# Installation and Usage
82
65
83
66
## Requirements
84
67
85
- The supported OS of the observer machine (those from which the tool is to be
86
- executed) :
68
+ For the operator machine (from where the tool will be executed), the following
69
+ OS are supported :
87
70
88
71
* Linux (modern RHEL/CentOS or Debian/Ubuntu; others should work as well, but
89
72
are not yet tested);
90
73
* MacOS.
91
74
92
- The following programs must be installed on the observer machine:
75
+ There are known cases when postgres-checkup was successfully used on Windows,
76
+ althought with some limitations.
77
+
78
+ The following programs must be installed on the operator machine:
93
79
94
80
* bash
95
81
* psql
@@ -101,53 +87,66 @@ The following programs must be installed on the observer machine:
101
87
* pandoc *
102
88
* wkhtmltopdf >= 0.12.4 *
103
89
104
- Pandoc and wkhtmltopdf optional, they need for generating HTML and PDF versions
105
- of report (see ` --pdf ` and ` --html ` ).
90
+ pandoc and wkhtmltopdf are optional, they are neededed for generating HTML and
91
+ PDF versions of report (options ` --html ` , ` --pdf ` ).
106
92
107
- Nothing special has to be installed on the observed machines. However, these
108
- machines must run Linux (again: modern RHEL/CentOS or Debian/Ubuntu; others
109
- should work as well, but are not yet tested).
93
+ Nothing special has to be installed on the observed machines. However, they must
94
+ run Linux (again: modern RHEL/CentOS or Debian/Ubuntu; others should work as
95
+ well, but are not yet tested).
110
96
111
- :warning : Only Postgres version 9.6 and higher are currently supported.
97
+ :warning : Only Postgres version 9.6 and higher are currently officially supported.
112
98
113
99
## How to Install
114
100
115
101
#### 1. Install required programs
116
102
117
103
Ubuntu/Debian:
118
- ```
119
- sudo apt-get update
120
- sudo apt-get install git postgresql coreutils jq golang
121
- # Optional (if you need PDF/HTML)
122
- # Pandoc (needed for both HTML and PDF generation)
123
- sudo apt install pandoc
124
- # wkhtmltopdf (needed for PDF generation)
104
+ ``` bash
105
+ sudo apt-get update -y
106
+ sudo apt-get install -y git postgresql coreutils jq golang
107
+
108
+ # Optional (to generate PDF/HTML reports)
109
+ sudo apt-get install -y pandoc
125
110
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
126
111
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
127
112
sudo mv wkhtmltox/bin/wkhtmlto* /usr/local/bin
128
113
sudo apt-get install -y openssl libssl-dev libxrender-dev libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig
129
114
```
130
115
131
- MacOS (assuming that [ Homebrew] ( https://brew.sh/ ) is installed):
116
+ CentOS/RHEL:
117
+ ``` bash
118
+ sudo yum install -y git postgresql coreutils jq golang
119
+
120
+ # Optional (to generate PDF/HTML reports)
121
+ sudo yum install -y pandoc
122
+ wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
123
+ tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
124
+ sudo mv wkhtmltox/bin/wkhtmlto* /usr/local/bin
125
+ sudo yum install -y libpng libjpeg openssl icu libX11 libXext libXrender xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi
132
126
```
133
- brew install postgresql
134
- brew install coreutils
135
- brew install jq
136
- brew install golang
137
- brew install git
138
- # Optional
139
- brew install pandoc
140
- brew install Caskroom/cask/wkhtmltopdf
127
+
128
+ MacOS (assuming that [ Homebrew] ( https://brew.sh/ ) is installed):
129
+ ``` bash
130
+ brew install postgresql coreutils jq golang git
131
+
132
+ # Optional (to generate PDF/HTML reports)
133
+ brew install pandoc Caskroom/cask/wkhtmltopdf
141
134
```
142
135
143
136
#### 2. Clone this repo
144
137
145
- Use ` git clone ` . This is the only method of installation currently supported.
138
+ ``` bash
139
+ git clone https://gitlab.com/postgres-ai/postgres-checkup.git
140
+ # Use --branch to use specific release version. For example, to use version 1.1:
141
+ # git clone --branch 1.1 https://gitlab.com/postgres-ai/postgres-checkup.git
142
+ cd postgres-checkup
143
+ ```
146
144
147
145
## Example of Use
148
146
149
- Let's make a report for a project named ` prod1 ` :
150
- Cluster ` slony ` contains two servers - ` db1.vpn.local ` and ` db1.vpn.local ` .
147
+ Let's make a report for a project named ` prod1 ` . Assume that we have two servers,
148
+ ` db1.vpn.local ` and ` db1.vpn.local ` .
149
+
151
150
Postgres-checkup automatically detects which one is a master:
152
151
153
152
``` bash
@@ -229,37 +228,14 @@ The check result can be found inside the `artifacts` folder in current directory
229
228
230
229
### Usage with ` docker run `
231
230
232
- First of all we need a postgres. You can use any local or remote running instance.
233
- For this example we run postgres in a separate docker container:
234
-
235
- ``` bash
236
- docker run \
237
- --name postgres \
238
- -e POSTGRES_PASSWORD=postgres \
239
- -d postgres
240
- ```
241
-
242
- We need to know a hostname or an ip address of target database to be used with ` -h ` parameter:
243
-
244
- ``` bash
245
- PG_HOST=$( docker inspect --format ' {{ .NetworkSettings.IPAddress }}' postgres)
246
- ```
247
-
248
- You can use official images or build an image yourself. Run this command to build an image:
249
-
250
- ``` bash
251
- docker build -t postgres-checkup .
252
- ```
253
-
254
- Then run a container with ` postgres-checkup ` . This command run the tool using
255
- Postgres connection only (without SSH):
231
+ There is an option to run postgres-checkup in a Docker container:
256
232
257
233
``` bash
258
234
docker run --rm \
259
235
--name postgres-checkup \
260
236
-e PGPASSWORD=" postgres" \
261
237
-v ` pwd` /artifacts:/artifacts \
262
- postgres-checkup \
238
+ registry.gitlab.com/ postgres-ai/postgres- checkup:latest \
263
239
./checkup \
264
240
-h hostname \
265
241
-p 5432 \
@@ -276,14 +252,16 @@ target machine with Postgres database.
276
252
277
253
If SSH connection to the Postgres server is available, it is possible to pass
278
254
SSH keys to the docker container, so postgres-checkup will switch to working via
279
- remote SSH calls, generating all reports:
255
+ remote SSH calls, generating all reports (this approach is known to have issues
256
+ on Windows, but should work well on Linux and MacOS machines):
280
257
281
258
``` bash
282
259
docker run --rm \
283
260
--name postgres-checkup \
284
261
-v " $( pwd) /artifacts:/artifacts" \
285
262
-v " $( echo ~ ) /.ssh/id_rsa:/root/.ssh/id_rsa:ro" \
286
- postgres-checkup ./checkup \
263
+ registry.gitlab.com/postgres-ai/postgres-checkup:latest \
264
+ ./checkup \
287
265
-h sshusername@hostname \
288
266
--username my_postgres_user \
289
267
--dbname my_postgres_database \
@@ -296,19 +274,6 @@ you cannot use `localhost` in `-h` parameter. You have to use a bridge between
296
274
host OS and Docker Engine. By default, host IP is ` 172.17.0.1 ` in ` docker0 `
297
275
network, but it vary depending on configuration. More information [ here] ( https://nickjanetakis.com/blog/docker-tip-65-get-your-docker-hosts-ip-address-from-in-a-container ) .
298
276
299
- ### Usage with ` docker-compose `
300
-
301
- It will run an empty ` postgres ` database and ` postgres-checkup ` application
302
- that will stop once it's done. The local folder named ` artifacts ` will contain
303
- the ` docker ` subfolder with checkup reports.
304
-
305
- ``` bash
306
- docker-compose build
307
- docker-compose up -d
308
-
309
- docker-compose down
310
- ```
311
-
312
277
## Credits
313
278
314
279
Some reports are based on or inspired by useful queries created and improved by
@@ -351,6 +316,7 @@ Docker support implemented by [Ivan Muratov](https://gitlab.com/binakot).
351
316
- [ ] C004 Failover #32
352
317
- [ ] C005 Switchover #33
353
318
- [ ] C006 Delayed replica (replay of 1 day of WALs) - #34
319
+ - [ ] C007 Replication slots. Lags. Standby feedbacks
354
320
355
321
## D. Monitoring / Troubleshooting
356
322
@@ -407,30 +373,4 @@ Docker support implemented by [Ivan Muratov](https://gitlab.com/binakot).
407
373
- [x] L001 (was: H003) Current sizes of DB objects (tables, indexes, mat. views) #163
408
374
- [ ] L002 (was: H004) Data types being used #53
409
375
- [x] L003 Integer (int2, int4) out-of-range risks in PKs // calculate capacity remained; optional: predict when capacity will be fully used) https://gitlab.com/postgres-ai-team/postgres-checkup/issues/237
410
-
411
- ## TODO:
412
-
413
- - [ ] DB schema, DDL, DB schema migrations
414
-
415
- ---
416
-
417
- # Ideas :bulb : :bulb : :bulb : : thinking \_ face:
418
-
419
- - analyze all FKs and check if data types of referencing column and referenced one match (same thing for multi-column FKs)
420
- - tables w/o PKs? tables not having even unique index?
421
-
422
- ## PostgreSQL:
423
-
424
- - ready to archive WAL files (count) (need FS access) on master
425
- - standby lag in seconds
426
-
427
- ## OS:
428
-
429
- - FS settings (mount command parsing)
430
- - meltdown/spectre patches
431
- - swap settings
432
- - memory pressure settings
433
- - overcommit settings
434
- - NUMA enabled?
435
- - Huge pages?
436
- - Transparent huge pages?
376
+ - [ ] L004 Tables without PK/UK
0 commit comments