sábado, 9 de enero de 2016

Do it: Workshop Oracle Database 12c SE 2, Clonando una base de datos de un CDB a otro en el mismo servidor.

Sigue los siguientes pasos para clonar una base de datos PDB a otro contenedor en el mismo servidor.

Este laboratorio asume que usted tiene definidos 2 contenedores:

  • cdbmaster
  • cdb2

El CDB cdbmaster tiene un PDB llamado PDB1 que será la instancia que deseamos clonar al otro contenedor.

Recuerda que en esta versión 12.1.0.2 de SE2, el máximo de hilos por instancia o configuración en HA ( RAC ), no puede ser superior a 16, pero puedes tener tantos contenedores de 12c SE2, como combinaciones puedas hacer con tus procesadores ( máximo dos sockets físicos por configuración o servidor ).

Manos a la obra.

[oracle@oracle12cse2 oradata]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        58G   24G   31G  44% /
tmpfs           3.0G  1.3G  1.7G  43% /dev/shm
/dev/sda1       190M   54M  126M  31% /boot

[oracle@oracle12cse2 oradata]$ echo $ORACLE_SID
cdb2

[oracle@oracle12cse2 oradata]$ . oraenv
ORACLE_SID = [cdb2] ? cdb2
The Oracle base remains unchanged with value /opt/oracle/product

[oracle@oracle12cse2 oradata]$ sqlplus /nolog

SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 9 10:56:56 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> connect / as sysdba
Connected.

SQL> exit
Disconnected from Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
[oracle@oracle12cse2 oradata]$ . oraenv
ORACLE_SID = [cdb2] ? cdbmaster
The Oracle base remains unchanged with value /opt/oracle/product

[oracle@oracle12cse2 oradata]$ sqlplus /nolog

SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 9 10:57:21 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> connect / as sysdba
Connected.

SQL> alter pluggable database pdb1 close immediate;

Pluggable database altered.

SQL> alter pluggable database pdb1 open read only;

Pluggable database altered.

SQL> exit
Disconnected from Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
[oracle@oracle12cse2 oradata]$

[oracle@oracle12cse2 oradata]$ sqlplus /nolog

SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 9 11:00:39 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> connect / as sysdba
Connected.
SQL> set timing on
SQL> create pluggable database pdb_clone from pdb1@clone_link;

Pluggable database created.

Elapsed: 00:02:22.92

SQL> host ps -ef|grep cdb2
oracle    2833     1  0 10:52 ?        00:00:00 ora_pmon_cdb2
oracle    2835     1  0 10:52 ?        00:00:00 ora_psp0_cdb2
oracle    2837     1 10 10:52 ?        00:01:19 ora_vktm_cdb2
oracle    2841     1  0 10:52 ?        00:00:00 ora_gen0_cdb2
oracle    2843     1  0 10:52 ?        00:00:00 ora_mman_cdb2
oracle    2847     1  0 10:52 ?        00:00:00 ora_diag_cdb2
oracle    2849     1  0 10:52 ?        00:00:00 ora_dbrm_cdb2
oracle    2851     1  0 10:52 ?        00:00:03 ora_vkrm_cdb2
oracle    2853     1  0 10:52 ?        00:00:00 ora_dia0_cdb2
oracle    2855     1  0 10:52 ?        00:00:00 ora_dbw0_cdb2
oracle    2857     1  0 10:52 ?        00:00:00 ora_lgwr_cdb2
oracle    2859     1  0 10:52 ?        00:00:00 ora_ckpt_cdb2
oracle    2861     1  0 10:52 ?        00:00:00 ora_smon_cdb2
oracle    2863     1  0 10:52 ?        00:00:00 ora_reco_cdb2
oracle    2865     1  0 10:52 ?        00:00:00 ora_lreg_cdb2
oracle    2867     1  0 10:52 ?        00:00:00 ora_pxmn_cdb2
oracle    2869     1  1 10:52 ?        00:00:07 ora_mmon_cdb2
oracle    2871     1  0 10:52 ?        00:00:00 ora_mmnl_cdb2
oracle    2873     1  0 10:52 ?        00:00:00 ora_d000_cdb2
oracle    2875     1  0 10:52 ?        00:00:00 ora_s000_cdb2
oracle    2887     1  0 10:52 ?        00:00:00 ora_tmon_cdb2
oracle    2889     1  0 10:52 ?        00:00:00 ora_tt00_cdb2
oracle    2891     1  0 10:52 ?        00:00:00 ora_smco_cdb2
oracle    2893     1  0 10:52 ?        00:00:00 ora_w000_cdb2
oracle    2895     1  0 10:52 ?        00:00:00 ora_w001_cdb2
oracle    2897     1  0 10:52 ?        00:00:00 ora_aqpc_cdb2
oracle    2901     1  0 10:53 ?        00:00:00 ora_qm02_cdb2
oracle    2905     1  0 10:53 ?        00:00:00 ora_q002_cdb2
oracle    2907     1  0 10:53 ?        00:00:00 ora_q003_cdb2
oracle    2909     1  0 10:53 ?        00:00:03 ora_cjq0_cdb2
oracle    3233  3232  2 11:00 ?        00:00:07 oraclecdb2 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle    3559  3232  0 11:05 pts/0    00:00:00 /bin/bash -c ps -ef|grep cdb2
oracle    3561  3559  0 11:05 pts/0    00:00:00 grep cdb2

