Neste artigo, vamos reproduzir a criação de um Catálogo de Backup RMAN em um ambiente Data Guard, contemplando tanto o Primary quanto o Standby Database (utilizando Data Broker). Além disso, veremos a questão do registro de ambos os ambientes no catálogo, e a criação da string de conexão dentro do RMAN para cada banco de dados, o que facilitará operações posteriores.
Analisando a configuração do nosso Data Guard:
[oracle@fornix1 ~]$ dgmgrl sys/oracle@CORTEX as sysdba
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Tue Jun 29 04:15:31 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "cortex"
Connected as SYSDBA.
DGMGRL> SHOW CONFIGURATION;
Configuration - cortex
Protection Mode: MaxPerformance
Members:
cortex - Primary database
cortexdr - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 41 seconds ago)
DGMGRL> SHOW DATABASE CORTEX;
Database - cortex
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
cortex
Database Status:
SUCCESS
DGMGRL>
Standby:
[oracle@fornix2 ~]$ dgmgrl sys/oracle@CORTEXDR as sysdba
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Tue Jun 29 04:16:08 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "cortexDR"
Connected as SYSDBA.
DGMGRL> SHOW DATABASE CORTEXDR;
Database - cortexdr
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 0 seconds ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Average Apply Rate: 28.00 KByte/s
Real Time Query: ON
Instance(s):
CORTEXDR
Database Status:
SUCCESS
DGMGRL>
Creating a RMAN Recovery Catalog
Obviamente, para ambientes corporativos, devemos criar o catálogo de backup em um banco de dados separado daquele(s) que queremos registrar, mas como nosso artigo tem objetivo apenas educacional, vou criar o catálogo dentro do meu banco primary:
[oracle@fornix1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jun 29 04:18:47 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> SELECT DB_UNIQUE_NAME,OPEN_MODE FROM V$DATABASE;
DB_UNIQUE_NAME OPEN_MODE
------------------------------ --------------------
cortex READ WRITE
SQL> CREATE USER CAT IDENTIFIED BY CAT DEFAULT TABLESPACE users QUOTA UNLIMITED ON users;
User created.
SQL> GRANT RECOVERY_CATALOG_OWNER TO CAT;
Grant succeeded.
Criando catálogo:
[oracle@fornix1 ~]$ rman
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Jun 29 04:19:54 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
RMAN> CONNECT CATALOG CAT/CAT@CORTEX
connected to recovery catalog database
RMAN> CREATE CATALOG;
recovery catalog created
Registering the Databases in the recovery catalog
Registrando o banco Primary no novo catálogo:
RMAN> CONNECT TARGET /
connected to target database: CORTEX (DBID=548968087)
RMAN> REGISTER DATABASE;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>
Validando o banco registrado:
RMAN> LIST DB_UNIQUE_NAME OF DATABASE;
List of Databases
DB Key DB Name DB ID Database Role Db_unique_name
------- ------- ----------------- --------------- ------------------
1 CORTEX 548968087 PRIMARY CORTEX
RMAN>
O mais legal é que o registro do Standby Database acontece automaticamente quando conectamos no catálogo com o standby, conforme abaixo:
[oracle@fornix2 ~]$ rman target / catalog CAT/CAT@CORTEX
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Jun 29 04:24:55 2021
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> LIST DB_UNIQUE_NAME OF DATABASE;
List of Databases
DB Key DB Name DB ID Database Role Db_unique_name
------- ------- ----------------- --------------- ------------------
1 CORTEX 548968087 PRIMARY CORTEX
1 CORTEX 548968087 STANDBY CORTEXDR
Defining the connect string for the primary and standby databases
Por fim, podemos definir uma string/alias que representará os 2 bancos em operações que faremos em artigos posteriores, como na execução de comandos LIST ou REPORT no RMAN.
[oracle@fornix1 ~]$ rman target / catalog CAT/CAT@CORTEX
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Jun 29 04:32:11 2021
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> CONFIGURE DB_UNIQUE_NAME CORTEX CONNECT IDENTIFIER 'CORTEX';
new RMAN configuration parameters:
CONFIGURE DB_UNIQUE_NAME 'CORTEX' CONNECT IDENTIFIER 'CORTEX';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
RMAN> CONFIGURE DB_UNIQUE_NAME CORTEXDR CONNECT IDENTIFIER 'CORTEXDR';
new RMAN configuration parameters:
CONFIGURE DB_UNIQUE_NAME 'CORTEXDR' CONNECT IDENTIFIER 'CORTEXDR';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
RMAN>
É possível realizar o SYNC dos 2 bancos com o catálogo ao mesmo tempo com o comando abaixo:
[oracle@fornix1 ~]$ rman target sys/oracle@CORTEX CATALOG CAT/CAT@CORTEX
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Jun 29 04:41:18 2021
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> RESYNC CATALOG FROM DB_UNIQUE_NAME ALL ;
starting full resync of recovery catalog
full resync complete
resyncing from database with DB_UNIQUE_NAME CORTEXDR
starting resync of recovery catalog
resync complete
RMAN>
Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laboratório pessoal para fins de aprendizado.
Pingback: Taking Backup in Primary and Standby Databases using RMAN – Bruno Santos da Silva
Pingback: Taking Backup in Primary and Standby Databases using RMAN – SWIV