Moneycontrol Brokerage Recos

Showing posts with label Oracle 12c. Show all posts
Showing posts with label Oracle 12c. Show all posts

Saturday, March 7, 2020

Creating Pluggable Database using OEM




Here in this article, I would demonstrate how we can create a new Pluggable Database using Oracle Enterprise Manager 13c.


1 - Login to the Oracle Enterprise Manager to go the Container Database target Home Page in which you want to create the new Pluggable Database.





2 - From the drop-down Menu of Cluster Database, Navigate to Provisioning > Provision Pluggable Databases.



3 - Create Pluggable Database : Creation Options page opens, Select "Create a new PDB" and provide oracle software owner credentials in the "Host Credentials" property. Click Next.




Click Next.





It validates the /tmp directory space on the nodes being provisioned.




You can schedule the provision date/time or you can just start the job right away with immediate option.



You can monitor the CreatePluggableDatabase job progress - Click on "View Execution Details" tab to monitor the progress.








Provisioning job's status now "Succeeded" and you are done with provisioning. You can validate the PDB status in OEM or by logging to the Container CDB at the host.







Hope it helps, thanks for reading, please subscribe to this blog to stay updated with latest news on Oracle Cloud Infrastructure and Oracle Autonomous Database Cloud Services and new articles.

Twitter : https://twitter.com/rajsoft8899
Linkedin : https://www.linkedin.com/in/raj-kumar-kushwaha-5a289219/
Facebook : https://www.facebook.com/rkushawaha










Friday, December 27, 2019

Moving datafile online in Oracle 12c (12.1.0.2)


Starting from Oracle database 12c release 1 (12.1.0.2), you can move a data file from one location/filesystem to another/ASM diskgroup while database is open and being used by the application users.


Taking an example of ASM storage where mistakenly a datafile was added to a tablespace without plus(+) shine before the diskgroup name and new file got added inside the $ORACLE_HOME on the filesystem.


In this situation, DBA should quickly try to reduce the newly added file size to smallest size possible and turn off the datafile autoextend so no much data could be written and datafile size remain small which gives us a luxury to move it to proper location in minimum time.

Below highlighted data file was added mistakenly which was placed into ORACLE_HOME.

FILE_NAME                                                                                GB AUT     MAX_GB
-------------------------------------------------------------------------------- ---------- --- ----------
+DATA/TESTDB/DATAFILE/users.4513.1027281799                                10 YES 31.9999847
+DATA/TESTDB/DATAFILE/users.4813.1027281809                                 4 YES 31.9999847
/u01/app/oracle/product/12.1.0.2/dbhome_1/dbs/DATA                                      2 YES         31
+DATA/TESTDB/DATAFILE/users.8520.1027282145                                 2 YES         31




Let's move the datafile created inside the /u01 mount to our +DATA ASM Diskgroup with following command.


SQL> ALTER DATABASE MOVE DATAFILE '/u01/app/oracle/product/12.1.0.2/dbhome_1/dbs/DATA' TO '+DATA';

Database altered.



Now, let's validate the datafile list if that is moved.


SQL> select file_name, bytes/1024/1024/1024 as GB ,autoextensible,MAXBYTES/1024/1024/1024 MAX_GB from dba_data_files where tablespace_name='users' order by GB desc;

FILE_NAME                                                                                GB AUT     MAX_GB
-------------------------------------------------------------------------------- ---------- --- ----------
+DATA/TESTDB/DATAFILE/users.4513.1027281799                                10 YES 31.9999847
+DATA/TESTDB/DATAFILE/users.4813.1027281809                                 4 YES 31.9999847
+DATA/TESTDB/DATAFILE/users.8520.1027282145                                 2 YES         31
+DATA/TESTDB/DATAFILE/users.4194.1027284059                        .001953125 NO           0


Data file moved successfully as you can see in the above output.

Now once datafile is moved to the appropriate location, you can resize and turn autoextend on for its auto growth.


SQL> alter database datafile '+DATA/TESTDB/DATAFILE/users.4194.1027284059' resize 1g;

Database altered.

SQL> alter database datafile '+DATA/TESTDB/DATAFILE/users.4194.1027284059' autoextend on maxsize 32767m;

Database altered.

SQL> 


Let's validate the data file which we moved if that has no any corrupt blocks.


RMAN> validate datafile 68;

Starting validate at 17-DEC-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=112 instance=TESTDB1 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00068 name=+DATA/TESTDB/DATAFILE/users.4194.1027284059
channel ORA_DISK_1: validation complete, elapsed time: 00:00:03
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
68   OK     0              130945       131072          15464094246834
  File Name: +DATA/TESTDB/DATAFILE/users.4194.1027284059
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              0
  Other      0              127

Finished validate at 17-DEC-19

RMAN>

Datafile validation is successful.




Hope it helps, thanks for reading, please subscribe to this blog to stay updated with latest news on Oracle Cloud Infrastructure and Oracle Autonomous Database Cloud Services and new articles.

Twitter : https://twitter.com/rajsoft8899
Linkedin : https://www.linkedin.com/in/raj-kumar-kushwaha-5a289219/


Thursday, October 17, 2019

ORA-46269: Conflicting operation on audit files



The DBMS_AUDIT_MGMT package provides subprograms to manage audit trail records. These subprograms enable audit administrators to manage the audit trail. In a mixed-mode environment, these audit trails comprise the database, operating system (OS), and XML audit trails. In a unified auditing environment, this comprises the unified audit trail.



One of the daily maintenance system job fails with ORA-46269 error as below.


