Creare un database principale di test

Determinare il metodo migliore per duplicare i dati per ognuno degli ambienti di sviluppo e test in base alla frequenza e alla velocità di aggiornamento delle informazioni.

Consultare le istruzioni sulla frequenza di aggiornamento dei dati riportate di seguito per determinare il metodo migliore per duplicare il database di produzione e creare il database principale di test.

  • Aggiornamenti frequenti (giornalieri, settimanali): creare un database principale di test come database in standby fisico.
  • Aggiornamenti normali (bi-weekly, mensilmente): creare un database principale di test da un database attivo utilizzando RMAN DUPLICATE
  • Aggiornamenti convenzionali (trimestrali e ogni anno): creare un database principale di test utilizzando il backup completo di RMAN.

Crea un database principale di test come database in standby fisico

Creare un database principale di test che sia un database in standby fisico quando è necessario eseguire sempre la sincronizzazione con la produzione.

Il database in standby fisico è il database principale di test per la creazione degli snapshot e non utilizzare il database principale di test per il recupero da errori irreversibili. Gli snapshot vengono creati sullo stesso server del database principale di test su Oracle ACFS.

In questo esempio viene utilizzato Oracle Database versione 12.1.0.2 con i seguenti nomi:

  • Istanza database di produzione di origine: PRODDB (il nome PDB è PDB1)
  • Istanza di database principale di test: TSTMSTR (il nome PDB è PDB1)
