A Oracle é o único grande provedor de nuvem que oferece instâncias de computação baseadas em Arm a apenas um centavo por hora de núcleo, o menor custo por núcleo do setor,
com dimensionamento flexível de VM de 1 a 80 OCPUs e 1 a 64 GB de memória por núcleo ou como um serviço bare-metal com 160 núcleos e 1TB de memória.
Hoje iremos utilizar uma instância Always Free Arm (4 OCPUs, 24GB de Memória) com Oracle Linux 8 e PostgreSQL 14. O PostgreSQL é um RDBMS fantástico, é um dos poucos bancos que pode ser executado em diversas arquiteturas e com diversas extensões, por isso ele foi escolhido neste exemplo.
Provisionando uma instancia always Free Arm com 4 OCPUs, 24GB de Memória. Irei provisionar a instância arm de forma standard, para mais detalhes sobre cada opção, leia a documentação da OCI.
Seleciona a imagem do sistema operacional Oracle Linux 8 e o shape Ampere com o máximo de OCPUs e memória ram.
- Você pode mudar as configurações de rede ou deixar de forma default, para detalhes, utilize a documentação, como este ambiente é apenas de estudos, iremos usar as configurações default. Não esqueça de baixar as chaves públicas e privadas para acessar ao ambiente quando for provisionado.
4 – Testing access to instance arm by public ip after provisioning status is running.
- Testando o acesso a instância arm pelo ip público após o status de provisionamento está em execução.
Instalando e configurando PostgreSQL 14.
- Download do repositório oficial do PostgreSQL 14.
Após atualizar o sistema operacional, reinicie o servidor.
[root@srvpg01 ~]# dnf update
Last metadata expiration check: 0:02:57 ago on Tue 02 Nov 2021 10:21:04 PM GMT.
Dependencies resolved.
========================================================================================================================================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================================================================================================================================
Installing:
kernel-uek aarch64 5.4.17-2136.300.7.el8uek ol8_baseos_latest 73 M
kernel-uek-debug-devel aarch64 5.4.17-2136.300.7.el8uek ol8_baseos_latest 18 M
kernel-uek-devel aarch64 5.4.17-2136.300.7.el8uek ol8_baseos_latest 18 M
Upgrading:
dtrace aarch64 2.0.0-1.8.el8 ol8_baseos_latest 1.5 M
iproute aarch64 5.12.0-1.0.2.el8 ol8_baseos_latest 768 k
iproute-tc aarch64 5.12.0-1.0.2.el8 ol8_baseos_latest 453 k
python36-oci-sdk aarch64 2.49.0-1.el8 ol8_oci_included 17 M
tzdata noarch 2021e-1.el8 ol8_baseos_latest 474 k
Installing dependencies:
python36-circuitbreaker noarch 1.3.1-1.el8 ol8_oci_included 13 k
Transaction Summary
========================================================================================================================================================================================================================================
Install 4 Packages
Upgrade 5 Packages
Total download size: 129 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): python36-circuitbreaker-1.3.1-1.el8.noarch.rpm 181 kB/s | 13 kB 00:00
(2/9): kernel-uek-debug-devel-5.4.17-2136.300.7.el8uek.aarch64.rpm 63 MB/s | 18 MB 00:00
(3/9): kernel-uek-devel-5.4.17-2136.300.7.el8uek.aarch64.rpm 55 MB/s | 18 MB 00:00
(4/9): python36-oci-sdk-2.49.0-1.el8.aarch64.rpm 70 MB/s | 17 MB 00:00
(5/9): iproute-5.12.0-1.0.2.el8.aarch64.rpm 8.6 MB/s | 768 kB 00:00
(6/9): iproute-tc-5.12.0-1.0.2.el8.aarch64.rpm 4.9 MB/s | 453 kB 00:00
(7/9): dtrace-2.0.0-1.8.el8.aarch64.rpm 4.7 MB/s | 1.5 MB 00:00
(8/9): tzdata-2021e-1.el8.noarch.rpm 3.3 MB/s | 474 kB 00:00
(9/9): kernel-uek-5.4.17-2136.300.7.el8uek.aarch64.rpm 65 MB/s | 73 MB 00:01
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 114 MB/s | 129 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : iproute-5.12.0-1.0.2.el8.aarch64 1/14
Installing : python36-circuitbreaker-1.3.1-1.el8.noarch 2/14
Upgrading : python36-oci-sdk-2.49.0-1.el8.aarch64 3/14
Upgrading : iproute-tc-5.12.0-1.0.2.el8.aarch64 4/14
Upgrading : tzdata-2021e-1.el8.noarch 5/14
Upgrading : dtrace-2.0.0-1.8.el8.aarch64 6/14
Running scriptlet: dtrace-2.0.0-1.8.el8.aarch64 6/14
Installing : kernel-uek-devel-5.4.17-2136.300.7.el8uek.aarch64 7/14
Running scriptlet: kernel-uek-devel-5.4.17-2136.300.7.el8uek.aarch64 7/14
Installing : kernel-uek-debug-devel-5.4.17-2136.300.7.el8uek.aarch64 8/14
Running scriptlet: kernel-uek-debug-devel-5.4.17-2136.300.7.el8uek.aarch64 8/14
Running scriptlet: kernel-uek-5.4.17-2136.300.7.el8uek.aarch64 9/14
Installing : kernel-uek-5.4.17-2136.300.7.el8uek.aarch64 9/14
Running scriptlet: kernel-uek-5.4.17-2136.300.7.el8uek.aarch64 9/14
Cleanup : tzdata-2021c-1.el8.noarch 10/14
Cleanup : python36-oci-sdk-2.47.1-1.el8.aarch64 11/14
Cleanup : iproute-tc-5.9.0-4.el8.aarch64 12/14
Cleanup : iproute-5.9.0-4.el8.aarch64 13/14
Cleanup : dtrace-2.0.0-1.7.el8.aarch64 14/14
Running scriptlet: dtrace-2.0.0-1.7.el8.aarch64 14/14
Running scriptlet: kernel-uek-5.4.17-2136.300.7.el8uek.aarch64 14/14
dracut: Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE_[AMD|INTEL]!=y
dracut: Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE_[AMD|INTEL]!=y
Running scriptlet: dtrace-2.0.0-1.7.el8.aarch64 14/14
Verifying : python36-circuitbreaker-1.3.1-1.el8.noarch 1/14
Verifying : kernel-uek-5.4.17-2136.300.7.el8uek.aarch64 2/14
Verifying : kernel-uek-debug-devel-5.4.17-2136.300.7.el8uek.aarch64 3/14
Verifying : kernel-uek-devel-5.4.17-2136.300.7.el8uek.aarch64 4/14
Verifying : python36-oci-sdk-2.49.0-1.el8.aarch64 5/14
Verifying : python36-oci-sdk-2.47.1-1.el8.aarch64 6/14
Verifying : dtrace-2.0.0-1.8.el8.aarch64 7/14
Verifying : dtrace-2.0.0-1.7.el8.aarch64 8/14
Verifying : iproute-5.12.0-1.0.2.el8.aarch64 9/14
Verifying : iproute-5.9.0-4.el8.aarch64 10/14
Verifying : iproute-tc-5.12.0-1.0.2.el8.aarch64 11/14
Verifying : iproute-tc-5.9.0-4.el8.aarch64 12/14
Verifying : tzdata-2021e-1.el8.noarch 13/14
Verifying : tzdata-2021c-1.el8.noarch 14/14
Upgraded:
dtrace-2.0.0-1.8.el8.aarch64 iproute-5.12.0-1.0.2.el8.aarch64 iproute-tc-5.12.0-1.0.2.el8.aarch64 python36-oci-sdk-2.49.0-1.el8.aarch64 tzdata-2021e-1.el8.noarch
Installed:
kernel-uek-5.4.17-2136.300.7.el8uek.aarch64 kernel-uek-debug-devel-5.4.17-2136.300.7.el8uek.aarch64 kernel-uek-devel-5.4.17-2136.300.7.el8uek.aarch64 python36-circuitbreaker-1.3.1-1.el8.noarch
Complete!
[root@srvpg01 ~]# init 6
ShellScriptInstalando o PostgreSQL 14.
[root@srvpg01 ~]# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-aarch64/pgdg-redhat-repo-latest.noarch.rpm
Last metadata expiration check: 0:16:10 ago on Tue 02 Nov 2021 10:21:04 PM GMT.
pgdg-redhat-repo-latest.noarch.rpm 16 kB/s | 9.9 kB 00:00
Dependencies resolved.
========================================================================================================================================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================================================================================================================================
Installing:
pgdg-redhat-repo noarch 42.0-18 @commandline 9.9 k
Transaction Summary
========================================================================================================================================================================================================================================
Install 1 Package
Total size: 9.9 k
Installed size: 12 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : pgdg-redhat-repo-42.0-18.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-18.noarch 1/1
Installed:
pgdg-redhat-repo-42.0-18.noarch
Complete!
[root@srvpg01 ~]# dnf -qy module disable postgresql
Importing GPG key 0x6D960B89:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: 33EC A7E4 0671 479E 2279 EA81 A8AC 42ED 6D96 0B89
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-AARCH64
Importing GPG key 0x6D960B89:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: 33EC A7E4 0671 479E 2279 EA81 A8AC 42ED 6D96 0B89
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-AARCH64
Importing GPG key 0x6D960B89:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: 33EC A7E4 0671 479E 2279 EA81 A8AC 42ED 6D96 0B89
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-AARCH64
Importing GPG key 0x6D960B89:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: 33EC A7E4 0671 479E 2279 EA81 A8AC 42ED 6D96 0B89
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-AARCH64
Importing GPG key 0x6D960B89:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: 33EC A7E4 0671 479E 2279 EA81 A8AC 42ED 6D96 0B89
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-AARCH64
Importing GPG key 0x6D960B89:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: 33EC A7E4 0671 479E 2279 EA81 A8AC 42ED 6D96 0B89
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-AARCH64
Importing GPG key 0x6D960B89:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: 33EC A7E4 0671 479E 2279 EA81 A8AC 42ED 6D96 0B89
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-AARCH64
[root@srvpg01 ~]# dnf install -y postgresql14-server
Last metadata expiration check: 0:02:25 ago on Tue 02 Nov 2021 10:38:03 PM GMT.
Dependencies resolved.
========================================================================================================================================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================================================================================================================================
Installing:
postgresql14-server aarch64 14.0-1PGDG.rhel8 pgdg14 5.5 M
Installing dependencies:
lz4 aarch64 1.8.3-3.el8_4 ol8_baseos_latest 98 k
postgresql14 aarch64 14.0-1PGDG.rhel8 pgdg14 1.5 M
postgresql14-libs aarch64 14.0-1PGDG.rhel8 pgdg14 263 k
Transaction Summary
========================================================================================================================================================================================================================================
Install 4 Packages
Total download size: 7.3 M
Installed size: 33 M
Downloading Packages:
(1/4): lz4-1.8.3-3.el8_4.aarch64.rpm 2.2 MB/s | 98 kB 00:00
(2/4): postgresql14-libs-14.0-1PGDG.rhel8.aarch64.rpm 133 kB/s | 263 kB 00:01
(3/4): postgresql14-14.0-1PGDG.rhel8.aarch64.rpm 629 kB/s | 1.5 MB 00:02
(4/4): postgresql14-server-14.0-1PGDG.rhel8.aarch64.rpm 1.9 MB/s | 5.5 MB 00:02
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.5 MB/s | 7.3 MB 00:02
warning: /var/cache/dnf/pgdg14-d7f99645c2890812/packages/postgresql14-14.0-1PGDG.rhel8.aarch64.rpm: Header V4 RSA/SHA256 Signature, key ID 6d960b89: NOKEY
PostgreSQL 14 for RHEL/CentOS 8 - aarch64 1.7 MB/s | 1.8 kB 00:00
Importing GPG key 0x6D960B89:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: 33EC A7E4 0671 479E 2279 EA81 A8AC 42ED 6D96 0B89
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-AARCH64
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : postgresql14-libs-14.0-1PGDG.rhel8.aarch64 1/4
Running scriptlet: postgresql14-libs-14.0-1PGDG.rhel8.aarch64 1/4
Installing : lz4-1.8.3-3.el8_4.aarch64 2/4
Installing : postgresql14-14.0-1PGDG.rhel8.aarch64 3/4
Running scriptlet: postgresql14-14.0-1PGDG.rhel8.aarch64 3/4
Running scriptlet: postgresql14-server-14.0-1PGDG.rhel8.aarch64 4/4
Installing : postgresql14-server-14.0-1PGDG.rhel8.aarch64 4/4
Running scriptlet: postgresql14-server-14.0-1PGDG.rhel8.aarch64 4/4
Verifying : lz4-1.8.3-3.el8_4.aarch64 1/4
Verifying : postgresql14-14.0-1PGDG.rhel8.aarch64 2/4
Verifying : postgresql14-libs-14.0-1PGDG.rhel8.aarch64 3/4
Verifying : postgresql14-server-14.0-1PGDG.rhel8.aarch64 4/4
Installed:
lz4-1.8.3-3.el8_4.aarch64 postgresql14-14.0-1PGDG.rhel8.aarch64 postgresql14-libs-14.0-1PGDG.rhel8.aarch64 postgresql14-server-14.0-1PGDG.rhel8.aarch64
Complete!
[root@srvpg01 ~]#
ShellScriptCriando o cluster de banco de dados.
[root@srvpg01 ~]# /usr/pgsql-14/bin/postgresql-14-setup initdb
Initializing database ... OK
[root@srvpg01 ~]# systemctl enable postgresql-14
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-14.service → /usr/lib/systemd/system/postgresql-14.service.
[root@srvpg01 ~]# systemctl start postgresql-14
[root@srvpg01 ~]#
[root@srvpg01 ~]# 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 Tue 2021-11-02 22:42:18 GMT; 1min 3s ago
Docs: https://www.postgresql.org/docs/14/static/
Process: 10759 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 10765 (postmaster)
Tasks: 8 (limit: 36876)
Memory: 28.7M
CGroup: /system.slice/postgresql-14.service
├─10765 /usr/pgsql-14/bin/postmaster -D /var/lib/pgsql/14/data/
├─10766 postgres: logger
├─10768 postgres: checkpointer
├─10769 postgres: background writer
├─10770 postgres: walwriter
├─10771 postgres: autovacuum launcher
├─10772 postgres: stats collector
└─10773 postgres: logical replication launcher
Nov 02 22:42:18 srvpg01 systemd[1]: Starting PostgreSQL 14 database server...
Nov 02 22:42:18 srvpg01 postmaster[10765]: 2021-11-02 22:42:18.355 GMT [10765] LOG: redirecting log output to logging collector process
Nov 02 22:42:18 srvpg01 postmaster[10765]: 2021-11-02 22:42:18.355 GMT [10765] HINT: Future log output will appear in directory "log".
Nov 02 22:42:18 srvpg01 systemd[1]: Started PostgreSQL 14 database server.
ShellScriptPara facilitar nossa vida, vamos usar alguns sites que nos ajudam a configurar de forma mais acertiva alguns parâmetros mais usados no PostgreSQL.
Alterando os parâmetros recomendados.
postgres=# ALTER SYSTEM SET shared_buffers TO '6GB';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET effective_cache_size TO '18GB';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET work_mem TO '246MB';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET maintenance_work_mem TO '2GB';
ALTER SYSTEM
postgres=#
postgres=# ALTER SYSTEM SET min_wal_size TO '512MB';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET max_wal_size TO '2GB';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET checkpoint_completion_target TO '0.7';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET wal_buffers TO '16MB';
ALTER SYSTEM
postgres=#
postgres=# ALTER SYSTEM SET listen_addresses TO '*';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET max_connections TO '100';
ALTER SYSTEM
postgres=#
postgres=# ALTER SYSTEM SET random_page_cost TO '4.0';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET effective_io_concurrency TO '2';
ALTER SYSTEM
postgres=#
postgres=# ALTER SYSTEM SET max_worker_processes TO '4';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET max_parallel_workers_per_gather TO '2';
ALTER SYSTEM
postgres=# ALTER SYSTEM SET max_parallel_workers TO '4';
ALTER SYSTEM
postgres=#
postgres=#
postgres=# SELECT pg_reload_conf();
pg_reload_conf
----------------
t
(1 row)
postgres=#
SQLReiniciando o cluster do PostgreSQl.
[root@srvpg01 ~]# systemctl restart postgresql-14
[root@srvpg01 ~]# 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 Tue 2021-11-02 23:01:12 GMT; 6s ago
Docs: https://www.postgresql.org/docs/14/static/
Process: 15102 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 15108 (postmaster)
Tasks: 8 (limit: 36876)
Memory: 154.7M
CGroup: /system.slice/postgresql-14.service
├─15108 /usr/pgsql-14/bin/postmaster -D /var/lib/pgsql/14/data/
├─15111 postgres: logger
├─15113 postgres: checkpointer
├─15114 postgres: background writer
├─15115 postgres: walwriter
├─15116 postgres: autovacuum launcher
├─15117 postgres: stats collector
└─15118 postgres: logical replication launcher
Nov 02 23:01:12 srvpg01 systemd[1]: Starting PostgreSQL 14 database server...
Nov 02 23:01:12 srvpg01 postmaster[15108]: 2021-11-02 23:01:12.185 GMT [15108] LOG: redirecting log output to logging collector process
Nov 02 23:01:12 srvpg01 postmaster[15108]: 2021-11-02 23:01:12.185 GMT [15108] HINT: Future log output will appear in directory "log".
Nov 02 23:01:12 srvpg01 systemd[1]: Started PostgreSQL 14 database server.
[postgres@srvpg01 ~]$ psql
psql (14.0)
Type "help" for help.
postgres=# SHOW listen_addresses;
listen_addresses
------------------
*
(1 row)
postgres=#
ShellScriptConfirmando que o parâmetro do listener foi alterado.
[postgres@srvpg01 ~]$ psql
psql (14.0)
Type "help" for help.
postgres=# SHOW listen_addresses;
listen_addresses
------------------
*
(1 row)
postgres=#
SQLNosso PostgreSQL esta pronto para uso e testes, abaixo segue imagem dos parâmetros usados de acordo com o hardware usado.
- Podemos melhorar ainda mais nosso ambiente usando block volumes para geração de backups do nosso PostgreSQL no link abaixo:
Links used in this article:
Links usados neste artigo:
https://www.oracle.com/br/cloud/compute/arm/
https://blogs.oracle.com/oracle-brasil/post/oracle-amplia-servicos-always-free-da-oracle-cloud
https://www.oracle.com/cloud/compute/arm/
https://www.postgresql.org/download/linux/redhat/