-bash-4.1$ oerr ora 46269
46269, 00000, "Conflicting operation on audit files"
// *Cause: Audit files were being operated by more than one DBMS_AUDIT_MGMT
//         API from different sessions. The simultaneous execution of the
//         CLEAN_AUDIT_TRAIL API with itself can cause the conflict.
// *Action: Wait until the execution of one of the API's complete and try
//          executing the API again.
-bash-4.1$


From the database instance alert log:

Tue Oct 15 19:38:53 2019
Errors in file /u01/app/oracle/diag/rdbms/orcldb/orcldb1/trace/orcldb1_j002_247077.trc:
ORA-12012: error on auto execute of job "SYS"."STANDARD_OS_AUDIT_TRAIL_PURGE"
ORA-46269: Conflicting operation on audit files
ORA-06512: at "SYS.DBMS_AUDIT_MGMT", line 61
ORA-06512: at "SYS.DBMS_AUDIT_MGMT", line 2447
ORA-06512: at line 1
Tue Oct 15 19:46:18 2019


From the incident trace file:

Trace file /u01/app/oracle/diag/rdbms/orcldb/orcldb1/trace/orcldb1_j002_247077.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/dbhome_2
System name:    Linux
Node name:      dbadm02.example.com
Release:        4.1.12-124.24.3.el6uek.x86_64
Version:        #2 SMP Mon Jan 14 15:08:09 PST 2019
Machine:        x86_64
Instance name: orcldb1
Redo thread mounted by this instance: 1
Oracle process number: 115
Unix process pid: 247077, image: oracle@dbadm02.example.com (J002)

*** 2019-10-15 19:38:53.665
*** SESSION ID:(1195.35311) 2019-10-15 19:38:53.665
*** CLIENT ID:() 2019-10-15 19:38:53.665
*** SERVICE NAME:(SYS$USERS) 2019-10-15 19:38:53.665
*** MODULE NAME:(DBMS_SCHEDULER) 2019-10-15 19:38:53.665
*** ACTION NAME:(STANDARD_OS_AUDIT_TRAIL_PURGE) 2019-10-15 19:38:53.665



Current audit management cleanup jobs list, I could see two audit clean-up jobs scheduled at same time and if first one that starts few seconds before the 2nd job, runs longer then 2nd job conflicts with the processing of first one and fails with the subjected error.


SQL> select * from DBA_AUDIT_MGMT_CLEANUP_JOBS

JOB_NAME                                 JOB_STAT AUDIT_TRAIL                  JOB_FREQUENCY
---------------------------------------- -------- ---------------------------- -----------------------------------
STANDARD_OS_AUDIT_TRAIL_PURGE            ENABLED  OS AUDIT TRAIL               FREQ=HOURLY;INTERVAL=1
CLEAN_OS_DB_AUDIT_RECORD                 ENABLED  OS AUDIT TRAIL               FREQ=HOURLY;INTERVAL=1

SQL>



SQL> select OWNER,JOB_NAME,to_char(last_start_date,'DD-MM-YY HH24:MI:SS') Last_date_time, to_char(next_run_date,'DD-MM-YY HH24:MI:SS') Next_Date_Time, JOB_ACTION from DBA_SCHEDULER_JOBS

OWNER                          JOB_NAME                       LAST_DATE_TIME    NEXT_DATE_TIME    JOB_ACTION
------------------------------ ------------------------------ ----------------- ----------------- -------------------------------------------------------
SYS                            CLEAN_OS_DB_AUDIT_RECORD       16-10-19 03:38:13 16-10-19 04:38:13 BEGIN DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL(4, TRUE);  END;
SYS                            STANDARD_OS_AUDIT_TRAIL_PURGE  16-10-19 03:38:53 16-10-19 04:38:53 BEGIN DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL(4, TRUE);  END;

SQL>


Scheduler details:


OWNER           JOB_NAME                            START_DATE                     ENABL STATE           FAILURE_COUNT LAST_START_DATE            NEXT_RUN_DATE               MAX_RUN_DURATIO SOURCE
--------------- ----------------------------------- ------------------------------ ----- --------------- ------------- -------------------------- ------------------------------ --------------- ---------------
SYS             STANDARD_OS_AUDIT_TRAIL_PURGE       16-jan-2016 02:38:53           TRUE  SCHEDULED                9731 16-oct-2019 01:38:53       16-oct-2019 02:38:53
SYS             CLEAN_OS_DB_AUDIT_RECORD            19-jan-2017 15:38:13           TRUE  SCHEDULED                 619 16-oct-2019 01:38:13       16-oct-2019 02:38:13
SYS             PURGE_LOG                           10-oct-2014 03:00:00           TRUE  SCHEDULED                   0 15-oct-2019 03:00:00       16-oct-2019 03:00:00




SQL> select * from DBA_AUDIT_MGMT_CONFIG_PARAMS

PARAMETER_NAME                 PARAMETER_VALUE                     AUDIT_TRAIL
------------------------------ ----------------------------------- ----------------------------
DB AUDIT TABLESPACE            SYSAUX                              STANDARD AUDIT TRAIL
DB AUDIT TABLESPACE            SYSAUX                              FGA AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                               OS AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                               XML AUDIT TRAIL
AUDIT FILE MAX AGE             5                                   OS AUDIT TRAIL
AUDIT FILE MAX AGE             5                                   XML AUDIT TRAIL
DB AUDIT CLEAN BATCH SIZE      10000                               STANDARD AUDIT TRAIL
DB AUDIT CLEAN BATCH SIZE      10000                               FGA AUDIT TRAIL
OS FILE CLEAN BATCH SIZE       1000                                OS AUDIT TRAIL
OS FILE CLEAN BATCH SIZE       1000                                XML AUDIT TRAIL
DEFAULT CLEAN UP INTERVAL      1                                   OS AUDIT TRAIL