Aggiungere la voce Nome host database principale di test alla directory /etc/hosts del database di produzione, configurare le porte sul database principale di test e configurare Oracle Data Guard tra i database principali di produzione e di test.
  1. Duplicare il database di produzione per creare un database principale di test come database in standby fisico.

    Utilizzare le opzioni gDBClone riportate di seguito per creare un database in standby fisico.

    • -sdbname: nome del database di origine
    • -sdbscan: nome SCAN host del database di origine
    • -sdbport: porta listener SCAN di origine (impostazione predefinita: 1521)
    • -tdbname: nome del database di destinazione
    • -tdbhome: home page del database di destinazione
    • -tdbport: porta listener SCAN di destinazione (impostazione predefinita: 1521)
    • -racmod: tipo Oracle RAC, utilizzare 0 per un database Oracle a istanza singola
    • -dataacfs: file di dati del database di destinazione memoria Oracle ACFS
    • -redoacfs: la memorizzazione Oracle ACFS di destinazione dei redo log del database (impostazione predefinita: dataacfs).
    • -recoacfs: memorizzazione Oracle ACFS di destinazione per il recupero del database (impostazione predefinita: dataacfs)
    • -channels: canali RMAN allocati (impostazione predefinita: 3)
    • -standby: la copia (snap) è un database in standby fisico.
    • -pmode: le opzioni della modalità Standby sono maxperf, maxavail e maxprot (valore predefinito: maxperf)
    • -activedg: abilita Active Data Guard
    • -syspwf: password file cifrato SYS
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone clone -sdbname PRODDB_iad1df.bass1.ebsvcn.examplevcn.com -sdbscan proddb.bass1.ebsvcn.examplevcn.com sdbport 1521 -tdbname TSTMSTR -tdbhome OraDB12102_home2 -tdomain bass1.ebsvcn.examplevcn.com -tdbport 1521 -racmod 0 -dataacfs /u02/app/oracle/oradata/TSTMSTR -redoacfs /u03/app/oracle/redo -recoacfs /u03/app/oracle/fast_recovery_area -channels 2 -standby -pmode maxperf -activedg -rtapply -noping -syspwf /opt/gDBClone/SYS.password
  2. Verificare che le informazioni sul database principale di test siano corrette.
    [oracle@tstmstr TSTMSTR]$ cat /etc/oratab|grep -i TSTMSTR
  3. Visualizzare una lista dei database utilizzando il comando gDBClone listdbs per confermare che il ruolo e la posizione sono corretti per il database in standby.
    Utilizzare il comando gDBClone listdbs -tree per visualizzare le relazioni padre/figlio.
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone listdbs
    Database Name    Database Type   Database Role      Master/Snapshot  Location/Parent
    -------------    -------------   -------------      ---------------  ---------------
    ORCL_iad1hb      SINGLE          PRIMARY            n/a              ASM            
    TSTMSTR          SINGLE          PHYSICAL_STANDBY   Master           /u02/app/oracle/oradata/TSTMSTR/.ACFS/snaps/
    
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone listdbs -tree
    Parent	Child
    ------	-----
    TSTMSTR
  4. Impostare le variabili di ambiente del cluster per il database principale di test.
    Configura il database principale di test come database in standby fisico di sola lettura.
    [oracle@tstmstr ~]$ srvctl getenv database -d TSTMSTR
    TSTMSTR:
    [oracle@tstmstr ~]$ 
    [oracle@tstmstr ~]$ srvctl setenv database -d TSTMSTR -envs "ORACLE_UNQNAME=TSTMSTR,TZ=UTC"
    [oracle@tstmstr ~]$ srvctl getenv database -d TSTMSTR
    TSTMSTR:
    ORACLE_UNQNAME=TSTMSTR
    TZ=UTC
    [oracle@tstmstr ~]$ 
    
    [oracle@tstmstr ~]$ . oraenv
    ORACLE_SID = [oracle] ? TSTMSTR
    The Oracle base has been set to /u01/app/oracle
    [oracle@tstmstr ~]$ srvctl config database -d TSTMSTR
    Database unique name: TSTMSTR
    Database name: 
    Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_2
    Oracle user: oracle
    Spfile: /u02/app/oracle/oradata/TSTMSTR/.ACFS/snaps/TSTMSTR/TSTMSTR/spfileTSTMSTR.ora
    Password file: 
    Domain: bass1.ebsvcn.examplevcn.com
    Start options: read only
    Stop options: immediate
    Database role: PHYSICAL_STANDBY
    Management policy: AUTOMATIC
    Server pools: 
    Disk Groups: 
    Mount point paths: /u02/app/oracle/oradata/TSTMSTR,/u03/app/oracle/
    Services: 
    Type: SINGLE
    OSDBA group: dba
    OSOPER group: dbaoper
    Database instance: TSTMSTR
    Configured nodes: tstmstr
    Database is administrator managed
    [oracle@tstmstr ~]$
  5. Riavviare il database principale di test.
    
    [oracle@tstmstr ~]$ srvctl stop database -d TSTMSTR
    [oracle@tstmstr ~]$ srvctl start database -d TSTMSTR
  6. Controllare lo stato del wallet TDE nel database principale di test.
    Lo stato del wallet deve essere OPEN e il tipo di wallet deve essere AUTOLOGIN.
    [oracle@tstmstr ~]$ export 
    ORACLE_UNQNAME=TSTMSTR
    [oracle@tstmstr ~]$ sqlplus / as sysdba
    SQL*Plus: Release 12.1.0.2.0 Production on Thu Sep 30 06:44:14 2019
    Copyright (c) 1982, 2014, Oracle.  All rights reserved.
    
    Connected to:Oracle Database 12c EE High Perf Release 
    12.1.0.2.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics
    and Real Application Testing options
    
    SQL> set linesize 180
    SQL> col wrl_parameter format a80
    SQL> select * from v$encryption_wallet;
    
    WRL_TYPE   WRL_PARAMETER                                      STATUS       WALLET_TYPE  WALLET_OR  FULLY_BAC   CON_ID
    --------  ------------ -------------------------------------  -----------  -----------  ---------  ---------   -------
    FILE      /opt/oracle/dcs/commonstore/wallets/tde/TSTMSTR/    OPEN         AUTOLOGIN    SINGLE     NO         0
    
  7. Controllare lo stato del database principale di test.
    SQL> select name,open_mode,database_role from v$database;
    
    NAME	  OPEN_MODE	       DATABASE_ROLE
    --------- -------------------- ----------------
    PRODDB	  MOUNTED	       PHYSICAL STANDBY
    
    SQL> show pdbs
    
        CON_ID CON_NAME			  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    	 2 PDB$SEED			  MOUNTED
    	 3 PDB1 			     MOUNTED
    
  8. Verificare che il database in standby fisico sia sincronizzato con la produzione.
    È possibile cambiare alcuni file di log nella produzione e controllare se redo viene trasportato e applicato nel database principale di test.
    SQL> select sequence#,archived,applied from v$archived_log order by sequence#;
    
