Skip to content

Commit

Permalink
French doc
Browse files Browse the repository at this point in the history
  • Loading branch information
natmaka committed Nov 4, 2019
1 parent 071bb2e commit f99c60c
Showing 1 changed file with 102 additions and 86 deletions.
188 changes: 102 additions & 86 deletions README.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,126 +2,142 @@

[![Build Status](https://travis-ci.org/jfcoz/postgresqltuner.svg?branch=master)](https://travis-ci.org/jfcoz/postgresqltuner)

`postgresqltuner.pl` est un script Perl pour vous aider à analyser la configuration de votre serveur PostgreSQL. Il est inspiré par [mysqltuner.pl](https://github.com/major/MySQLTuner-perl)
`postgresqltuner.pl` analyse la configuration d'un serveur PostgreSQL et produit un rapport préconisant des améliorations.

## Démonstration
C'est un script Perl dont l'auteur s'est inspiré de [mysqltuner.pl](https://github.com/major/MySQLTuner-perl)

Voici un exemple de son exécution :
## Démonstration

Voici un exemple de rapport:
~~~
postgresqltuner.pl version 0.0.8
Connecting to /var/run/postgresql:5432 database testdb with user postgres...
[OK] User used for report have super rights
postgresqltuner.pl version 1.0.1
Checking if OS commands are available on /var/run/postgresql...
[OK] I can run OS commands
Connecting to /var/run/postgresql:5432 database template1 with user postgres...
[OK] The user acount used for reporting has superuser rights on this PostgreSQL instance
===== OS information =====
[INFO] OS: Debian GNU/Linux 8 \n \l
[INFO] OS total memory: 15.52 GB
[OK] vm.overcommit_memory is good : no memory overcommitment
[INFO] Running on physical machine
[INFO] Currently used I/O scheduler(s) : cfq
[INFO] OS: linux Version: 4.9.0 Arch: x86_64-linux-gnu-thread-multi
[INFO] OS total memory: 94.36 GB
[OK] vm.overcommit_memory is good: no memory overcommitment
[INFO] Running (probably) directly on a physical machine
[INFO] Currently used I/O scheduler(s): mq-deadline
===== General instance informations =====
----- Version -----
[WARN] You are using version 9.4.8 which is not the latest version
[OK] You are using the latest major version (11.5 (Debian 11.5-1+deb10u1)) of PostreSQL
----- Uptime -----
[INFO] Service uptime : 101d 21h 53m 03s
[INFO] Service uptime: 01h 41m 13s
[WARN] Uptime less than 1 day. My report may be inaccurate
----- Databases -----
[INFO] Database count (except templates): 2
[INFO] Database list (except templates): postgres testdb
[INFO] Database count (except templates): 3
[INFO] Database list (except templates): postgres wikistats adrenalib
----- Extensions -----
[INFO] Number of activated extensions : 1
[INFO] Activated extensions : plpgsql
[WARN] Extensions pg_stat_statements is disabled
[INFO] Number of activated extensions: 1
[INFO] Activated extensions: plpgsql
[WARN] Extension pg_stat_statements is disabled in database template1
----- Users -----
[OK] No user account will expire in less than 7 days
[OK] No user with password=username
[OK] Password encryption is enabled
[OK] Password encryption enabled
----- Connection information -----
[INFO] max_connections: 100
[INFO] current used connections: 6 (6.00%)
[INFO] 3 are reserved for super user (3.00%)
[INFO] Average connection age : 1d 11h 31m 18s
[INFO] max_connections: 20
[INFO] Current used connections: 8 (40.00%)
[INFO] 2 connections are reserved for super user (10.00%)
[INFO] Average connection age: 01h 08m 18s
----- Memory usage -----
[INFO] configured work_mem: 4.00 MB
[INFO] Configured work_mem: 128.00 MB
[INFO] Using an average ratio of work_mem buffers by connection of 150% (use --wmp to change it)
[INFO] total work_mem (per connection): 6.00 MB
[INFO] shared_buffers: 128.00 MB
[INFO] Track activity reserved size : 111.00 KB
[WARN] maintenance_work_mem is less or equal default value. Increase it to reduce maintenance tasks time
[INFO] Max memory usage :
shared_buffers (128.00 MB)
+ max_connections * work_mem * average_work_mem_buffers_per_connection (100 * 4.00 MB * 150 / 100 = 600.00 MB)
+ autovacuum_max_workers * maintenance_work_mem (3 * 64.00 MB = 192.00 MB)
+ track activity size (111.00 KB)
= 920.11 MB
[INFO] effective_cache_size: 4.00 GB
[INFO] Size of all databases : 41.87 GB
[INFO] PostgreSQL maximum memory usage: 5.79% of system RAM
[WARN] Max possible memory usage for PostgreSQL is less than 60% of system total RAM. On a dedicated host you can increase PostgreSQL buffers to optimize performances.
[INFO] max memory+effective_cache_size is 31.57% of total RAM
[WARN] Increase shared_buffers and/or effective_cache_size to use more memory
[INFO] Total work_mem (per connection): 192.00 MB
[INFO] shared_buffers: 40.00 GB
[INFO] Track activity reserved size: 0.00 B
[INFO] maintenance_work_mem=2.00 GB
[INFO] Max memory usage:
shared_buffers (40.00 GB)
+ max_connections * work_mem * average_work_mem_buffers_per_connection (20 * 128.00 MB * 150 / 100 = 3.75 GB)
+ autovacuum_max_workers * maintenance_work_mem (2 * 2.00 GB = 4.00 GB)
+ track activity size (0.00 B)
= 47.75 GB
[INFO] effective_cache_size: 85.00 GB
[INFO] Cumulated size of all databases: 2.17 TB
[INFO] PostgreSQL maximum amount of memory used: 50.60% of system RAM
[WARN] PostgreSQL will not use more than 60% of the amount of RAM. On a dedicated host you may increase PostgreSQL shared_buffers, as it may improve performances.
[INFO] max memory+effective_cache_size (less shared_buffers) is 98.29% of the amount of RAM
[WARN] The sum of max_memory and effective_cache_size is too high, the planner may create bad plans because the system buffercache will probably be smaller than expected, especially if the machine is NOT dedicated to PostgreSQL
----- Huge Pages -----
[OK] huge_pages enabled in PostgreSQL
[INFO] Hugepagesize is 2048 kB
[INFO] HugePages_Total 21000 pages
[INFO] HugePages_Free 18004 pages
[INFO] Suggested number of Huge Pages: 21001 (Consumption peak: 43009080 / Huge Page size: 2048)
----- Logs -----
[OK] log_hostname is off : no reverse DNS lookup latency
[WARN] log of long queries is desactivated. It will be more difficult to optimize query performances
[OK] log_hostname is off: no reverse DNS lookup latency
[WARN] Log of long queries deactivated. It will be more difficult to optimize query performance
[OK] log_statement=none
----- Two phase commit -----
[OK] Currently no two phase commit transactions
----- Two-phase commit -----
[OK] Currently no two-phase commit transactions
----- Autovacuum -----
[OK] autovacuum is activated.
[INFO] autovacuum_max_workers: 3
[INFO] autovacuum_max_workers: 2
----- Checkpoint -----
[WARN] checkpoint_completion_target(0.5) is low
[OK] checkpoint_completion_target(0.9) OK
----- Disk access -----
[OK] fsync is on
[BAD] fsync is off. You may lose data after a crash, DANGER!
[OK] synchronize_seqscans is on
----- WAL -----
[BAD] The wal_level minimal does not allow PITR backup and recovery
----- Planner -----
[OK] costs settings are defaults
[OK] all plan features are enabled
===== Database information for database testdb =====
[OK] I/O cost settings are set at their default values
[BAD] Some plan features are disabled: enable_partitionwise_aggregate,enable_partitionwise_join
===== Database information for database template1 =====
----- Database size -----
[INFO] Database testdb total size : 41.86 GB
[INFO] Database testdb tables size : 13.07 GB (31.22%)
[INFO] Database testdb indexes size : 28.79 GB (68.78%)
[INFO] Database template1 total size: 8.02 MB
[INFO] Database template1 indexes size: 4.91 MB (61.21%)
[INFO] Database template1 indexes size: 3.11 MB (38.79%)
----- Tablespace location -----
[OK] No tablespace in PGDATA
----- Shared buffer hit rate -----
[INFO] shared_buffer_heap_hit_rate: 94.11%
[INFO] shared_buffer_toast_hit_rate: 23.73%
[INFO] shared_buffer_tidx_hit_rate: 97.41%
[INFO] shared_buffer_idx_hit_rate: 96.33%
[WARN] Shared buffer idx hit rate is quite good. Increase shared_buffer memory to increase hit rate
[INFO] shared_buffer_heap_hit_rate: 99.98%
[INFO] shared_buffer_toast_hit_rate: 97.31%
[INFO] shared_buffer_tidx_hit_rate: 98.97%
[INFO] shared_buffer_idx_hit_rate: 99.95%
[OK] This is very good (if this PostgreSQL instance was recently used as it usually is, and was not stopped since)
----- Indexes -----
[OK] No invalid indexes
[WARN] Some indexes are unused since last statistics: hosts_owner_idx
[OK] No invalid index
[OK] No unused indexes
----- Procedures -----
[OK] No procedures with default costs
===== Configuration advices =====
----- backup -----
Configure your wal_level to a level which allow PITR backup and recovery
===== Configuration advice =====
----- checkpoint -----
Your checkpoint completion target is too low. Put something nearest from 0.8/0.9 to balance your writes better during the checkpoint interval
[URGENT] set fsync to on!
----- extension -----
Enable pg_stat_statements to collect statistics on all queries (not only queries longer than log_min_duration_statement in logs)
----- index -----
You have unused indexes in the database since last statistics. Please remove them if they are never use
[LOW] Enable pg_stat_statements in database template1 to collect statistics on all queries (not only those longer than log_min_duration_statement)
----- hugepages -----
[LOW] Change Huge Pages size from 2MB to 1GB
[MEDIUM] set vm.nr_hugepages=21001 in /etc/sysctl.conf and run sysctl -p to reload it. This will allocate Huge Pages (it may require a system reboot).
~~~


## Utilisation

### Installation

Pré-requis : module Perl `DBD::Pg`
Des modules Perl sont requis:

- Sur Debian et dérivées :
- Sur Debian et dérivées:
```
apt-get install libdbd-pg-perl libdbi-perl perl-modules
```
apt-get install libdbd-pg-perl
- Sur Fedora et dérivées:
```
- Sur Fedora et dérivées :
yum install perl-DBD-Pg perl-DBI perl-Term-ANSIColor
```

- Sur MacOS avec Homebrew:
```
yum install perl-DBD-Pg
brew install perl
cpan DBD-pg
```

Téléchargement :
Téléchargement du script:

```
wget -O postgresqltuner.pl postgresqltuner.pl
Expand All @@ -130,54 +146,54 @@ curl -o postgresqltuner.pl postgresqltuner.pl
curl -o postgresqltuner.pl https://postgresqltuner.pl
```

Droits :
Établissement des droits :
```
chmod +x postgresqltuner.pl
```

Lancement :
- Connexion par le réseau :
Invocation, en tant qu'utilisateur "postgres":
- Connexion à PostgreSQL par TCP:
```
postgresqltuner.pl --host=dbhost --database=testdb --user=username --password=qwerty
```
- Connexion via le socket unix en tant qu'utilisateur système postgres :
- Connexion via le socket unix:
```
postgres$ postgresqltuner.pl --host=/var/run/postgresql # PostgreSQL socket directory
```

### Avec Docker

- Connexion par le réseau :
- Connexion par le réseau:
```
docker run -it --rm jfcoz/postgresqltuner --host=dbhost --user=username --password=pass --database=testdb
```
- Connexion par le réseau avec accès SSH :
- Connexion via SSH:
```
docker run -it --rm -v $HOME/.ssh:/root/.ssh jfcoz/postgresqltuner --host=dbhost --user=username --password=pass --database=testdb
```
- Connexion via un lien Docker :
- Connexion via un lien Docker:
```
docker run -it --rm --link your-postgresql-container:dbhost jfcoz/postgresqltuner --host=dbhost --user=username --password=pass --database=testdb
```

### SSH

En cas d'utilisation à distance, postgresqltuner.pl utilise SSH pour se connecter au serveur et collecter quelques informations sur l'OS. Il faut pour ça configurer SSH pour que postgresqltuner.pl puisse se connecter au serveur avec une authentification par clef.
Si le script analyse un serveur distant il utilise SSH pour s'y connecter afin de collecter quelques informations décrivant le système. Pour cela vous devez configurer SSH de sorte que le script puisse se connecter au serveur avec une authentification par clef.

## Options

- Nombre moyen de buffers work_mem par connection :

Une requête peut utiliser plusieurs fois simultanément des buffers work_mem, en fonction de la complexité de la requête. Vous pouvez configurer le nombre moyen de buffers work_mem par connection (en pourcentage) avec l'option :
Une requête SQL compliquée peut utiliser de nombreux tampons de travail (work_mem). Vous pouvez configurer le nombre moyen de buffers work_mem par connection (en pourcentage) avec l'option :
```
--wmp 300
```
La valeur par défaut est 150%

- Disques SSD :
- SSD et hyperviseurs:

Dans un hyperviseur la détection de disques SSD n'est pas fiable.
Le script ne détecte pas toujours parfaitement l'éventuel hyperviseur ou le stockage SSD.
```
--ssd
```
Permet d'indiquer que les disques sont SSD.
Indique que le stockage employé par PostreSQL est SSD.

0 comments on commit f99c60c

Please sign in to comment.