11 rows selected.

SQL>


I don't want duplicate job schedules in place for the same purpose so I disabled and drop the one job schedule to fix the conflict and avoid the noise tickets.

SQL> begin
dbms_scheduler.disable( '"SYS"."CLEAN_OS_DB_AUDIT_RECORD"' );
END;
/

PL/SQL procedure successfully completed.

SQL>



SQL> EXEC DBMS_AUDIT_MGMT.DROP_PURGE_JOB('CLEAN_OS_DB_AUDIT_RECORD');

PL/SQL procedure successfully completed.

SQL>


Now, only one job is left in the schedule and it should work fine without any conflict in future.


SQL> select * from DBA_AUDIT_MGMT_CLEANUP_JOBS;

JOB_NAME                                                                                             JOB_STAT AUDIT_TRAIL                  JOB_FREQUENCY
---------------------------------------------------------------------------------------------------- -------- ---------------------------- ----------------------------------------------------------------------------------------------------
STANDARD_OS_AUDIT_TRAIL_PURGE                                                                        ENABLED  OS AUDIT TRAIL               FREQ=HOURLY;INTERVAL=1



OWNER                          JOB_NAME                       LAST_DATE_TIME    NEXT_DATE_TIME    JOB_ACTION
------------------------------ ------------------------------ ----------------- ----------------- -------------------------------------------------------
SYS                            STANDARD_OS_AUDIT_TRAIL_PURGE  16-10-19 04:38:53 16-10-19 05:38:53 BEGIN DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL(4, TRUE);  END;



Tested the manual job run once, and it worked fine.


SQL> BEGIN DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL(4, TRUE);  END;
  2  /

PL/SQL procedure successfully completed.

SQL>




Hope it helps, thanks for reading, please subscribe to this blog to stay updated with latest news on Oracle Cloud Infrastructure and Oracle Autonomous Database Cloud Services and new articles.



Thursday, September 19, 2019

DGMGRL SWITCHOVER fails with ORA-01017: invalid username/password; logon denied



While performing the Data Guard switchover activity for one of the container 2 node RAC primary and standby database (12.1.0.2) by Data Guard Broker (DGMGRL), it failed with error - ORA-01017: invalid username/password; logon denied.



Connect to DGMGRL:

DGMGRL> connect /
Connected as SYSDG.


DGMGRL>


View the details of current Data Guard Configuration:


DGMGRL> show configuration

Configuration - CDB_CONFIG

  Protection Mode: MaxPerformance
  Members:
  cdbad - Primary database
    cdb1  - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 30 seconds ago)

DGMGRL>



Let's validate if the primary and standby databases are ready for  switchover operation.

DGMGRL> validate database cdbad

  Database Role:     Physical standby database
  Primary Database:  cdb1

  Ready for Switchover:  Yes
  Ready for Failover:    Yes (Primary Running)

  Flashback Database Status:
    cdb1:   Off
    cdbad:  Off

DGMGRL>



DGMGRL> validate database cdb1

  Database Role:    Primary database

  Ready for Switchover:  Yes

  Flashback Database Status:
    cdb1:  Off

DGMGRL>


Above you see that both the primary and standby databases are ready for the switchover.

Let's try to perform the switchover to standby as follows:


DGMGRL> switchover to cdb1
Performing switchover NOW, please wait...
Operation requires a connection to instance "CDB1" on database "cdb1"
Connecting to instance "CDB1"...
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.

        connect to instance "CDB1" of database "cdb1"

DGMGRL> 


Oooops !! it failed, I validated the connection from primary to standby and vice versa and things look cool out there.... no issues with connectivity in either ways.

then I realized that when we connect to dgmgrl as "DGMGRL>connect /" then it connects with SYSDG user not with SYS user.

I tried to validate if SYSDG user is using the password file for remote authentication but..... this user is not assigned to password file to do the remote password file authentication. Only SYS user is there in the password file.


SQL> select * from v$pwfile_users;

USERNAME                       SYSDB SYSOP SYSAS SYSBA SYSDG SYSKM     CON_ID
------------------------------ ----- ----- ----- ----- ----- ----- ----------
SYS                            TRUE  TRUE  FALSE FALSE FALSE FALSE          0




Resolution : In this case, try to connect with SYS user at DGMGRL as below and perform the switchover operation since SYS user is already added in the password file and its connectivity is fine from both primary and standby directions.


DGMGRL> connect sys
Password:*******
Connected as SYSDG.
DGMGRL>




DGMGRL> switchover to cdb1
Performing switchover NOW, please wait...
Operation requires a connection to instance "CDB1" on database "cdb1"
Connecting to instance "CDB1"...
Connected as SYSDBA.
New primary database "cdb1" is opening...
Oracle Clusterware is restarting database "cdbad" ...
Switchover succeeded, new primary is "cdb1"
DGMGRL>

Great.....!! switchover operation successful now !!

Why?

because we connected as SYS user and it is using the password file for remote authentication !!



DGMGRL> show configuration

Configuration - CDB_CONFIG

  Protection Mode: MaxPerformance
  Members:
  cdb1  - Primary database
    cdbad - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 61 seconds ago)

DGMGRL>




DGMGRL> show database cdb1

Database - cdb1

  Role:               PRIMARY
  Intended State:     TRANSPORT-ON
  Instance(s):
    CDB1
    CDB2

Database Status:
SUCCESS

DGMGRL>



New container standby is in sync...

DGMGRL> show database cdbad

