User Tools

Site Tools


wikiv1:install_postgres_ol8

Instalação no Oracle Linux 8

Preparando o sistema operacional

Desativando o módulo padrão

$ dnf module list postgresql
Última verificação de data de vencimento de metadados: 0:00:27 atrás em qua 15 jun 2022 14:35:53 -03.
Oracle Linux 8 Application Stream (x86_64)
Name                                          Stream                                   Profiles                                             Summary
postgresql                                    9.6                                      client, server [d]                                   PostgreSQL server and client module
postgresql                                    10 [d]                                   client, server [d]                                   PostgreSQL server and client module
postgresql                                    12                                       client, server [d]                                   PostgreSQL server and client module
postgresql                                    13                                       client, server [d]                                   PostgreSQL server and client module
$ sudo dnf -qy module disable postgresql
$ dnf module list postgresql
Última verificação de data de vencimento de metadados: 0:05:44 atrás em qua 15 jun 2022 14:35:53 -03.
Oracle Linux 8 Application Stream (x86_64)
Name                                         Stream                                      Profiles                                            Summary
postgresql                                   9.6 [x]                                     client, server [d]                                  PostgreSQL server and client module
postgresql                                   10 [d][x]                                   client, server [d]                                  PostgreSQL server and client module
postgresql                                   12 [x]                                      client, server [d]                                  PostgreSQL server and client module
postgresql                                   13 [x]                                      client, server [d]                                  PostgreSQL server and client module
 
Sugestão: [d] padrão, [e] habilitado, [x] desabilitado, [i] instalado

Adicionando o repositório oficial

$ sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm
$ dnf search postgresql14
Última verificação de data de vencimento de metadados: 0:00:12 atrás em qua 15 jun 2022 14:49:05 -03.
================================================================================== Nome Correspondeu Exatamente: postgresql14 ===================================================================================
postgresql14.x86_64 : PostgreSQL client programs and libraries
======================================================================================== Nome Correspondeu: postgresql14 ========================================================================================
postgresql14-contrib.x86_64 : Contributed source and binaries distributed with PostgreSQL
postgresql14-devel.x86_64 : PostgreSQL development header files and libraries
postgresql14-docs.x86_64 : Extra documentation for PostgreSQL
postgresql14-libs.x86_64 : The shared libraries required for any PostgreSQL clients
postgresql14-llvmjit.x86_64 : Just-in-time compilation support for PostgreSQL
postgresql14-odbc.x86_64 : PostgreSQL ODBC driver
postgresql14-plperl.x86_64 : The Perl procedural language for PostgreSQL
postgresql14-plpython3.x86_64 : The Python3 procedural language for PostgreSQL
postgresql14-pltcl.x86_64 : The Tcl procedural language for PostgreSQL
postgresql14-server.x86_64 : The programs needed to create and run a PostgreSQL server
postgresql14-tcl.x86_64 : A Tcl client library for PostgreSQL
postgresql14-test.x86_64 : The test suite distributed with PostgreSQL

Instalando o PostgreSQL

$ sudo dnf install postgresql14-server postgresql14-contrib

Inicializando o database e o serviço do PostgreSQL

$ sudo postgresql-14-setup initdb
Initializing database ... OK
$ sudo systemctl enable --now postgresql-14
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-14.service → /usr/lib/systemd/system/postgresql-14.service.
$ systemctl is-enabled postgresql-14
enabled
$ systemctl status postgresql-14
● postgresql-14.service - PostgreSQL 14 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2022-06-15 14:55:32 -03; 58s ago
     Docs: https://www.postgresql.org/docs/14/static/
  Process: 3286 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 3292 (postmaster)
    Tasks: 8 (limit: 23627)
   Memory: 16.7M
   CGroup: /system.slice/postgresql-14.service
           ├─3292 /usr/pgsql-14/bin/postmaster -D /var/lib/pgsql/14/data/
           ├─3293 postgres: logger
           ├─3295 postgres: checkpointer
           ├─3296 postgres: background writer
           ├─3297 postgres: walwriter
           ├─3298 postgres: autovacuum launcher
           ├─3299 postgres: stats collector
           └─3300 postgres: logical replication launcher
 
jun 15 14:55:31 pgsql systemd[1]: Starting PostgreSQL 14 database server...
jun 15 14:55:31 pgsql postmaster[3292]: 2022-06-15 14:55:31.834 -03 [3292] LOG:  redirecting log output to logging collector process
jun 15 14:55:31 pgsql postmaster[3292]: 2022-06-15 14:55:31.834 -03 [3292] HINT:  Future log output will appear in directory "log".
jun 15 14:55:32 pgsql systemd[1]: Started PostgreSQL 14 database server.

Instalando a extensão TimescaleDB

$ sudo tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/$(rpm -E %{rhel})/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOL
$ sudo dnf install timescaledb-2-postgresql-14
$ sudo timescaledb-tune --pg-config=/usr/pgsql-14/bin/pg_config
Using postgresql.conf at this path:
/var/lib/pgsql/14/data/postgresql.conf
 
Is this correct? [(y)es/(n)o]: y
Writing backup to:
/tmp/timescaledb_tune.backup202206151520
 
shared_preload_libraries needs to be updated
Current:
#shared_preload_libraries = ''
Recommended:
shared_preload_libraries = 'timescaledb'
Is this okay? [(y)es/(n)o]: y
success: shared_preload_libraries will be updated
 
Tune memory/parallelism/WAL and other settings? [(y)es/(n)o]: y
Recommendations based on 7.58 GB of available memory and 8 CPUs for PostgreSQL 14
 
Memory settings recommendations
Current:
shared_buffers = 128MB
#effective_cache_size = 4GB
#maintenance_work_mem = 64MB
#work_mem = 4MB
Recommended:
shared_buffers = 1940MB
effective_cache_size = 5821MB
maintenance_work_mem = 993601kB
work_mem = 2484kB
Is this okay? [(y)es/(s)kip/(q)uit]: y
success: memory settings will be updated
 
Parallelism settings recommendations
Current:
missing: timescaledb.max_background_workers
#max_worker_processes = 8
#max_parallel_workers_per_gather = 2
#max_parallel_workers = 8
Recommended:
timescaledb.max_background_workers = 8
max_worker_processes = 19
max_parallel_workers_per_gather = 4
max_parallel_workers = 8
Is this okay? [(y)es/(s)kip/(q)uit]: y
success: parallelism settings will be updated
 
WAL settings recommendations
Current:
#wal_buffers = -1
min_wal_size = 80MB
Recommended:
wal_buffers = 16MB
min_wal_size = 512MB
Is this okay? [(y)es/(s)kip/(q)uit]: y
success: WAL settings will be updated
 
Miscellaneous settings recommendations
Current:
#default_statistics_target = 100
#random_page_cost = 4.0
#checkpoint_completion_target = 0.9
#max_locks_per_transaction = 64
#autovacuum_max_workers = 3
#autovacuum_naptime = 1min
#effective_io_concurrency = 1
Recommended:
default_statistics_target = 500
random_page_cost = 1.1
checkpoint_completion_target = 0.9
max_locks_per_transaction = 64
autovacuum_max_workers = 10
autovacuum_naptime = 10
effective_io_concurrency = 256
Is this okay? [(y)es/(s)kip/(q)uit]: y
success: miscellaneous settings will be updated
Saving changes to: /var/lib/pgsql/14/data/postgresql.conf
$ sudo systemctl restart postgresql-14

Referências

wikiv1/install_postgres_ol8.txt · Last modified: by 127.0.0.1