- Implantar uma topologia DR híbrida para um banco de dados local
- Criar uma Instância Stand-by Usando RMAN
Criar uma Instância Stand-by Usando RMAN
Use o RMAN (Oracle Recovery Manager) para criar uma instância da nuvem stand-by a partir do banco de dados principal.
Criar um Log de Arquivamento
Verifique o modo de log do servidor Oracle local. Se estiver no modo NOARCHIVELOG
, altere-o para o modo ARCHIVELOG
para criar um log de arquivamento.
- Exibir o modo de log para o servidor local.
SQL> select log_mode from v$database;
A saída será semelhante à seguinte quando o modo de log estiver no modoNOARCHIVELOG
:LOG_MODE ------------ NOARCHIVELOG
- Fazer shut-down da instância local.
SQL> shutdown immediate;
A saída terá uma aparência semelhante à seguinte:Database closed. Database dismounted. ORACLE instance shut down.
- Monte o banco de dados local.
SQL> startup mount;
A saída terá uma aparência semelhante à seguinte:ORACLE instance started. Total System Global Area 4966054520 bytes Fixed Size 9144952 bytes Variable Size 922746880 bytes Database Buffers 4026531840 bytes Redo Buffers 7630848 bytes Database mounted.
- Altere o log de arquivamento do banco de dados e abra o banco de dados.
SQL> alter database archivelog;
SQL> alter database open;
- Altere o modo de log para
ARCHIVELOG
.SQL> select log_mode from v$database;
LOG_MODE ------------ ARCHIVELOG
- Exiba a lista de logs de arquivamento.
SQL> archive log list;
A saída terá uma aparência semelhante à seguinte:Database log mode Archive Mode Automatic archival Enabled Archive destination /opt/oracle/product/19c/dbhome_1/dbs/arch Oldest online log sequence 10 Next log sequence to archive 12 Current log sequence 12
- Arquivar todos os logs.
SQL> archive log all;
ORA-00271:there are no logs that need archiving
Instanciar o Banco de Dados Stand-by no OCI
Use o RMAN (Oracle Recovery Manager) para duplicar o banco de dados principal ativo no OCI (Oracle Cloud Infrastructure). Como alternativa, você pode duplicar a partir de um backup do banco de dados principal.
- Interrompa o banco de dados usando o utilitário
srvctl
ou faça shutdown do banco de dados usando o SQL*Plus.-
$ srvctl stop database -d standby DB_UNIQUE_NAME -o immediate
-
Shutdown immediate;
-
- Conectar ao banco de dados.
$ rman target / RMAN> startup nomount;
- Restaure o arquivo de controle stand-by do serviço principal.Neste exemplo, ORCLCDB é o banco de dados local principal.
RMAN> restore standby controlfile from service 'ORCLCDB';
- Se as seguintes mensagens de erro forem exibidas, reconecte-se ao banco de dados.
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of restore command at 09/24/2020 21:10:13 RMAN-06496: must use the TO clause when the database is mounted or open
- Desativar o banco de dados
RMAN> shutdown;
- Conectar ao banco de dados
RMAN> startup nomount;
- Desativar o banco de dados
- Restaurar usando o arquivo de controle do banco de dados em vez do catálogo de recuperação.
RMAN> restore standby controlfile from service 'ORCLCDB';
A saída terá uma aparência semelhante à seguinte:Starting restore at DD-MM-YY using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=182 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 output file name=/u02/app/oracle/oradata/ORCLCDB_iad1s3/control01.ctl output file name=/u03/app/oracle/fast_recovery_area/ORCLCDB_IAD1S3/control02.ctl Finished restore at DD-MM-YY
- Montar o banco de dados.
RMAN> alter database mount;
- Se uma mensagem de erro semelhante a esta for exibida, reconecte-se ao banco de dados.Se você não receber uma mensagem de erro, vá para a Etapa 8.
Released channel: ORA_DISK_1 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of sql statement command at 09/24/2020 21:13:41 RMAN-06189: current DBID 2822997440 does not match target mounted database (2823031995)
- Desativar o banco de dados
RMAN> shutdown immediate;
A saída terá uma aparência semelhante à seguinte:database dismounted Oracle instance shutdown
- Conectar ao banco de dados
RMAN> startup nomount;
A saída terá uma aparência semelhante à seguinte:connected to target database (not started) Oracle instance startedTotal System Global Area 14495511760 bytesFixed Size 9151696 bytes Variable Size 1912602624 bytes Database Buffers 12549357568 bytes Redo Buffers 24399872 bytes
- Defina o identificador do banco de dados.
RMAN> set DBID=2823031995;
A saída terá uma aparência semelhante à seguinte:executing command: SET DBID
- Desativar o banco de dados
- Como raiz na instância do OCI, altere as permissões do diretório Oracle para aberto (
chmod 777
).[root@drdb opc]# sudo su [root@drdb opc]# cd /opt/ [root@drdb opt]# ls -lrt total 8 drwx------ 7 root root 4096 Sep 12 00:39 zookeeper drwxr-xr-x 6 root root 4096 Sep 12 00:51 oracle [root@drdb opt]# chmod 777 oracle/ [root@drdb opt]# ls -lrt total 8 drwx------ 7 root root 4096 Sep 12 00:39 zookeeper drwxrwxrwx 6 root root 4096 Sep 12 00:51 oracle
- Restaure o banco de dados a partir do banco de dados principal (ORCLCDB).
RMAN> restore database from service 'ORCLCDB' section size 5G;
Depois que o backup de verificação cruzada e a cópia de verificação cruzada forem concluídos, uma lista de arquivos catalogados aparecerá na saída, semelhante à seguinte:Starting restore at 01-SEP-20 Starting implicit crosscheck backup at 01-SEP-20 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=184 device type=DISK Finished implicit crosscheck backup at 01-SEP-20 Starting implicit crosscheck copy at 01-SEP-20 using channel ORA_DISK_1 Finished implicit crosscheck copy at 01-SEP-20 searching for all files in the recovery area cataloging files... cataloging done List of Cataloged Files ======================= File Name: /u03/app/oracle/fast_recovery_area/ORCLCDB_IAD1S3/archivelog/2020_08_27/o1_mf_1_3_hngo1gl6_.arc File Name: /u03/app/oracle/fast_recovery_area/ORCLCDB_IAD1S3/archivelog/2020_08_27/o1_mf_1_1_hngnvtgb_.arc File Name: /u03/app/oracle/fast_recovery_area/ORCLCDB_IAD1S3/archivelog/2020_08_27/o1_mf_1_2_hngnwdfd_.arc using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to /opt/oracle/oradata/ORCLCDB/system01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:26 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00003 to /opt/oracle/oradata/ORCLCDB/sysaux01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00004 to /opt/oracle/oradata/ORCLCDB/undotbs01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:08 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00005 to /opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00006 to /opt/oracle/oradata/ORCLCDB/pdbseed/sysaux01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:08 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00007 to /opt/oracle/oradata/ORCLCDB/users01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00008 to /opt/oracle/oradata/ORCLCDB/pdbseed/undotbs01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:04 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00009 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00010 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:08 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00011 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ORCLCDB channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00012 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf channel ORA_DISK_1: restoring section 1 of 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 01-SEP-20
- Desative o banco de dados.
RMAN> Shutdown immediate;
- Reinicie o banco de dados stand-by usando o utilitário Server Control (
srvctl
) ou o SQL*Plus.- Use o utilitário
srvctl
para iniciar o banco de dados:srvctl start instance -d standby DB_UNIQUE_NAME -i standby instance name -o mount
- Use o SQL*Plus para iniciar o banco de dados:
$ ./sqlplus / as sysdba
- Use o utilitário
- Montar o banco de dados.
SQL> startup mount
A saída terá uma aparência semelhante à seguinte:ORACLE instance started. Total System Global Area 1.4496E+10 bytes Fixed Size 9151696 bytes Variable Size 1912602624 bytes Database Buffers 1.2549E+10 bytes Redo Buffers 24399872 bytes Database mounted.
- Altere o banco de dados.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.
- Exiba a atribuição, o número do thread, o número de sequência e a ação do banco de dados.
SQL> SELECT ROLE, THREAD#, SEQUENCE#, ACTION FROM V$DATAGUARD_PROCESS;
A saída terá uma aparência semelhante à seguinte:ROLE THREAD# SEQUENCE# ACTION ------------------------ ---------- ---------- ------------ post role transition 0 0 IDLE recovery apply slave 0 0 IDLE recovery apply slave 0 0 IDLE recovery apply slave 0 0 IDLE recovery apply slave 0 0 IDLE recovery logmerger 1 7 WAIT_FOR_LOG managed recovery 0 0 IDLE archive redo 0 0 IDLE archive local 0 0 IDLE redo transport timer 0 0 IDLE gap manager 0 0 IDLE archive redo 0 0 IDLE archive redo 0 0 IDLE redo transport monitor 0 0 IDLE log writer 0 0 IDLE 15 rows selected.
- (Opcional) Exiba o nome e a atribuição do banco de dados.
SQL> select name, database_role from v$database;
A saída terá uma aparência semelhante à seguinte:NAME DATABASE_ROLE --------- ---------------- ORCLCDB PHYSICAL STANDBY
- Como
sysdba
, limpe todos os logsredo
stand-by on-line$ sqlplus “/ as sysdba” SQL> alter system set db_create_online_log_dest_1=<DATA Disk group>; SQL> set pagesize 0 feedback off linesize 120 trimspool on SQL> spool /tmp/clearlogs.sql SQL> select distinct 'alter database clear logfile group '||group#||';' from v$logfile; SQL> spool off SQL> @/tmp/clearlogs.sql SQL> select member from v$logfile;
Adicionar Instâncias RAC a tnsnames.ora
Arquivos
Para o Oracle Real Application Clusters (Oracle RAC), adicione as instâncias do Oracle RAC a tnsnames.ora
e reinicie seus listeners. O nome da varredura não pode ser resolvido em nenhuma direção em uma configuração híbrida, o que torna necessário configurar a lista de endereços para fornecer alta disponibilidade.
- Edite o arquivo
TNSNAMES.ORA
no host do banco de dados local.Primary db_unique_name = (DESCRIPTION = (SDU=65536) (RECV_BUF_SIZE=134217728) (SEND_BUF_SIZE=134217728) (ADDRESS_LIST = (FAILOVER=on) (CONNECT_TIMEOUT=3)(RETRY_COUNT=3) (ADDRESS = (PROTOCOL = TCP)(HOST = PrimaryDB Node 1IP address)(PORT = {1521|port#})) (ADDRESS = (PROTOCOL = TCP)(HOST = StandbyDB Node 2IP address)(PORT = {1521|port#})) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Primary_db_SID) (UR=A) )) Standby db_unique_name = (DESCRIPTION = (SDU=65536) (RECV_BUF_SIZE=134217728) (SEND_BUF_SIZE=134217728) (ADDRESS_LIST = (FAILOVER=on) (CONNECT_TIMEOUT=3)(RETRY_COUNT=3) (ADDRESS = (PROTOCOL = TCP)(HOST = StandbyDB Node 1IP address)(PORT = {1521|port#})) (ADDRESS = (PROTOCOL = TCP)(HOST = StandbyDB Node 2IP address)(PORT = {1521|port#})) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Primary_db_SID) (UR=A) ))
- Edite o arquivo
TNSNAMES.ORA
no host do banco de dados stand-by no OCI (Oracle Cloud Infrastructure).Standby db_unique_name = (DESCRIPTION = (SDU=65536) (RECV_BUF_SIZE=134217728) (SEND_BUF_SIZE=134217728) (ADDRESS_LIST = (FAILOVER=on) (CONNECT_TIMEOUT=3)(RETRY_COUNT=3) (ADDRESS = (PROTOCOL = TCP)(HOST = StandbyDB Node 1IP address)(PORT = {1521|port#})) (ADDRESS = (PROTOCOL = TCP)(HOST = StandbyDB Node 2IP address)(PORT = {1521|port#})) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Primary_db_SID) (UR=A) )) <Primary db_unique_name> = (DESCRIPTION = (SDU=65536) (RECV_BUF_SIZE=134217728) (SEND_BUF_SIZE=134217728) (ADDRESS_LIST = (FAILOVER=on) (CONNECT_TIMEOUT=3)(RETRY_COUNT=3) (ADDRESS = (PROTOCOL = TCP)(HOST = PrimaryDB Node 1IP address)(PORT = {1521|port#})) (ADDRESS = (PROTOCOL = TCP)(HOST = StandbyDB Node 2IP address)(PORT = {1521|port#})) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = Primary_db_SID) (UR=A) ))