Database - cdbad

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 0 seconds ago)
  Apply Lag:          0 seconds (computed 0 seconds ago)
  Average Apply Rate: 6.00 KByte/s
  Real Time Query:    OFF
  Instance(s):
    cdbad1
    cdbad2 (apply instance)

Database Status:
SUCCESS

DGMGRL>


SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       MOUNTED
         3 PDB1                           MOUNTED
         5 PDB3                           MOUNTED
SQL>



Hope it helps, subscribe to this blog to stay updated on latest Oracle Technologies and new articles.

Twitter : https://twitter.com/rajsoft8899
Linkedin : https://www.linkedin.com/in/raj-kumar-kushwaha-5a289219/





Sunday, September 15, 2019

Warning: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE has been deprecated



You would see this warning message in the alert log file starting 12.1.0.2 Oracle Standby Databases when starting the MRP process using below command for real-time apply.



SQL> recover managed standby database using current logfile disconnect from session;
Media recovery complete.
SQL>



From alert log:

Warning: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE has been deprecated.
Warning: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE has been deprecated.
ALTER DATABASE RECOVER  managed standby database using current logfile disconnect from session




Instead, you should now being using the below command in 12c.


SQL> recover managed standby database cancel;
Media recovery complete.
SQL>



SQL> alter database recover managed standby database disconnect nodelay;

Database altered.

SQL>



NAME      INSTANCE_NAME    STATUS       OPEN_MODE            DATABASE_ROLE
 --------- ---------------- ------------ -------------------- ----------------
 CDB1      cdbad1           OPEN         READ ONLY WITH APPLY PHYSICAL STANDBY
 CDB1      cdbad2           OPEN         READ ONLY WITH APPLY PHYSICAL STANDBY




Hope it helps, subscribe to this blog to stay updated on latest Oracle Technologies and new articles.

Twitter : @rajsoft8899
Linkedin : https://www.linkedin.com/in/raj-kumar-kushwaha-5a289219/

Sunday, September 8, 2019

DROP Pluggable Database



Theory from Oracle Doc:


Drop a PDB when you want to move the PDB to a new CDB or when you no longer need it. When you drop a PDB, the control file of the CDB is modified to eliminate all references to the dropped PDB. Archived redo log files and backups associated with the PDB are not removed, but you can use Oracle Recovery Manager (RMAN) to remove them.

When dropping a PDB, you can either keep or delete the PDB's data files by using one of the following clauses of the DROP PLUGGABLE DATABASE statement:

KEEP DATAFILES, the default, retains the data files. The PDB temp file is removed even when KEEP DATAFILES is specified because the temp file is no longer needed. When KEEP DATAFILES is specified, the PDB must be unplugged.

INCLUDING DATAFILES removes the data files from disk. If a PDB was created with the SNAPSHOT COPY clause, then you must specify INCLUDING DATAFILES when you drop the PDB.


Prerequisites

The following prerequisites must be met:

• The PDB must be in mounted mode, or it must be unplugged.
• The current user must have SYSDBA or SYSOPER administrative privilege, and the privilege must be either commonly granted or locally granted in the PDB. The user must exercise the privilege using AS SYSDBA or AS SYSOPER at connect time.



To drop a PDB:

1 - In SQL*Plus, ensure that the current container is the CDB root, or, for an application PDB, the application root that contains the application PDB. If the PDB is plugged into the CDB root, then the current container must be the CDB root. If the PDB is plugged into an application root, then the current container must be that application root or the CDB root. If you are dropping an application container, then the current container must be the CDB root, and the application container must not have any application PDBs plugged into it.

2 - Run the DROP PLUGGABLE DATABASE statement and specify the PDB to drop.

Example : Dropping PDB salespdb While Keeping Its Data Files

SQL> DROP PLUGGABLE DATABASE pdb_name KEEP DATAFILES;

Example : Dropping PDB salespdb and Its Data Files

SQL> DROP PLUGGABLE DATABASE pdb_name INCLUDING DATAFILES;





Demonstration

We many DEV Pluggable databases that we created in the previous article - Click here to read how to create many PDBs in bulk using OEM.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
         5 PDB_DEV2                       READ WRITE NO
         6 PDB_DEV3                       READ WRITE NO
         7 PDB_DEV4                       READ WRITE NO
         8 PDB_DEV5                       READ WRITE NO
        10 PDB_DEV1                       READ WRITE NO



Closing/shutting down all PDBs that needs to be dropped:

SQL> alter pluggable database PDB_DEV1 close;

Pluggable database altered.

SQL> alter pluggable database PDB_DEV2 close;

Pluggable database altered.

SQL> alter pluggable database PDB_DEV3 close;

Pluggable database altered.

SQL> alter pluggable database PDB_DEV4 close;

Pluggable database altered.

SQL> alter pluggable database PDB_DEV5 close;

Pluggable database altered.



Validate if all are in MOUNTED state now.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
         5 PDB_DEV2                       MOUNTED
         6 PDB_DEV3                       MOUNTED
         7 PDB_DEV4                       MOUNTED
         8 PDB_DEV5                       MOUNTED
        10 PDB_DEV1                       MOUNTED



Drop the PDBs with clause "including datafiles"

SQL> drop pluggable database PDB_DEV1 including datafiles;

Pluggable database dropped.

SQL> drop pluggable database PDB_DEV2 including datafiles;

Pluggable database dropped.

SQL> drop pluggable database PDB_DEV3 including datafiles;

Pluggable database dropped.

SQL> drop pluggable database PDB_DEV4 including datafiles;

Pluggable database dropped.

SQL> drop pluggable database PDB_DEV5 including datafiles;

Pluggable database dropped.



Validate if PDBs are dropped and gone successfully.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
SQL>