SQL> host ps -ef|grep pdb_clone
oracle    3573  3232  0 11:06 pts/0    00:00:00 /bin/bash -c ps -ef|grep pdb_clone
oracle    3575  3573  0 11:06 pts/0    00:00:00 grep pdb_clone

SQL>
SQL> desc v$pdbs
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 CON_ID                                             NUMBER
 DBID                                               NUMBER
 CON_UID                                            NUMBER
 GUID                                               RAW(16)
 NAME                                               VARCHAR2(30)
 OPEN_MODE                                          VARCHAR2(10)
 RESTRICTED                                         VARCHAR2(3)
 OPEN_TIME                                          TIMESTAMP(3) WITH TIME ZONE
 CREATE_SCN                                         NUMBER
 TOTAL_SIZE                                         NUMBER
 BLOCK_SIZE                                         NUMBER
 RECOVERY_STATUS                                    VARCHAR2(8)
 SNAPSHOT_PARENT_CON_ID                             NUMBER

SQL> select name, open_mode, con_id from v$pdbs;

NAME                           OPEN_MODE      CON_ID
------------------------------ ---------- ----------
PDB$SEED                       READ ONLY           2
PDB_CLONE                      MOUNTED             3

Elapsed: 00:00:00.01
SQL> alter pluggable database pdb_clone open;

Pluggable database altered.

Elapsed: 00:00:10.64
SQL> select name, open_mode, con_id from v$pdbs;

NAME                           OPEN_MODE      CON_ID
------------------------------ ---------- ----------
PDB$SEED                       READ ONLY           2
PDB_CLONE                      READ WRITE          3

Elapsed: 00:00:00.01

SQL> connect system/clone@pdb_clone;
Connected.
SQL> alter user hr account unlock;

User altered.

Elapsed: 00:00:00.11
SQL> alter user hr identified by hr;

User altered.

Elapsed: 00:00:02.68
SQL> connect hr/hr@pdb_clone
Connected.
SQL> select * from cat;

SQL> column table_name format a30
SQL> /

TABLE_NAME                     TABLE_TYPE
------------------------------ -----------
T1_2MILLON                     TABLE
T1_MILLON                      TABLE
T2                             TABLE
NUMERO_CONSEC_A_NIVEL_SESSION  SEQUENCE
ISEQ$$_92680                   SEQUENCE
IDENTIDAD_DEFACTO_NULOS        TABLE
ISEQ$$_92678                   SEQUENCE
IDENTIDAD_DEFACTO              TABLE
ISEQ$$_92676                   SEQUENCE
TEST_TABLE_INCREMENTAL         TABLE
EMPLEADOS                      TABLE
TEST_TABLE                     TABLE
EMP_DETAILS_VIEW               VIEW
JOB_HISTORY                    TABLE
EMPLOYEES_SEQ                  SEQUENCE
EMPLOYEES                      TABLE
JOBS                           TABLE
DEPARTMENTS_SEQ                SEQUENCE
DEPARTMENTS                    TABLE
LOCATIONS_SEQ                  SEQUENCE
LOCATIONS                      TABLE
COUNTRIES                      TABLE
REGIONS                        TABLE

23 rows selected.

Elapsed: 00:00:00.05
SQL>

SQL> host df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        58G   28G   28G  50% /
tmpfs           3.0G  1.3G  1.7G  43% /dev/shm
/dev/sda1       190M   54M  126M  31% /boot

SQL>

QL> connect / as sysdba
Connected.

SQL> select name from v$pdbs;

NAME
------------------------------
PDB$SEED
PDB_CLONE

Elapsed: 00:00:00.01
SQL> alter pluggable database pdb_clone close immediate;

Pluggable database altered.

Elapsed: 00:00:01.08
SQL> drop pluggable database pdb_clone including datafiles;

Pluggable database dropped.

Elapsed: 00:00:01.38
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> exit
Disconnected from Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production

[oracle@oracle12cse2 oradata]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        58G   24G   31G  44% /
tmpfs           3.0G  656M  2.3G  22% /dev/shm
/dev/sda1       190M   54M  126M  31% /boot
[oracle@oracle12cse2 oradata]$

No hay comentarios:

Publicar un comentario en la entrada

Te agradezco tus comentarios. Te esperamos de vuelta.