OCP 12C – Basics of Multitenant Container Database (CDB)

The multitenant architecture

  • Needs enterprise edition and the multitenant option.
  • Consists of a CDB (Container database) and zero, one or up to 252 PDBs (pluggable databases).
  • Has a root container (the CDB itself) and a seed container (template to create PDBs)
  • There is only one instance per CDB.
  • A PDB doesn’t have :
    • background processes
    • undo tablespace, it uses the CDB’s.
    • redologs, it uses the CDB’s.
    • controlfiles
  • A PDB have :
    • It’s own tablespaces
    • It’s own local users and local roles
    • It’s own metadata
  • A PDB CAN have :
    • a temporary tablespace or can use the CDB temporary tablespace.
    • it’s own Resource Manager Plan or can use the default CDB one.
  • Users can be common users (at the CDB level) or local users (local to a PDB)

Continue reading OCP 12C – Basics of Multitenant Container Database (CDB)

OCP 12C – Enterprise Manager and Other Tools

EM Database Express

  • The old Enterprise Manager database control is replaced by Enterprise Manager database express in Oracle 12c.
  • It contains only basic administration capabilities as the advanced ones are included in Enterprise Manager cloud control
  • With EM database Express you can manage Security (Users, roles, profiles), Configuration (Instance Parameters, memory, database features), Storage (tablespaces, undo, redo, archive logs, control files), Performance.
  • Enterprise Manager needs the XML DB component.
  • You can configure the port used by EM database Express using :  exec DBMS_XDB_CONFIG.setHTTPsPort(5500);
  • You can get the port configured for EM database Express using :  select DBMS_XDB_CONFIG.getHTTPsPort from dual;
  • The EM_EXPRESS_BASIC (read-only role)  and EM_EXPRESS_ALL (access all functionnalities) roles can be used to grant access to EM Database Express to non-administrative users.
  • You can’t start or stop your DB with EM database express, this means that you database is accessible through EM database express only when you opened it.
  • Listener should be up and running for access to EM Express being possible.
  • Alternative for performing some DBA admin tasks is the DBA tab of SQLDeveloper

 

Datafile space reclaimable report.

This script will help you find the space reclaimable in your datafiles, it finds the High Water Mark of all your datafiles (the minimum size) and then report the following information:

  • Datafile Size
  • Datafile HWM
  • Percentage of space reclaimable
  • Command to resize the datafile
  • Total space reclaimable in your datafiles
  • Percentage of space reclaimable in your datafiles

Find space reclaimable in the datafiles

set pages 1000
set serveroutput on
set lines 500

DECLARE 
		
	v_hwm number :=0;
	v_current_size number :=0;
	v_percent_gain number :=0;
	v_total_space_rec number :=0;
	v_total_data_size number :=0;
		
BEGIN
	
	for v_file_info in (select FILE_NAME, FILE_ID, BLOCK_SIZE 
						from dba_tablespaces tbs, dba_data_files df 
						where tbs.tablespace_name = df.tablespace_name)
	loop
		select ceil( (nvl(hwm,1) * v_file_info.block_size)/1024/1024 ) ,
			   ceil( blocks * v_file_info.block_size/1024/1024) into v_hwm,v_current_size
		from dba_data_files a,
		( select file_id, max(block_id+blocks-1) hwm
		  from dba_extents
		  group by file_id ) b
	   where a.file_id = b.file_id(+)
	   and a.file_id = v_file_info.file_id;
	   
	   v_total_space_rec := v_total_space_rec +(v_current_size-v_hwm);
	   v_total_data_size := v_total_data_size +v_current_size;
		  
		dbms_output.put_line(v_file_info.file_name || ':');
		dbms_output.put_line('Current size: ' || v_current_size || 'M' );
		dbms_output.put_line('HWM: ' || v_hwm || 'M' );
		dbms_output.put_line('Percentage reclaimable: ' || round((v_current_size-v_hwm)*100/v_current_size,2) || '%');
		dbms_output.put_line('Use following command to resize: ALTER DATABASE DATAFILE ''' || v_file_info.file_name || ''' RESIZE ' || v_hwm|| 'M;');
		
		dbms_output.put_line('	');
		dbms_output.put_line('	');
	end loop;
	
	dbms_output.put_line('Total datafiles size reclaimable: ' || v_total_space_rec || 'M');
	dbms_output.put_line('Percentage of space reclaimable in the datafiles: ' || round(v_total_space_rec*100/v_total_data_size,2) || '%');
END;
/