Hope it helps, subscribe to this blog to stay updated on latest Oracle Technologies and new articles.

Twitter : @rajsoft8899
Linkedin : https://www.linkedin.com/in/raj-kumar-kushwaha-5a289219/

Thursday, September 5, 2019

PDB Cloning in same CDB


In this article, I would explain how to clone an existing Pluggable Database into a new PDB or you can say - create a new PDB from an existing PDB in the same container database.


In this demo, we would be cloning PDB3 as a new Pluggable Database named PDB4.

1 - Let's see the existing list of PDBs currently we have using "show pdbs" command.


SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
         5 PDB3                           READ WRITE NO
SQL>


2 - Review the GUID for the individual PDBs

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

    CON_ID GUID                             NAME                           OPEN_MODE
---------- -------------------------------- ------------------------------ ----------
         2 8FA8EFE7EE287653E0537C17800A501C PDB$SEED                       READ ONLY
         3 90C13D2FC47D70F9E0537C17800ACC04 PDB1                           READ WRITE
         4 91AC92BB3457B533E0537C17800AF412 PDB2                           READ WRITE
         5 91C3038EF67B5702E0537C17800A84C6 PDB3                           READ WRITE


3 - Here I am going to create a new tablespace into the PDB3 so that when we clone this as PDB4 so difference be visible.

SQL> alter session set container = pdb3;

Session altered.

SQL> show con_name

CON_NAME
------------------------------
PDB3
SQL>


SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATAC1/CDB1/DATAFILE/undotbs1.11084.1015822335
+DATAC1/CDB1/91C3038EF67B5702E0537C17800A84C6/DATAFILE/system.9073.1018133353
+DATAC1/CDB1/91C3038EF67B5702E0537C17800A84C6/DATAFILE/sysaux.3022.1018133353
+DATAC1/CDB1/91C3038EF67B5702E0537C17800A84C6/DATAFILE/users.3693.1018133353

SQL>


SQL> create tablespace tbs1 datafile '+DATAC1' size 100m;

Tablespace created.



SQL> select name from v$datafile;


NAME
--------------------------------------------------------------------------------
+DATAC1/CDB1/DATAFILE/undotbs1.11084.1015822335
+DATAC1/CDB1/91C3038EF67B5702E0537C17800A84C6/DATAFILE/system.9073.1018133353
+DATAC1/CDB1/91C3038EF67B5702E0537C17800A84C6/DATAFILE/sysaux.3022.1018133353
+DATAC1/CDB1/91C3038EF67B5702E0537C17800A84C6/DATAFILE/users.3693.1018133353
+DATAC1/CDB1/91C3038EF67B5702E0537C17800A84C6/DATAFILE/tbs1.3023.1018133807

SQL>



4 - Here now we create PDB4 from the existing PDB3 using the below simple command. This is how simple it is to clone a PDB into Oracle Multi-tenant Architecture.

SQL> create pluggable database pdb4 from pdb3;

Pluggable database created.



5 - You can list all the PDBs in the CDB using the "show pdbs" command and you can see that new PDB4 is created now. By default, new PDB be in MOUNT state when gets created.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
         5 PDB3                           READ WRITE NO
         6 PDB4                           MOUNTED


6 - Open the Pluggable Database using below command.

SQL> alter pluggable database pdb4 open;

Pluggable database altered.


7 - Validate the PDB open status now.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
         5 PDB3                           READ WRITE NO
         6 PDB4                           READ WRITE NO


8 - Validate new PDB details.

SQL> alter session set container = pdb4;

Session altered.

SQL> show con_name

CON_NAME
------------------------------
PDB4
SQL>


Each PDB has its own GUID named directory under the parent Container Database directory where individual PDBs store its local tablespace/datafiles in there.

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

    CON_ID GUID                             NAME                           OPEN_MODE
---------- -------------------------------- ------------------------------ ----------
         2 8FA8EFE7EE287653E0537C17800A501C PDB$SEED                       READ ONLY
         3 90C13D2FC47D70F9E0537C17800ACC04 PDB1                           READ WRITE
         4 91AC92BB3457B533E0537C17800AF412 PDB2                           READ WRITE
         5 91C3038EF67B5702E0537C17800A84C6 PDB3                           READ WRITE
         6 91C324409E5776D8E0537C17800A746B PDB4                           READ WRITE


Cloned PDB4 has all tablespaces as it was in PDB3 under its own GUID directory path.

SQL> select name from v$datafile;

NAME
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+DATAC1/CDB1/DATAFILE/undotbs1.11084.1015822335
+DATAC1/CDB1/91C324409E5776D8E0537C17800A746B/DATAFILE/system.3134.1018133901
+DATAC1/CDB1/91C324409E5776D8E0537C17800A746B/DATAFILE/sysaux.663.1018133901
+DATAC1/CDB1/91C324409E5776D8E0537C17800A746B/DATAFILE/users.7266.1018133901
+DATAC1/CDB1/91C324409E5776D8E0537C17800A746B/DATAFILE/tbs1.7233.1018133901




Hope it helps, subscribe to this blog to stay updated on latest Oracle Technologies and new articles.

Twitter : @rajsoft8899
Linkedin : https://www.linkedin.com/in/raj-kumar-kushwaha-5a289219/


Wednesday, September 4, 2019

Creating Multiple PDBs in one Go using OEM



Here in this article, I would demonstrate the process steps to create multiple Pluggable Databases in just one Go using Oracle Enterprise Manager 13c.

1 - You need to make sure the underline Container Database is registered in the OEM and it is up.
2 - You need to have Oracle RDBMS software owner and password in hand.
3 - Get ASM diskgroup name handy from the ASM cluster running on the underline database server.




