O tema deste artigo é simples, porém é de relevante importância na estratégia de Backup e Recovery de um ambiente Oracle Database. Para explorar a criação do Recovery Catalog, utilizarei os ambientes abaixo:
Banco do Catálogo do RMAN (que foi construído neste artigo AQUI).
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
RMANDB OPEN
SQL> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
SQL> !cat /etc/*release*
Oracle Linux Server release 8.1
SQL> ! hostname
oel8.localdomain
Banco Target (que foi construído neste artigo AQUI).
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
cortex OPEN
SQL> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
SQL> !cat /etc/*release*
Oracle Linux Server release 7.7
SQL> !hostname
oel7.localdomain
Antes de iniciar o processo, preciso garantir que essas duas VMs (construídas no VirtualBox) possam se comunicar, além de conseguirem ter acesso ao banco de dados remotamente.
Alterando o “/etc/hosts” da máquina do catálogo RMAN:
[root@oel8 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.107 oel8.localdomain oel8
192.168.0.108 oel7.localdomain oel7
Realizando testes de ping:
[root@oel8 ~]# ping oel7
PING oel7.localdomain (192.168.0.108) 56(84) bytes of data.
64 bytes from oel7.localdomain (192.168.0.108): icmp_seq=1 ttl=64 time=0.588 ms
64 bytes from oel7.localdomain (192.168.0.108): icmp_seq=2 ttl=64 time=1.01 ms
Realizando o mesmo processo na máquina do banco CORTEX:
[root@oel7 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.108 oel7.localdomain oel7
192.168.0.107 oel8.localdomain oel8
Teste de ping:
[root@oel7 ~]# ping oel8
PING oel8.localdomain (192.168.0.107) 56(84) bytes of data.
64 bytes from oel8.localdomain (192.168.0.107): icmp_seq=1 ttl=64 time=0.964 ms
64 bytes from oel8.localdomain (192.168.0.107): icmp_seq=2 ttl=64 time=0.569 ms
Incluindo a string do banco CORTEX na máquina do catálogo e realizando testes:
[oracle@oel8 admin]$ cd $ORACLE_HOME/network/admin
[oracle@oel8 admin]$ vi tnsnames.ora
RMANDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oel8.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RMANDB)
)
)
CORTEX =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cortex.localdomain)
)
)
[oracle@oel8 admin]$ tnsping RMANDB
TNS Ping Utility for Linux: Version 18.0.0.0.0 - Production on 02-MAY-2020 21:41:22
Copyright (c) 1997, 2018, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oel8.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RMANDB)))
OK (0 msec)
[oracle@oel8 admin]$ tnsping CORTEX
TNS Ping Utility for Linux: Version 18.0.0.0.0 - Production on 02-MAY-2020 21:41:31
Copyright (c) 1997, 2018, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = cortex.localdomain)))
OK (0 msec)
[oracle@oel8 admin]$
[oracle@oel8 admin]$ sqlplus SYSTEM@CORTEX
SQL*Plus: Release 18.0.0.0.0 - Production on Sat May 2 21:42:19 2020
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Enter password:
Last Successful login time: Sat May 02 2020 18:15:05 -03:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
cortex OPEN
SQL>
Realizando configuração e testes na outra máquina:
[oracle@oel7 admin]$ cd $ORACLE_HOME/network/admin
[oracle@oel7 admin]$ vi tnsnames.ora
CORTEX =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.108.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cortex.localdomain)
)
)
LISTENER_LISTENER =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.108.localdomain)(PORT = 1521))
RMANDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oel8.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RMANDB)
)
)
[oracle@oel7 admin]$ tnsping CORTEX
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 02-MAY-2020 21:44:01
Copyright (c) 1997, 2019, Oracle. All rights reserved.
Used parameter files:
/oracle/19.3.0/product/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.108.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = cortex.localdomain)))
OK (60 msec)
[oracle@oel7 admin]$ tnsping RMANDB
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 02-MAY-2020 21:44:08
Copyright (c) 1997, 2019, Oracle. All rights reserved.
Used parameter files:
/oracle/19.3.0/product/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oel8.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RMANDB)))
OK (0 msec)
[oracle@oel7 admin]$ sqlplus SYSTEM@RMANDB
SQL*Plus: Release 19.0.0.0.0 - Production on Sat May 2 21:44:17 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
RMANDB OPEN
SQL>
Antes de iniciar o processo, creio que seja importante, mesmo que de forma breve, falar do propósito e vantagens de se usar o Recovery Catalog. Ele é um esquema de banco de dados que armazena metadados de um ou mais bancos Oracle. Tem como benefícios ser uma redundância, já que estes metadados também são gravados nos arquivos de control file do banco. Ou seja, caso os perca, você tem onde recorrer. Além disso, caso você tenha um ambiente que centraliza essas catálogos, fica mais fácil extrair informações e executar certas tarefas (que você precisaria conectar em vários bancos para coletar). Além disso, o catálogo tem capacidade de armazenamento muito maior que o control file, sendo interessante para manter seus artefatos catalogados por um bom tempo. E por último, para ambientes que usam o Oracle Data Guard, o catálogo é um dos requisitos. O recurso de \”Stored Scripts\” também é bem legal, permitindo a persistência dos blocos de scripts rman dentro do próprio catálogo.
Criando tablespace no banco que abrigará o catálogo:
[oracle@oel8 datafile]$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Sat May 2 22:04:58 2020
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> CREATE TABLESPACE TS_CORTEX_CATALOG DATAFILE '/oracle/dados/RMANDB/datafile/ts_cortex_catalog.dbf' SIZE 200M AUTOEXTEND ON NEXT 200M MAXSIZE UNLIMITED;
Tablespace created.
Criando usuário com o privilégio necessário:
SQL> CREATE USER CORTEX_CATALOG IDENTIFIED BY CORTEX_CATALOG DEFAULT TABLESPACE TS_CORTEX_CAALOG;
User created.
SQL> ALTER USER CORTEX_CATALOG QUOTA UNLIMITED ON TS_CORTEX_CATALOG;
User altered.
SQL> GRANT RECOVERY_CATALOG_OWNER TO CORTEX_CATALOG;
Grant succeeded.
No banco target, realizar a seguinte chamada utilizando o RMAN:
[oracle@oel7 19.3.0]$ rman target / catalog CORTEX_CATALOG/CORTEX_CATALOG@RMANDB
Recovery Manager: Release 19.0.0.0.0 - Production on Sat May 2 22:10:08 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CORTEX (DBID=548968087)
connected to recovery catalog database
RMAN>
Criando o catálogo:
RMAN> create catalog;
recovery catalog created
Registrando o banco:
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
Realizando uma consulta através do report schema:
RMAN> report schema;
Report of database schema for database with db_unique_name CORTEX
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 910 SYSTEM YES +DG_DATA/CORTEX/DATAFILE/system.256.1039033445
3 570 SYSAUX NO +DG_DATA/CORTEX/DATAFILE/sysaux.257.1039033519
4 340 UNDOTBS1 YES +DG_DATA/CORTEX/DATAFILE/undotbs1.258.1039033555
7 5 USERS NO +DG_DATA/CORTEX/DATAFILE/users.259.1039033555
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 32 TEMP 32767 +DG_DATA/CORTEX/TEMPFILE/temp.264.1039033669
RMAN>