Database
 sql >> Base de Dados >  >> RDS >> Database

Configurando o Active Data Guard Physical Standby na Arquitetura RAC One Node - Parte 2


Este artigo é a parte 2 de uma série de duas partes que descreve as etapas para definir o modo de espera físico do Active Data Guard na arquitetura de um nó RAC. Você pode encontrar a parte 1 aqui.



1. Quando o processo de banco de dados duplicado for concluído (Parte 1 do artigo), adicione o banco de dados Standby no Clusterware
 
srvctl add database -d analytics_dg -o /u01/app/oracle/product/12.1.0.2/dbhome_1 -c RACONENODE -p '+DG_DATA/analytics_DG/PARAMETERFILE/spfileanalytics_dg.ora' -r PHYSICAL_STANDBY -s MOUNT -n analytics_dg -e hostdr

2. desligue um banco de dados
sqlplus> shutdown immediate;

3. Copie o “arquivo de senha Oracle” com o novo nome da instância “orapwanalyticsdg_1”
cd $ORACLE_HOME/dbs
cp orapwanalytics_dg orapwanalyticsdg_1

4. Inicie o banco de dados
$ srvctl start database -d analytics_dg
$ srvctl config database -d analytics_dg
Database unique name: analytics_dg
Database name: analytics_dg
Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_1
Oracle user: oracle
Spfile: +DG_DATA/analytics_DG/PARAMETERFILE/spfileanalytics_dg.ora
Password file:
Domain:
Start options: read only
Stop options: immediate
Database role: PHYSICAL_STANDBY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DG_DATA,DG_RECO
Mount point paths:
Services:
Type: RACOneNode
Online relocation timeout: 30
Instance name prefix: analyticsdg
Candidate servers: hostdr
OSDBA group: sdba
OSOPER group: soper
Database instances:
Database is administrator managed

5. De acordo com o padrão do Oracle Restart, a instância analytics_dg será chamada analyticsdg_1, portanto, listener.ora deve ser atualizado.

Execute o comando “listener reload” para forçar o ouvinte a ler as entradas “listener.ora” novamente. Atenção! Esta operação afetará a disponibilidade do ouvinte.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = analytics_dg_dgmgrl)
# (SID_NAME = analytics_dg)
(SID_NAME = analyticsdg_1)
(ORACLE_HOME = /u01/app/oracle/product/12.1.0.2/dbhome_1)
)
)

6. O Redo Transport Service será habilitado manualmente para validar conexões e configurações.

Parâmetros DB_BLOCK_CHECKSUM , DB_BLOCK_CHECKING e DB_LOST_WRITE_PROTECT será configurado para ambos os bancos de dados, primário e standby, para prevenir e detectar blocos corrompidos.

6.1. Ajustar parâmetros no banco de dados Standby
sqlplus> alter system set log_archive_config='dg_config=(analytics,analytics_dg)' scope=both sid='*' ;
sqlplus> alter system SET log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_ROLES, ALL_LOGFILES) db_unique_name=analytics_dg' scope=both sid='*' ;
sqlplus> alter system set log_archive_dest_2='service=analytics LGWR ASYNC NOAFFIRM max_failure=10 max_connections=1 reopen=180 valid_for=(online_logfiles,primary_role) db_unique_name=analytics' scope=both sid='*';
sqlplus> alter system set fal_server='analytics' scope=both sid='*';
sqlplus> alter system set fal_client='analytics_dg' scope=both sid='*';
sqlplus> alter system set log_archive_max_processes=4 scope=both sid='*';
sqlplus> alter system set standby_file_management='AUTO' scope=both sid='*';
sqlplus> alter system set db_file_name_convert='+DG_DATA_DR/analytics','+DG_DATA/analytics_DG','+DG_RECO_DR/analytics','+DG_RECO/analytics_DG' scope=spfile sid='*';
sqlplus> alter system set log_file_name_convert='+DG_DATA_DR/analytics','+DG_DATA/analytics_DG','+DG_RECO_DR/analytics','+DG_RECO/analytics_DG' scope=spfile sid='*';
sqlplus> alter system set db_block_checksum=FULL scope=both sid='*' ;
sqlplus> alter system set db_block_checking=MEDIUM scope=both sid='*' ;
sqlplus> alter system set db_lost_write_protect=TYPICAL scope=both sid='*' ;
sqlplus> alter system set log_archive_dest_state_1='enable' scope=both sid='*';
sqlplus> alter system set log_archive_dest_state_2='enable' scope=both sid='*';