Let's now begin by logging into the OEM and go the Container Database target home page.




Click on the Target Home drop down option and navigate to "Provisioning" then click on "Provision Pluggable Databases"





Provision Pluggable Databases page opens > Select the option "Create New Pluggable Databases" and click on "Launch"





Select "Create a New PDB" option and provide named credentials for Oracle Software owner and its password. Click on Next.




Provide "PDB Name" that you want per the naming convention and Tick the "Create Multiple Copies" option to create the number of Pluggable Databases you want, provide PDB Administrator username/password. In my case, I am creating 5 pluggable database in one Go!

Click on Next.




Since my container database is using "+DATAC1" diskgroup for database files storage so it is selected already, click on Next.




It checks for /tmp directory location on the underline database server.



Click on Next.




Finally you can review the summary of "Create Pluggable Database" selections and click on "Submit" to start the job to create PDBs.




Click on "View Execution Details" tab to go to provisioning job details page to monitor the job steps progress.




Job is running >





Job is "Succedded" in just 11 minutes, 57 seconds - so five PDBs created this fast.



Now if you go back to Container Database home page then you would see there are 7 Pluggable databases now, earlier it was only 2.

Click on the "Pluggable Databases" to view the names of all PDBs and its target names:




You can see below, five Pluggable Databases are created per the naming convention we provided with one number incremental number appended to its name.






You can validate the same by logging into the SQLPLUS, using the SQL>show pdbs command, as below:


SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
         5 PDB_DEV2                       READ WRITE NO
         6 PDB_DEV3                       READ WRITE NO
         7 PDB_DEV4                       READ WRITE NO
         8 PDB_DEV5                       READ WRITE NO
        10 PDB_DEV1                       READ WRITE NO
SQL>




Hope it helps, subscribe to this blog to stay updated on latest Oracle Technologies and new articles.

Twitter : @rajsoft8899
Linkedin : https://www.linkedin.com/in/raj-kumar-kushwaha-5a289219/



Sunday, August 18, 2019

ORA-27154: post/wait create failed




Today, we were doing Exadata X7-2 QFSDP APR 2019 patching, but during post patch steps, some of the cluster database instances failed to start with following error  - Over-all 62 databases running on this Exadata Machine.

Note : Recently we added 2 more databases to this Exadata box.


SQL> startup
ORA-27154: post/wait create failed
ORA-27300: OS system dependent operation:semget failed with status: 28
ORA-27301: OS failure message: No space left on device
ORA-27302: failure occurred at: sskgpcreates
SQL> 


From one of the database alert log file:

Starting ORACLE instance (normal)
************************ Large Pages Information *******************
Per process system memlock (soft) limit = UNLIMITED

Total Shared Global Region in Large Pages = 0 KB (0%)

Large Pages used by this instance: 0 (0 KB)
Large Pages unused system wide = 0 (0 KB)
Large Pages configured system wide = 13833 (27 GB)
Large Page size = 2048 KB

RECOMMENDATION:
  Total System Global Area size is 2050 MB. For optimal performance,
  prior to the next instance restart:
  1. Increase the number of unused large pages by
 at least 1025 (page size 2048 KB, total size 2050 MB) system wide to
  get 100% of the System Global Area allocated with large pages
********************************************************************
Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_184111.trc:
ORA-27154: post/wait create failed
ORA-27300: OS system dependent operation:semget failed with status: 28
ORA-27301: OS failure message: No space left on device
ORA-27302: failure occurred at: sskgpcreates


From the trace file:

*** 2019-08-17 10:10:25.566
Switching to regular size pages for segment size 100663296
Switching to regular size pages for segment size 2046820352
Switching to regular size pages for segment size 2097152

*** 2019-08-17 10:10:25.595
dbkedDefDump(): Starting a non-incident diagnostic dump (flags=0x0, level=0, mask=0x0)
----- Error Stack Dump -----
ORA-27154: post/wait create failed
ORA-27300: OS system dependent operation:semget failed with status: 28
ORA-27301: OS failure message: No space left on device
ORA-27302: failure occurred at: sskgpcreates


Semaphore current configuration in the system.

[root@exa01dbadm01 ~]# ipcs -ls

------ Semaphore Limits --------
max number of arrays = 256
max semaphores per array = 1024
max semaphores system wide = 60000
max ops per semop call = 1024
semaphore max value = 32767


Means 60000 semaphores are available in the system and one semaphore identifier can accommodate a maximum of 1024 semaphores with the configuration above.

But ipcs command shows each semaphore identifier accommodates maximum of 514 (some 752) semaphores by Oracle. 



------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0x27219008 5242886    oracle     640        704
0x1d63fabc 5373959    oracle     640        514
0x1d63fabd 5406728    oracle     640        514
0x26f035f8 5603337    oracle     640        514
0x1d63fabe 5472266    oracle     640        514
0x26f035f9 5701643    oracle     640        514
0xeb773830 5898252    oracle     640        514
0x26f035fa 5832717    oracle     640        514
0x14422b02 11862119   oracle     640        514
0xa83d39fc 11993192   oracle     640        514
0xa83d39fd 12025961   oracle     640        514
0xa83d39fe 12058730   oracle     640        514
0xea1a4768 12189803   oracle     640        514
0xea1a4769 12222572   oracle     640        514
0xea1a476a 12255341   oracle     640        514
0xdcc4a7a4 12386414   oracle     640        514
0xdcc4a7a5 12419183   oracle     640        514
0xdcc4a7a6 12451952   oracle     640        514
0x75550980 12583025   oracle     600        514
0x75550981 12615794   oracle     600        514
0x75550982 12648563   oracle     600        514



