Sunday, 19 December 2021

clone non-cdb to another container pdb in 19c

User request to clone for specific pdb from non cdb prod database 

source :SELECT name,network_name,pdb FROM   v$active_services ORDER BY 1;

target : SELECT name,network_name,pdb FROM   v$active_services ORDER BY 1;

SOURCE :

   srvctl status database -d PROD

    srvctl status service database -d PROD

Target :

srvctl status service database -d xbduat -s xcuatsrv

srvctl config service -d xdbuat -s xcuatsrv

Target :

SRVCTL status service -d xdbuat

srvctl stop service -d xdbuat -s xcuatsrv

srvctl remove service -d xdbuat -s xcuatsrv

alter pluggable database xdbuat close immediate instances=all;

drop pluggable database xdbuat including datafiles;


Source:

create user ram identified by *****;

grant create session,create pluggable database to ram;

Target :

drop database link cdb_dblink;

create database link cdb_dblink connect to ram identified by ****** using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = prod-vip)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD)))'

select * from dual@cbd_dblink;

create pluggable database xdbuat from NON$CDB@cdb_dblink standbys=none;

----on standby side:

col name format a20

select name, recovery_status from v$pdbs;

select name,open_mode from v$pdbs;

ALTER SESSION SET CONTAINER=xdbuat;

@?/rdbms/admin/noncdb_to_pdb.sql

ALTER PLUGGABLE DATABASE xdbuat OPEN instances=all;

col cause for a15

col name for a15

col message for a35 word_wrapped

set line 200

set head off

select name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS where name='xdbuat';

alter pluggable database xdbuat open;

alter session set container=xdbuat;

select count(*) from dba_objects where status='INVALID'

@?/rdbms/admin/utlrp.sql

shut immediate    // inside the pdb

startup     //inside the pdb

select network_name from dba_services;

remove the service if not required.

BEGIN DBMS_SERVICE.STOP_SERVICE (SERVICE_NAME => 'cdsrv'); END;

/

BEGIN DBMS_SERVICE.DELETE_SERVICE (SERVICE_NAME => 'cdsrv'); END;

/

[oracle@ed ~]$ srvctl status service -d xdbuat -s xdbuatsrv


srvctl add service -d xdbuat  -service cdbsrv -pdb xdbuat -preferred drod3,drod4

srvctl start service -d xdbuat  -service cdbsrv 

srvctl status service -d xdbuat  -service cdbtsrv 


_____________happy learning_____________

No comments:

Post a Comment

Featured post

duplicate db from standy to other server

 Duplicate Testuat   $ export ORACLE_SID=Testuat3 $ sqlplus '/as sysdba' Testuat3 SQL> alter system set cluster_database=FALSE sc...