6.2. Ajuste os parâmetros no banco de dados primário:
sqlplus> alter system set log_archive_config='dg_config=(analytics,analytics_dg)' scope=both sid='*' ;
sqlplus> alter system SET log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_ROLES,ALL_LOGFILES) db_unique_name=analytics' scope=both sid='*' ;
sqlplus> alter system set log_archive_dest_2='service=analytics_dg LGWR ASYNC NOAFFIRM max_failure=10 max_connections=1 reopen=180 valid_for=(online_logfiles,primary_role) db_unique_name=analytics_dg' scope=both sid='*';
sqlplus> alter system set fal_server='analytics_dg' scope=both sid='*';
sqlplus> alter system set fal_client='analytics' scope=both sid='*';
sqlplus> alter system set log_archive_max_processes=4 scope=both sid='*' ;
sqlplus> alter system set standby_file_management='AUTO' scope=both sid='*' ;
sqlplus> alter system set db_file_name_convert='+DG_DATA/analytics_DG','+DG_DATA_DR/analytics','+DG_RECO/analytics_DG','+DG_RECO_DR/analytics' scope=spfile sid='*';
sqlplus> alter system set log_file_name_convert='+DG_DATA/analytics_DG','+DG_DATA_DR/analytics','+DG_RECO/analytics_DG','+DG_RECO_DR/analytics' scope=spfile sid='*';
sqlplus> alter system set db_block_checksum=TYPICAL scope=both sid='*' ;
sqlplus> alter system set db_block_checking=MEDIUM scope=both sid='*' ;
sqlplus> alter system set db_lost_write_protect=TYPICAL scope=both sid='*' ;
sqlplus> alter system set log_archive_dest_state_1='enable' scope=both sid='*' ;
sqlplus> alter system set log_archive_dest_state_2='enable' scope=both sid='*' ;

6.3. O atributo "status" do Primary e Standby deve retornar 'VALID'
sqlplus> select dest_id,status,destination ,error from v$archive_dest where dest_id <=5;
 ID DB_status Archive_dest Error
---------- --------- ----------------------------- -------
1 VALID USE_DB_RECOVERY_FILE_DEST
2 VALID analytics_dg
3 INACTIVE
4 INACTIVE
5 INACTIVE

sqlplus> select dest_id,status,database_mode,recovery_mode from v$archive_dest_status where status <> 'INACTIVE';
 DEST_ID STATUS DATABASE_MODE RECOVERY_MODE
---------- --------- --------------- -----------------------
1 VALID OPEN IDLE
2 VALID MOUNTED-STANDBY IDLE

6.4. Iniciar manualmente Redo Apply:
sqlplus> alter database recover managed standby database using current logfile disconnect;

6.5. Sincronização entre a validação do banco de dados primário e em espera
sqlplus> select * from v$archive_gap;
sqlplus> select name, value, datum_time, time_computed from v$dataguard_stats where name like 'apply lag';
sqlplus> select file_type, number_of_files, percent_space_used from v$recovery_area_usage;
sqlplus> select current_scn from v$database;
sqlplus> select sequence#, first_time, applied from v$archived_log order by sequence#;

6.6. Interrompa o Redo Apply antes de configurar o Data Guard Broker
sqlplus> alter database recover managed standby database cancel;
Database altered.

7. Configure o Data Guard Broker no banco de dados primário e em espera

Nota:Os arquivos de configuração do Data Guard serão criados no ASM em diferentes grupos de discos:dg_broker_config_file1 e dg_broker_config_file2

7.1. No banco de dados primário:
sqlplus> alter system set dg_broker_config_file1 = '+DG_DATA_DR/analytics/BROKERCFG/brokeranalytics1.dat' scope=both sid='*';
sqlplus> alter system set dg_broker_config_file2 = '+DG_RECO_DR/analytics/BROKERCFG/brokeranalytics2.dat' scope=both sid='*';
sqlplus> alter system set log_archive_dest_2='' scope=both sid='*' ;
sqlplus> alter system set DG_BROKER_START=FALSE scope=both sid='*';
sqlplus> alter system set DG_BROKER_START=TRUE scope=both sid='*';

7.2. No banco de dados em espera:
sqlplus> alter system set dg_broker_config_file1 = '+DG_DATA/analytics_DG/BROKERCFG/brokeranalytics_dg1.dat' scope=both sid='*';
sqlplus> alter system set dg_broker_config_file2 = '+DG_RECO/analytics_DG/BROKERCFG/brokeranalytics_dg2.dat' scope=both sid='*';
sqlplus> alter system set log_archive_dest_2='' scope=both sid='*' ;
sqlplus> alter system set DG_BROKER_START=FALSE scope=both sid='*';
sqlplus> alter system set DG_BROKER_START=TRUE scope=both sid='*';