So, maximum semaphores available on this system would be 514x256 = 131584



[root@exa01dbadm01 ~]# /sbin/sysctl -a | grep sem
kernel.sem = 1024       60000   1024    256


Per above, we see that we have less, max semaphores configured in the system i.e. 60000.
==================

SEMMNI should be increased to accomodate more semaphores.



[root@exa01dbadm01 ~]# /sbin/sysctl -a | grep sem
kernel.sem = 1024       60000   1024    256



I increased the max number of semaphores to be available on the system to 70000 from 60000

From :

[root@exa01dbadm01 ~]# /sbin/sysctl -a | grep sem
kernel.sem = 1024       60000   1024    256


To this:

[root@exa01dbadm01 ~]# /sbin/sysctl -a | grep sem
kernel.sem = 1024       70000   1024    256

And finally run the below to make new kernel values effective without server reboot.

/sbin/sysctl -p




Finally, tried to start the remaining DB instances and all came up normally.

[oracle@exa01dbadm01 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.2.0 Production on Sat Aug 17 10:32:13 2019

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  2926472 bytes
Variable Size            1318045816 bytes
Database Buffers          822083584 bytes
Redo Buffers                4427776 bytes
Database mounted.
Database opened.
SQL>




Hope it helps, subscribe to this blog to stay updated on latest Oracle Technologies and new articles.

Twitter : @rajsoft8899
Linkedin : https://www.linkedin.com/in/raj-kumar-kushwaha-5a289219/

Friday, August 16, 2019

Expanded controlfile section 27 from 1000 to 2000 records



Following entry in the alert log file is just an informational message means more information is getting added or updated in database controlfile sections. We already know that database control file records lots of information in it about its database, below you would see what all kinds of information, database control file stores in it.

All information age/length depends on the below parameter - i.e. for how long you want to retain all information inside the control file that it stores. In my case, we are storing the information for 38 days and my control file size is almost 1GB. We are generating almost 6000 archives per day.

SQL> show parameter control_file_record_keep_time

NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- ------------------------------
control_file_record_keep_time        integer                          38
SQL>


In my case, my standby database had to sync over 9000 pending archives shipping from the primary database to the DR. I have archivelog deletion policy set in the RMAN configuration on the standby so that applied archives get deleted(when there is space pressure on the FRA ) once applied to maintain the proper space inside the FRA.

Below is the alert log entry added in the standby where it says that controlfile section 27 has been expanded from 1000 to 2000 so it can record new/update information/values - archive apply speed very high - 32 to 33 archives per minute.


Fri Aug 16 05:58:37 2019
Expanded controlfile section 27 from 1000 to 2000 records
Requested to grow by 1000 records; added 2 blocks of records



SQL> select * from v$version;

BANNER                                                                               CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production              0
PL/SQL Release 12.1.0.2.0 - Production                                                    0
CORE    12.1.0.2.0      Production                                                                0
TNS for Linux: Version 12.1.0.2.0 - Production                                            0
NLSRTL Version 12.1.0.2.0 - Production                                                    0

SQL>



Below you can see that control file section 27 (REMOVABLE RECOVERY FILES) has been expanded to 2000 from 1000 since you can see its current value is 1318 i.e greater than 1000 hence the relevant section expanded to store more information in it.

"REMOVABLE RECOVERY FILES" control file section was expanded because archives at standby database getting shipped and applied at very rapid speed (32 to 33 archives apply per minute) and applied archives are being marked as "REMOVABLE RECOVERY FILES" and eligible to be removed once there is space pressure on FRA hence control file requires to store this information in it and its relevant section needs some more blocks to store the growing information hence the section expanded.


Below are various control file sections that stores separate information into it.

SQL> select rownum,t.* from v$controlfile_record_section t;

ROWNUM TYPE                         RECORD_SIZE RECORDS_TOTAL RECORDS_USED FIRST_INDEX LAST_INDEX LAST_RECID     CON_ID
---------- ---------------------------- ----------- ------------- ------------ ----------- ---------- ---------- ---------- 
         1 DATABASE                             316             1            1           0          0          0          0
         2 CKPT PROGRESS                       8180            35            0           0          0          0          0
         3 REDO THREAD                          256            32            2           0          0        120          0
         4 REDO LOG                              72           192           20           0          0        162          0
         5 DATAFILE                             520          1024           76           0          0      10409          0
         6 FILENAME                             524          4674          121           0          0          0          0
         7 TABLESPACE                            68          1024           23           0          0         36          0
         8 TEMPORARY FILENAME                    56          1024            3           0          0      32716          0
         9 RMAN CONFIGURATION                  1108            50           11           0          0         55          0
        10 LOG HISTORY                           56        382842       382842      174193     174192    1473530          0
        11 OFFLINE RANGE                        200          1063            5           1          5          5          0
        12 ARCHIVED LOG                         584        696320         9496           1       9496       9496          0
        13 BACKUP SET                            96         32704        32704       31215      31214     129326          0
        14 BACKUP PIECE                         780         32192        32192         559        558     129326          0
        15 BACKUP DATAFILE                      200          6866         6866        2580       2579      48776          0
        16 BACKUP REDOLOG                        76        440320       417543      384410     361632    1462432          0
        17 DATAFILE COPY                        736          1000          152           1        152        152          0
        18 BACKUP CORRUPTION                     44          1115            0           0          0          0          0
        19 COPY CORRUPTION                       40          1227            0           0          0          0          0
        20 DELETED OBJECT                        20        803572       756216      545421     498064    1842356          0
        21 PROXY COPY                           928          1004            0           0          0          0          0
        22 BACKUP SPFILE                        124          1890         1890         555        554      17509          0
        23 DATABASE INCARNATION                  56           292            2           1          2          2          0
        24 FLASHBACK LOG                         84          2048            0           0          0          0          0
        25 RECOVERY DESTINATION                 180             1            1           0          0          0          0
        26 INSTANCE SPACE RESERVATION            28          1055            2           0          0          0          0
        27 REMOVABLE RECOVERY FILES              32          2000         1318           0          0          0          0
        28 RMAN STATUS                          116          7568         7568        1861       1860      98780          0
        29 THREAD INSTANCE NAME MAPPING          80            32           32           0          0          0          0
        30 MTTR                                 100            32            2           0          0          0          0
        31 DATAFILE HISTORY                     568            57            0           0          0          0          0
        32 STANDBY DATABASE MATRIX              400            31           31           0          0          0          0
        33 GUARANTEED RESTORE POINT             212          2048            0           0          0          0          0
        34 RESTORE POINT                        212          2083            0           0          0          0          0
        35 DATABASE BLOCK CORRUPTION             80          8384            0           0          0          0          0
        36 ACM OPERATION                        104            64            9           0          0          0          0
        37 FOREIGN ARCHIVED LOG                 604          1002            0           0          0          0          0
        38 PDB RECORD                           684            10            0           0          0          0          0
        39 AUXILIARY DATAFILE COPY              584           128            0           0          0          0          0
        40 MULTI INSTANCE REDO APPLY            556             1            0           0          0          0          0
        41 PDBINC RECORD                        144           113            0           0          0          0          0

41 rows selected. 

SQL>



Since archivelog shipping and apply was massive hence you would see below that control file section 27 expanded again from 2000 to 4000



Fri Aug 16 07:28:38 2019
Expanded controlfile section 27 from 2000 to 4000 records
Requested to grow by 2000 records; added 4 blocks of records



SQL> select rownum,t.* from v$controlfile_record_section t;

ROWNUM TYPE                         RECORD_SIZE RECORDS_TOTAL RECORDS_USED FIRST_INDEX LAST_INDEX LAST_RECID     CON_ID

---------- ---------------------------- ----------- ------------- ------------ ----------- ---------- ---------- ----------  

         1 DATABASE                             316             1            1           0          0          0          0

         2 CKPT PROGRESS                       8180            35            0           0          0          0          0

         3 REDO THREAD                          256            32            2           0          0        120          0

         4 REDO LOG                              72           192           20           0          0        162          0

         5 DATAFILE                             520          1024           76           0          0      10409          0

         6 FILENAME                             524          4674          121           0          0          0          0

         7 TABLESPACE                            68          1024           23           0          0         36          0

         8 TEMPORARY FILENAME                    56          1024            3           0          0      32716          0

         9 RMAN CONFIGURATION                  1108            50           11           0          0         55          0

        10 LOG HISTORY                           56        382842       382842      174718     174717    1474055          0

        11 OFFLINE RANGE                        200          1063            5           1          5          5          0

        12 ARCHIVED LOG                         584        696320         9580           1       9580       9580          0

        13 BACKUP SET                            96         32704        32704       31215      31214     129326          0

        14 BACKUP PIECE                         780         32192        32192         559        558     129326          0

        15 BACKUP DATAFILE                      200          6866         6866        2580       2579      48776          0

        16 BACKUP REDOLOG                        76        440320       417543      384410     361632    1462432          0

        17 DATAFILE COPY                        736          1000          152           1        152        152          0

        18 BACKUP CORRUPTION                     44          1115            0           0          0          0          0

        19 COPY CORRUPTION                       40          1227            0           0          0          0          0

        20 DELETED OBJECT                        20        803572       756216      545421     498064    1842356          0

        21 PROXY COPY                           928          1004            0           0          0          0          0

        22 BACKUP SPFILE                        124          1890         1890         555        554      17509          0

        23 DATABASE INCARNATION                  56           292            2           1          2          2          0

        24 FLASHBACK LOG                         84          2048            0           0          0          0          0

        25 RECOVERY DESTINATION                 180             1            1           0          0          0          0

        26 INSTANCE SPACE RESERVATION            28          1055            2           0          0          0          0

        27 REMOVABLE RECOVERY FILES              32          4000         2013           0          0          0          0

        28 RMAN STATUS                          116          7568         7568        1861       1860      98780          0

        29 THREAD INSTANCE NAME MAPPING          80            32           32           0          0          0          0

        30 MTTR                                 100            32            2           0          0          0          0

        31 DATAFILE HISTORY                     568            57            0           0          0          0          0

        32 STANDBY DATABASE MATRIX              400            31           31           0          0          0          0

        33 GUARANTEED RESTORE POINT             212          2048            0           0          0          0          0

        34 RESTORE POINT                        212          2083            0           0          0          0          0

        35 DATABASE BLOCK CORRUPTION             80          8384            0           0          0          0          0

        36 ACM OPERATION                        104            64            9           0          0          0          0

        37 FOREIGN ARCHIVED LOG                 604          1002            0           0          0          0          0

        38 PDB RECORD                           684            10            0           0          0          0          0

        39 AUXILIARY DATAFILE COPY              584           128            0           0          0          0          0

        40 MULTI INSTANCE REDO APPLY            556             1            0           0          0          0          0

        41 PDBINC RECORD                        144           113            0           0          0          0          0

41 rows selected. 

SQL>


Hope it helps, subscribe to this blog to stay updated on latest Oracle Technologies and new articles.

Twitter : @rajsoft8899
Linkedin : https://www.linkedin.com/in/raj-kumar-kushwaha-5a289219/