Monday, 28 February 2022
Flashback Oracle RAC Database with Dataguard
Oracle Database smon recovery -- Disable , enable and Tuning Rollback
Oracle Database smon recovery -- Disable , enable and Tuning Rollback
We can speed up and slowdown rollback seeing business hours .
If Undo tablespace is used up and rollback is slow , we can add new undo tablespace and change default undo tablespace
If smon recovery is causing performance issues we may opt to disable smon recovery temporarily and re-enable back after business hours . Similarly we can speed up and reduce speed of smon recovery
select sql_text
from v$sqlarea
where address = (select sql_address from v$session where sid in (select SID
from v$transaction,dba_rollback_segs,v$session
where SADDR=SES_ADDR and
XIDUSN=SEGMENT_ID and
flag=7811));
select * from v$fast_start_servers;
select pid, spid from v$process where pid in ( select pid from v$fast_start_servers);
select pid, program from v$process where program like '%SMON%'; -
oradebug setorapid 10
select 'alter system kill session '''||s.sid||','||s.serial#||''' immediate;', 'kill -9 '||spid from v$session s, (select * from v$process
where pid in (select pid from v$fast_start_servers)) p
where s.paddr=p.addr;
alter system set fast_start_parallel_rollback=false;
select * from v$fast_start_servers;
select pid from v$fast_start_servers ;
show parameter fast
oradebug event 10513 trace name context off ;
Speed up smon recovery
1)
select * from v$fast_start_servers;
If all the processes are in state RECOVERING, then you can benefit from adding more processes:
SQL> alter system set fast_start_parallel_rollback = high;
This will create parallel servers as much as 4 times the number of CPUs.
2)
Increase the parameter ‘_cleanup_rollback_entries’ to 400. The default is 100.
This parameter cannot be changed dynamically, so in order to change this the database will need to be restarted. As outlined above this is not advisable and basically needs to be done when no alternative. This needs to be done only on suggestion of Oracle support
CONVERT NON-CONTAINER ORACLE DB TO CONTAINER DB
Here are the two situations:
There is no direct way to convert a Non-Container 12C database to Container 12C database. All you can do is to consider Non-Container database as a pluggable database(PDB) and attach it to the existing 12C container database.
With that said - How to create a PDB Using a Non-CDB?
Both the CDB and the non-CDB must be running Oracle Database 12c Release 1 (12.1.0.2) or later.
If your current non-CDB uses an Oracle Database release before Oracle Database 12c Release 1 (12.1.0.2), then you must upgrade the non-CDB to Oracle Database 12C.
Once you have both your Non-Container database and Container database running on 12C,
When transporting a non-CDB from an Oracle Database 11g Release 2 (11.2.0.3) or later Oracle Database 11g database to Oracle Database 12c, the VERSION Data Pump export parameter must be set to 12.0.0.0.0 or higher.
How to Change DBID of a Single-Instance Database
For a duplicate database, you may want to change its Database Identifier (DBID) only in order to distinguish this one from another.
Here we use nid, a DBNEWID utility provided by Oracle to change DBID only.
Let's check DBID before changing.
[oracle@test ~]$ sqlplus / as sysdba
...
SQL> select name, dbid from v$database;
NAME DBID
--------- ----------
TESTCDB 3411734329
We restart the database to MOUNT state.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
...
Database mounted.
Next, we use nid to connect to the database. Without specifying DBNAME, nid will change only DBID. There're more options of nid syntax in Oracle documentation.
[oracle@test ~]$ nid target=sys
Or connect to the database via a TNS name.
[oracle@test ~]$ nid target=sys@testcdb
DBNEWID: Release 19.0.0.0.0 - Production on Mon Dec 21 21:00:40 2020
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Password:
Connected to database TESTCDB (DBID=3411734329)
Connected to server version 19.9.0
Control Files in database:
/u01/app/oracle/oradata/TESTCDB/control01.ctl
/u01/app/oracle/fast_recovery_area/TESTCDB/control02.ctl
Change database ID of database TESTCDB? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 3411734329 to 3425699846
Control File /u01/app/oracle/oradata/TESTCDB/control01.ctl - modified
Control File /u01/app/oracle/fast_recovery_area/TESTCDB/control02.ctl - modified
Datafile /u01/app/oracle/oradata/TESTCDB/system01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/sysaux01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/undotbs01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/pdbseed/system01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/pdbseed/sysaux01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/users01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/pdbseed/undotbs01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/ORCLPDB1/system01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/ORCLPDB1/sysaux01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/ORCLPDB1/undotbs01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/ORCLPDB1/users01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/ORCLPDB1/example01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/temp01.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/pdbseed/temp012020-07-14_23-10-41-107-PM.db - dbid changed
Datafile /u01/app/oracle/oradata/TESTCDB/ORCLPDB1/temp01.db - dbid changed
Control File /u01/app/oracle/oradata/TESTCDB/control01.ctl - dbid changed
Control File /u01/app/oracle/fast_recovery_area/TESTCDB/control02.ctl - dbid changed
Instance shut down
Database ID for database TESTCDB changed to 3425699846.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.
Since the database identifier has been changed, we have to open the database with resetlogs.
[oracle@test ~]$ sqlplus / as sysdba
...
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
...
Database mounted.
SQL> alter database open resetlogs;
Database altered.
A new DBID now service the database.
SQL> select name, dbid from v$database;
NAME DBID
--------- ----------
TESTCDB 3425699846
Done!
Sunday, 27 February 2022
Oracle Multitenant / Container Database -- PDB / CDB
Oracle Multitenant/Container Database :-
2) When we open Container database seed database is in read only mode and Pdb are in mount stage
3) Background processes and memory allocation are at CDB level only
The PDB_FILE_NAME_CONVERT Initialization Parameter
9) A PDB would have its SYSTEM, SYSAUX, TEMP tablespaces.It can also contains other user created tablespaces in it
10) For revoking privilege from common user
If the current container is the root:
/ Specify CONTAINER = CURRENT to revoke a locally granted system privilege, object privilege, or role from a common user or common role. The privilege or role is revoked from the user or role only in the root. This clause does not revoke privileges granted with CONTAINER = ALL.
/ Specify CONTAINER = ALL to revoke a commonly granted system privilege, object privilege on a common object, or role from a common user or common role. The privilege or role is revoked from the user or role across the entire CDB. This clause can revoke only a privilege or role granted with CONTAINER = ALL from the specified common user or common role. This clause does not revoke privileges granted locally with CONTAINER = CURRENT. However, any locally granted privileges that depend on the commonly granted privilege being revoked are also revoked.
If you omit this clause, then CONTAINER = CURRENT is the default.
11) When we restart CDB , be default Seed will be in Read only mode and all PDB will be in mount stage
How to check if database is Container Database / CDB:
Undo Management :
Interesting behavior in 12.1.0.1 DB of creating an undo tablespace in a PDB. With the new Multitenant architecture the undo tablespace resides at the CDB level and PDBs all share the same UNDO tablespace. When the current container is a PDB, an attempt to create an undo tablespace fails without returning an error.
column property_name format a30
column property_value format a30
select property_name, property_value
from database_properties
where property_name = 'LOCAL_UNDO_ENABLED';
PROPERTY_NAME PROPERTY_VALUE
------------------------------ ------------------------------
LOCAL_UNDO_ENABLED TRUE
SQL>
select con_id, tablespace_name
from cdb_tablespaces
where contents = 'UNDO'
order by con_id;
CON_ID TABLESPACE_NAME
---------- ------------------------------
1 UNDOTBS1
3 UNDOTBS1
SQL>
conn / as sysdba
shutdown immediate;
startup upgrade;
alter database local undo off;
shutdown immediate;
startup;
conn / as sysdba
-- Just the root container.
alter system set undo_retention=3000;
-- The root container and all PDBs.
alter system set undo_retention=3000 container=all;
A PDB can either have its owner temporary tablespace, or if it is created without a temporary tablespace, it can share the temporary tablespace with the CBD.
ALTER SESSION SET CONTAINER = pdb1;
CREATE TABLESPACE dummy
DATAFILE '/u01/app/oracle/oradata/cdb1/pdb1/dummy01.dbf' SIZE 1M
AUTOEXTEND ON NEXT 1M;
ALTER PLUGGABLE DATABASE DEFAULT TABLESPACE users;
ALTER PLUGGABLE DATABASE DEFAULT TEMPORARY TABLESPACE temp;
SQL> SELECT CON_ID,TABLESPACE_NAME FROM CDB_TABLESPACES WHERE CON_ID=1;
SQL> SELECT CON_ID,FILE_NAME FROM CDB_DATA_FILES WHERE CON_ID=1;
SQL> SELECT CON_ID,FILE_NAME FROM CDB_TEMP_FILES WHERE CON_ID=1;
from cdb_tablespaces
where contents = 'UNDO'
order by con_id;
User and Role Management :
create User c##pwtest identified by password container=all ;
grant create session to c#pwtest container=all ;
connect c#pwtest/password
alter user c#pwtest identified by password ;
alter user c#pwtest identified password contrainer=all ;
select username , profile , common , con_id from cdb_users where username='C##a1';
select username,profile,common,con_id from cdb_users where username='C##AA1';
SELECT ROLE,ROLE_ID,COMMON,CON_ID FROM CDB_ROLES WHERE ROLE='C##ROLE1';
SQL> select username, con_id from cdb_users where username='C##AA1';
SQL> select d.username, c.con_id,p.name from dba_users d, cdb_users c , v$pdbs p where d.username='C##AA1' and d.username=c.username and p.con_id=c.con_id;
ALTER PLUGGABLE DATABASE OPEN ALL ISSUED from the root
ALTER PLUGGABLE DATABASE OPEN issued from that PDb
1) Backup and recovery can be done at CDB and PDB level
Parameter check :
select name , value from v$nls_parameters where parameter='NLS_CHARACTERSET';
Flashback Cdb :
SHUTDOWN IMMEDIATE
STARTUP MOUNT
FLASHBACK DATABASE to TIME “TO_DATE (‘08/20/12’ , ‘MM/DD/YY’)”;
ALTER DATABASE OPEN RESETLOGS;
ALTER PLUGGABLE DATABASE ALL OPEN;
Note :
flashback of the CDB.
How to recovery PDB when PDB database is dropped in Oracle
How to recovery PDB when PDB database is dropped :) [oracle@rac01 ~]$ sqlplus '/as sysdba' SQL*Plus: Release 21.0.0.0.0 - Product...
-
What Is OEM? Oracle Enterprise Manager (OEM) has built-in management capabilities that enable DBAs and Apps DBAs to monitor and ma...
-
In each version of the Oracle database, a large number of background processes will be added. Below I have compiled a list of Oracle backg...
-
Oracle ASMCMD is ASM command-line utility that you can use to manage Oracle ASM instances, disk groups, file access control for disk groups,...