7.3. Configurações do corretor:
$ dgmgrl
dgmgrl> connect sys/xxxxx@analytics
Connected as SYSDBA.
dgmgrl> create configuration 'analytics_cfg' as primary database is 'analytics' connect identifier is analytics;
Configuration "analytics_cfg" created with primary database "analytics"
dgmgrl> add database 'analytics_dg' as connect identifier is analytics_dg maintained as physical;
Database "analytics_dg" added
dgmgrl> edit database 'analytics_dg' set property logxptmode=async;
Property "logxptmode" updated
dgmgrl> edit configuration set protection mode as MAXPERFORMANCE;
Succeeded.
dgmgrl> enable configuration; 
Enabled.

Use o comando SHOW CONFIGURATION para mostrar um breve resumo das configurações.
dgmgrl> show configuration

Configuration - analytics_cfg
Protection Mode: MaxPerformance
Databases:
analytics - Primary database
analytics_dg - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS

7.4. Validar configurações com comandos
dgmgrl> show database verbose 'analytics_dg' 'RecvQEntries';
dgmgrl> show database verbose 'analytics';
dgmgrl> show database verbose 'analytics_dg';

Nó 1:
sqlplus> select NAME,OPEN_MODE,PROTECTION_MODE,PROTECTION_LEVEL,DATABASE_ROLE from v$database;
NAME OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE
--------- -------------------- -------------------- -------------------- -----------
analytics READ WRITE MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PRIMARY

Nó 2:
sqlplus> select NAME,OPEN_MODE,PROTECTION_MODE,PROTECTION_LEVEL,DATABASE_ROLE from v$database;
NAME OPEN_MODE PROTECTION_MODE PROTECTION_LEVE DATABASE_ROLE
--------- -------------------- -------------------- -------------------- -----------
analytics READ WRITE MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PRIMARY

DB em espera:
sqlplus> select NAME,OPEN_MODE,PROTECTION_MODE,PROTECTION_LEVEL,DATABASE_ROLE from v$database;
NAME OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE
--------- ---------------- -------------------- -------------------- ----------------
analytics MOUNTED MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PHYSICAL STANDBY

8. Os ajustes no Broker serão feitos nas configurações “MaxConnections”, “TransportDisconnectedThreshold” e “TransportLagThreshold” [1]
A propriedade “MaxConnections” especifica quantos processos ARCn serão usados ​​em paralelo para transferir dados de um arquivo de redo log para o site remoto quando houver um GAP no processo. Se MaxConnections for definido com um valor maior que 1, os serviços de transporte de redo usarão vários processos ARCn para transferir dados de um arquivo de log de redo para o modo de espera.

A propriedade “TransportDisconnectedThreshold” pode ser usada para criar um status de aviso para uma espera lógica ou física ou captura instantânea quando a última comunicação do banco de dados primário exceder o valor especificado da propriedade. O valor da propriedade é expresso em segundos.

A propriedade “TransportLagThreshold” pode ser usada para criar um status de aviso para uma espera lógica ou física ou captura instantânea quando o atraso no transporte do banco de dados exceder o valor especificado da propriedade. O valor da propriedade é expresso em segundos.
dgmgrl> edit database 'analytics' SET PROPERTY 'MaxConnections'= 4;
Property "MaxConnections" updated
dgmgrl> edit database 'analytics' SET PROPERTY TransportDisconnectedThreshold='180';
Property "transportdisconnectedthreshold" updated
dgmgrl> edit database 'analytics' SET PROPERTY TransportLagThreshold='900';
Property "transportlagthreshold" updated
dgmgrl> edit database 'analytics_dg' SET PROPERTY 'MaxConnections'= 4;
Property "MaxConnections" updated
dgmgrl> edit database 'analytics_dg' SET PROPERTY TransportDisconnectedThreshold='180';
Property "transportdisconnectedthreshold" updated
dgmgrl> edit database 'analytics_dg' SET PROPERTY TransportLagThreshold='900';
Property "transportlagthreshold" updated

9. Altere os archives da política de exclusão no banco de dados primário.
rman> CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO STANDBY;


Ativação do Dataguard ativo




10. Parar Redo Apply no broker
$ dgmgrl
dgmgrl> connect sys
dgmgrl> edit database 'analytics_dg' set state = 'apply-off';
dgmgrl> show database 'analytics_dg'

11. Abra a instância de espera no modo somente leitura.
sqlplus> alter database open read only;

12. Inicie o Redo Apply no broker
$ dgmgrl
dgmgrl> connect sys
dgmgrl> edit database 'analytics_dg' set state = 'apply-on';
dgmgrl> show database 'analytics_dg'
 

Referências



[1] Data Guard Broker. Disponível em:https://docs.oracle.com/cd/E11882_01/server.112/e40771/dbpropref.htm#DGBKR3781