Il database principale di test è un database in standby fisico e viene sincronizzato con il database di produzione. È possibile creare uno snapshot del database in qualsiasi momento.

Creare un database principale di test da un database attivo

Creare una copia di database da un database di produzione in linea utilizzando Oracle Recovery Manager (RMAN) Duplicazione attiva quando è necessario aggiornare periodicamente un ambiente di test.

In questo esempio viene utilizzato Oracle Database versione 12.1.0.2 con i seguenti nomi:

  • Istanza database di produzione di origine: PRODDB (il nome PDB è PDB1)
  • Istanza di database principale di test: TSTMSTR (il nome PDB è PDB1)
Aggiungere il database principale di test alla directory, configurare la porta e configurare Oracle Data Guard sull'istanza di database di produzione.
  1. Creare un database principale di test utilizzando la duplicazione attiva di RMAN.

    Utilizzare le opzioni gDBClone riportate di seguito per creare un database in standby fisico.

    • -sdbname: nome del database di origine
    • -sdbscan: nome SCAN host del database di origine
    • -sdbport: porta listener SCAN di origine (impostazione predefinita: 1521)
    • -tdbname: nome del database di destinazione
    • -tdbhome: home page del database di destinazione
    • -tdbport: porta listener SCAN di destinazione (impostazione predefinita: 1521)
    • -racmod: tipo Oracle RAC, utilizzare 0 per un database Oracle a istanza singola
    • -dataacfs: file di dati del database di destinazione memoria Oracle ACFS
    • -redoacfs: la memorizzazione Oracle ACFS di destinazione dei redo log del database (impostazione predefinita: dataacfs).
    • -recoacfs: memorizzazione Oracle ACFS di destinazione per il recupero del database (impostazione predefinita: dataacfs)
    • -channels: canali RMAN allocati (impostazione predefinita: 3)
    • -standby: la copia (snap) è un database in standby fisico.
    • -pmode: le opzioni della modalità Standby sono maxperf, maxavail e maxprot (valore predefinito maxperf)
    • -activedg: abilita Active Data Guard
    • -syspwf: password file cifrato SYS
    root@tstmstr gDBClone]# /opt/gDBClone/gDBClone clone -sdbname PRODDB_iad1df.bassubad1.ebsvcn.oraclevcn.com -sdbscan proddb.bassubad1.ebsvcn.oraclevcn.com sdbport 1521 -tdbname TSTMSTR -tdbhome OraDB12102_home2 -tdomain bassubad1.ebsvcn.oraclevcn.com -tdbport 1521 -racmod 0 -dataacfs /u02/app/oracle/oradata/TSTMSTR -redoacfs /u03/app/oracle/redo -recoacfs /u03/app/oracle/fast_recovery_area -channels 2 -noping -syspwf /opt/gDBClone/SYS.password
    
  2. Verificare che le informazioni sul database principale di test siano corrette.
    [oracle@tstmstr TSTMSTR]$ cat /etc/oratab|grep -i TSTMSTR
  3. Visualizzare una lista dei database utilizzando il comando gDBClone listdbs per confermare che il ruolo e la posizione sono corretti per il database in standby.
    Utilizzare il comando gDBClone listdbs -tree per visualizzare le relazioni padre/figlio.
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone listdbs
    Database Name    Database Type   Database Role      Master/Snapshot  Location/Parent
    -------------    -------------   -------------      ---------------  ---------------
    ORCL_iad1hb      SINGLE          PRIMARY            n/a              ASM            
    TSTMSTR          SINGLE          PRIMARY            Master           /u02/app/oracle/oradata/TSTMSTR/.ACFS/snaps/
    
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone listdbs -tree
    Parent	Child
    ------	-----
    TSTMSTR
  4. Impostare le variabili di ambiente del cluster per il database principale di test.
    Configura il database principale di test come database in standby fisico di sola lettura.
    
    [oracle@tstmstr ~]$ srvctl getenv database -d TSTMSTR
    TSTMSTR:
    [oracle@tstmstr ~]$ 
    [oracle@tstmstr ~]$ srvctl setenv database -d TSTMSTR -envs "ORACLE_UNQNAME=TSTMSTR,TZ=UTC"
    [oracle@tstmstr ~]$ srvctl getenv database -d TSTMSTR
    TSTMSTR:
    ORACLE_UNQNAME=TSTMSTR
    TZ=UTC
    [oracle@tstmstr ~]$ 
    
    [oracle@tstmstr ~]$ . oraenv
    ORACLE_SID = [oracle] ? TSTMSTR
    The Oracle base has been set to /u01/app/oracle
    [oracle@tstmstr TSTMSTR]$ srvctl getenv database -d TSTMSTR
    TSTMSTR:
    ORACLE_UNQNAME=TSTMSTR
    TZ=UTC
    [oracle@tstmstr TSTMSTR]$ srvctl config database -d TSTMSTR
    Database unique name: TSTMSTR
    Database name: 
    Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_2
    Oracle user: oracle
    Spfile: /u02/app/oracle/oradata/TSTMSTR/.ACFS/snaps/TSTMSTR/TSTMSTR/spfileTSTMSTR.ora
    Password file: 
    Domain: 
    Start options: open
    Stop options: immediate
    Database role: PRIMARY
    Management policy: AUTOMATIC
    Server pools: 
    Disk Groups: 
    Mount point paths: /u02/app/oracle/oradata/TSTMSTR,/u03/app/oracle/
    Services: 
    Type: SINGLE
    OSDBA group: dba
    OSOPER group: dbaoper
    Database instance: TSTMSTR
    Configured nodes: tstmstr
    Database is administrator managed
    [oracle@tstmstr TSTMSTR]$ 
    
  5. Riavviare il database principale di test.
    [oracle@tstmstr ~]$ srvctl stop database -d TSTMSTR
    [oracle@tstmstr ~]$ srvctl start database -d TSTMSTR
  6. Controllare lo stato del wallet TDE (Transparent Data Encryption) nel database principale di test.
    Lo stato del wallet deve essere OPEN e il tipo di wallet deve essere AUTOLOGIN.
    [oracle@tstmstr ~]$ export ORACLE_UNQNAME=TSTMSTR
    [oracle@tstmstr ~]$ sqlplus / as sysdba
    SQL*Plus: Release 12.1.0.2.0 Production on Thu Sep 30 06:44:14 2019
    Copyright (c) 1982, 2014, Oracle.  All rights reserved.
    
    Connected to:
    Oracle Database 12c EE High Perf Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics
    and Real Application Testing options
    
    SQL> set linesize 180
    SQL> col wrl_parameter format a80
    SQL> select * from v$encryption_wallet;
    
    WRL_TYPE   WRL_PARAMETER					   STATUS	WALLET_TYPE   WALLET_OR   FULLY_BAC   CON_ID
    --------   -------------------------------------------------  ----------- -------------  ---------   ----------- -------
    FILE	/opt/oracle/dcs/commonstore/wallets/tde/TSTMSTR/   OPEN	 AUTOLOGIN      SINGLE      NO	   0
    
  7. Controllare lo stato del database principale di test e verificare che il MOUNT dei database collegabili (PDB) sia stato eseguito.
    SQL> select name,open_mode,database_role from v$database;
    
    NAME	  OPEN_MODE	       DATABASE_ROLE
    --------- -------------------- ----------------
    TSTMSTR   READ WRITE	       PRIMARY
    
    SQL> show pdbs
    
        CON_ID CON_NAME			  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    	 2 PDB$SEED			  MOUNTED
    	 3 PDB1 			     MOUNTED
    
