Saturday, January 25, 2020

How to check Oracle Flex cluster and Flex ASM

Oracle FLEX ASM: The number of ASM instances which will be running in the cluster based on cardinality defined during the cluster configuration.

Flex Cluster need to be enabled for flex ASM.

The default cardinality is 3, can be changed with srvctl modify asm commands

Clients can connect to remote ASM instance either shared network or separate dedicated asm network.

Useful commands:
 srvctl status asm -detail

run at asmcmd command prompt:
showclsutermode
showclusterstate




Oracle Flex Cluster:
Oracle Flex Cluster is a type of cluster with Hub and leaf nodes. Hub nodes do have direct access to storage and its files (OCR, Voting disks, disk group files etc.)
.leaf nodes do not have direct access to shared storages. all leaf nodes communicatoin go via hub nodes. Flex Cluster need Flex ASM configured prior.

Useful Commands:
crsctl get node role config
crsctl get node role config -all
olsnodes  -n -s -a
crsctl get cluster mode status




Sunday, January 12, 2020

Plug Single Instance PDB from non ASM CDB to ASM RAC CDB with wallet configuration

Plug Single Instance PDB to RAC CDB


Objective : clone pdb from one cdb to another cdb. DB version : 12.2
our source is non RAC file system CDB, our target is ASM RAC CDB.

One may wonder why did we do unplug and plug in database when we have a simple way of doing pdb clone with database link. yes, doing pdb clone copy with database link is simple but we could not bring PDB across all 4 nodes of RAC, we could bring cloned pdb on only one instance, bring it on all the nodes gave UNDO Tablespace related issues. In RAC, each instances has their own UNDO, in non RAC db, there is only one undo, PDB clone gave issues to me hence I did via unplug and plug method. please past the steps or method of pdb clone from non-rac file system to ASM RAC CDB with database link if anyone has done it.thanks.



SQL> conn sys as sysdba
Enter password:


SQL> SQL>  alter session set container=EXP_IMP_PDB;

Session altered.

SQL> administer key management set keystore open identified by "password";

keystore altered.

SQL> administer key management  export encryption keys with secret "this is my secret password for the export" to '/tmp/mr/EXP_IMP_PDB.p12' identified by "password";

keystore altered.

SQL> conn sys as sysdba
Enter password:

Connected.
SQL> SQL> alter pluggable database EXP_IMP_PDB close immediate;

Pluggable database altered.

SQL>  ALTER PLUGGABLE DATABASE EXP_IMP_PDB UNPLUG INTO '/tmp/mr/EXP_IMP_PDB.xml';

Pluggable database altered.


Please Note:
Copy the files (XML +, wallet file, database files) to the target database host (you may use scp or zip or any other format to copy xml and all the datafiles of pluggable database that is being moved/cloned/made a copy from it)

-- move files to different RAC database host- move to any one of rac instance.

---- RAC CDB steps -- begin

create /tmp/mr/ folder , copy xml files and datafiles to this folder.

. oraenv
+ASM1

asmcmd
got to DATA, create folder structure to have the path

  +DATA/ORCL/88E8A407CFE57C1FE053A3A4580A3356/datafile

login into RAC CDB

  set serveroutput on;
 declare
  chk boolean := FALSE;
  begin
  chk :=DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file=>'/tmp/mr/EXP_IMP_PDB.xml',pdb_name=>'EXP_IMP_PDB');
  if chk then
  DBMS_OUTPUT.PUT_LINE('YES');
  else DBMS_OUTPUT.PUT_LINE('NO');
  end if;
  end;
  /


 create pluggable database EXP_IMP_PDB  using '/tmp/mr/EXP_IMP_PDB.xml' FILE_NAME_CONVERT=('/scratch/u01/app/oracle/oradata/ORCL/OMF/ORCL/','+DATA/ORCL/') copy;


alter pluggable database EXP_IMP_PDB open;



  SQL> alter pluggable database EXP_IMP_PDB open;

Warning: PDB altered with errors.

SQL>
SQL>
SQL> select name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS where name='EXP_IMP_PDB';

NAME
--------------------------------------------------------------------------------
CAUSE                                                            TYPE
---------------------------------------------------------------- ---------
MESSAGE
--------------------------------------------------------------------------------
STATUS
---------
EXP_IMP_PDB
Wallet Key Needed                                                ERROR
PDB needs to import keys from source.
PENDING

.....
9 rows selected.


SQL>  alter session set container=EXP_IMP_PDB;

Session altered.

SQL> administer key management set keystore open identified by "password";

keystore altered.

SQL> administer key management  import encryption keys with secret "this is my secret password for the export" from '/tmp/mr/EXP_IMP_PDB.p12' identified by "password"  with backup;


keystore altered.

SQL> SQL>


SQL> conn sys as sysdba
Enter password:


Connected.
SQL>  alter pluggable database EXP_IMP_PDB close immediate instances=all;

Pluggable database altered.

SQL>  alter pluggable database EXP_IMP_PDB open  instances=all;

Pluggable database altered.




---- RAC CDB steps -- end



--- plugin the pdb on same CDB in which unplug steps are done to make pdb same as what it was on same host ----------

  set serveroutput on;
 declare
  chk boolean := FALSE;
  begin
  chk :=DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file=>'/tmp/mr/EXP_IMP_PDB.xml',pdb_name=>'EXP_IMP_PDB');
  if chk then
  DBMS_OUTPUT.PUT_LINE('YES');
  else DBMS_OUTPUT.PUT_LINE('NO');
  end if;
  end;
  /


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


  drop pluggable database  EXP_IMP_PDB keep datafiles;





 Create pluggable database EXP_IMP_PDB using '/tmp/mr/EXP_IMP_PDB.xml' copy ;

 alter pluggable database EXP_IMP_PDB open;



  SQL> alter pluggable database EXP_IMP_PDB open;

Warning: PDB altered with errors.

SQL>
SQL>
SQL> select name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS where name='EXP_IMP_PDB';

NAME
--------------------------------------------------------------------------------
CAUSE                                                            TYPE
---------------------------------------------------------------- ---------
MESSAGE
--------------------------------------------------------------------------------
STATUS
---------
EXP_IMP_PDB
Wallet Key Needed                                                ERROR
PDB needs to import keys from source.
PENDING



SQL>  alter session set container=EXP_IMP_PDB;

Session altered.

SQL> administer key management set keystore open identified by "password";

keystore altered.

SQL> administer key management  import encryption keys with secret "this is my secret password for the export" from '/tmp/mr/EXP_IMP_PDB.p12' identified by "password"  with backup;


keystore altered.

SQL> SQL>


SQL> conn sys as sysdba
Enter password:


Connected.
SQL>  alter pluggable database EXP_IMP_PDB close immediate;

Pluggable database altered.

SQL>  alter pluggable database EXP_IMP_PDB open;

Pluggable database altered.