Quando il database principale di test è disponibile, è possibile creare un database thin clone (snapshot). Quando il database principale di test non è aggiornato, aggiornare la copia del database principale di test dal database di produzione prima di creare uno snapshot.

Creare un database principale di test da un backup completo del database

Creare una copia di backup completa del database di produzione di origine su Oracle Cloud Infrastructure File Storage Service quando il database principale di test richiede alcuni aggiornamenti. Creare il backup con Oracle Recovery Manager (RMAN) duplicato attivo e caricare il backup nel server principale di test.

In questo esempio viene utilizzato Oracle Database versione 12.1.0.2 con i seguenti nomi:

  • Istanza database di produzione di origine: PRODDB (il nome PDB è PDB1)
  • Istanza di database principale di test: TSTMSTR (il nome PDB è PDB1)
  1. Creare un backup del database di produzione impostando l'ambiente clone e copiando il database con RMAN.
    Utilizzare le seguenti opzioni gDBClone:
    • -sdbname: nome del database di origine
    • -sbckloc: posizione del backup completo RMAN di origine
    • -tdbname: nome del database di destinazione
    • -tdbhome: home page del database di destinazione
    • -sdbport: porta listener SCAN di origine (impostazione predefinita: 1521)
    • -racmod: modello Oracle Real Application Clusters (Oracle RAC), utilizzare 0 per un database Oracle a istanza singola
    • -dataacfs: i file di dati del database utilizzano la memorizzazione Oracle ASM Cluster File System (Oracle ACFS) di destinazione.
    • -redoacfs: il database redo registra la memoria Oracle ACFS di destinazione (impostazione predefinita: dataacfs)
    • -recoacfs: memorizzazione Oracle ACFS di destinazione per il recupero del database (impostazione predefinita: dataacfs)
    • -channels: canali RMAN allocati (impostazione predefinita: 3)
    • -syspwf: password file cifrato SYS
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone clone -sdbname TSTMSTR -sbckloc '/mnt/fss/dbbackup'  -tdbname TSTDEV -tdbhome OraDB12102_home2 -tdbport 1521 -racmod 0 -dataacfs /u02/app/oracle/oradata/TSTMSTR -redoacfs /u03/app/oracle/redo -recoacfs /u03/app/oracle/fast_recovery_area -channels 2 -noping -syspwf /opt/gDBClone/SYS.password
    Lo script convalida l'impostazione, imposta l'ambiente di copia e crea un database di copia.
  2. Verificare che le informazioni sul database principale di test siano corrette.
    [oracle@tstmstr TSTMSTR]$ cat /etc/oratab|grep -i TSTMSTR
    
  3. Visualizzare una lista dei database utilizzando il comando gDBClone listdbs per confermare che il ruolo e la posizione sono corretti per il database in standby.
    Utilizzare il comando gDBClone listdbs -tree per visualizzare le relazioni padre/figlio.
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone listdbs
    Database Name    Database Type   Database Role      Master/Snapshot  Location/Parent
    -------------    -------------   -------------      ---------------  ---------------
    ORCL_iad1hb      SINGLE          PRIMARY            n/a              ASM            
    TSTMSTR          SINGLE          PRIMARY            Master           /u02/app/oracle/oradata/TSTMSTR/.ACFS/snaps/
    [root@tstmstr gDBClone]# 
    
    [root@tstmstr gDBClone]# /opt/gDBClone/gDBClone listdbs -tree
    Parent	Child
    ------	-----
    TSTMSTR
    
  4. Impostare i parametri di ambiente del cluster per il database principale di test.
    [oracle@tstmstr ~]$ srvctl getenv database -d TSTMSTR
    TSTMSTR:
    [oracle@tstmstr ~]$ 
    [oracle@tstmstr ~]$ srvctl setenv database -d TSTMSTR -envs "ORACLE_UNQNAME=TSTMSTR,TZ=UTC"
    [oracle@tstmstr ~]$ srvctl getenv database -d TSTMSTR
    TSTMSTR:
    ORACLE_UNQNAME=TSTMSTR
    TZ=UTC
    [oracle@tstmstr ~]$ 
    
    [oracle@tstmstr ~]$ . oraenv
    ORACLE_SID = [oracle] ? TSTMSTR
    The Oracle base has been set to /u01/app/oracle
    [oracle@tstmstr TSTMSTR]$ srvctl getenv database -d TSTMSTR
    TSTMSTR:
    ORACLE_UNQNAME=TSTMSTR
    TZ=UTC
    [oracle@tstmstr TSTMSTR]$ srvctl config database -d TSTMSTR
    Database unique name: TSTMSTR
    Database name: 
    Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_2
    Oracle user: oracle
    Spfile: /u02/app/oracle/oradata/TSTMSTR/.ACFS/snaps/TSTMSTR/TSTMSTR/spfileTSTMSTR.ora
    Password file: 
    Domain: 
    Start options: open
    Stop options: immediate
    Database role: PRIMARY
    Management policy: AUTOMATIC
    Server pools: 
    Disk Groups: 
    Mount point paths: /u02/app/oracle/oradata/TSTMSTR,/u03/app/oracle/
    Services: 
    Type: SINGLE
    OSDBA group: dba
    OSOPER group: dbaoper
    Database instance: TSTMSTR
    Configured nodes: tstmstr
    Database is administrator managed
    [oracle@tstmstr TSTMSTR]$ 
    
  5. Riavvia database principale di test
    
    [oracle@tstmstr ~]$ srvctl stop database -d TSTMSTR
    [oracle@tstmstr ~]$ srvctl start database -d TSTMSTR
  6. Controllare lo stato del wallet TDE (Transparent Data Encryption) nel database principale di test.
    Il wallet deve essere OPEN con AUTOLOGIN.
    [oracle@tstmstr ~]$ export ORACLE_UNQNAME=TSTMSTR
    [oracle@tstmstr ~]$ sqlplus / as sysdba
    SQL*Plus: Release 12.1.0.2.0 Production on Thu Sep 30 06:44:14 2019
    Copyright (c) 1982, 2014, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 12c EE High Perf Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics
    and Real Application Testing options
    
    SQL> set linesize 180
    SQL> col wrl_parameter format a80
    SQL> select * from v$encryption_wallet;
    
    WRL_TYPE    WRL_PARAMETER					    STATUS	WALLET_TYPE	   WALLET_OR  FULLY_BAC   CON_ID
    --------    -------------------------------------------------   ----------- -------------------- ---------   ----------- -------
    FILE	 /opt/oracle/dcs/commonstore/wallets/tde/TSTMSTR/    OPEN	 AUTOLOGIN	      SINGLE     NO	   0
    
  7. Controllare lo stato del database principale di test e verificare che il MOUNT dei database collegabili (PDB) sia stato eseguito.
    Il database TSTMSTR deve essere in modalità lettura/scrittura e in stato MOUNTED.
    SQL> select name,open_mode,database_role from v$database;
    
    NAME	  OPEN_MODE	  DATABASE_ROLE
    --------- -------------------- ----------------
    TSTMSTR   READ WRITE	    PRIMARY
    SQL> 
    SQL> show pdbs
    
        CON_ID CON_NAME			 OPEN MODE  RESTRICTED
    ---------- ----------------------------- ---------- ----------
    	 2 PDB$SEED			  MOUNTED
    	 3 PDB1 			     MOUNTED
    
Il database principale di test è una copia di backup completa del database di produzione di origine.
Creare uno snapshot del database. Quando il database principale di test non è aggiornato, aggiornare il database principale di test di backup dal database di produzione prima di creare uno snapshot.