Thursday, December 10, 2020

How to Switch CDB (container) to PDB (pluggable) database in Multitenant

Switch CDB (container) to PDB (pluggable)  database in  multitenant 



[oracle@node2 ~]$ srvctl status database -d orcl

Instance orcl1 is running on node node1

Instance orcl2 is running on node node2

[oracle@node2 ~]$

[oracle@node2 ~]$

[oracle@node2 ~]$

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


SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 10 19:56:50 2020


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

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Advanced Analytics and Real Application Testing options

SQL>

SQL>

SQL> show pdbs


    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         2 PDB$SEED                       READ ONLY  NO

         3 PDBORCL                        MOUNTED

SQL>

SQL>

SQL> alter pluggable database PDBORCL open read write;


Pluggable database altered.


SQL> show pdbs


    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         2 PDB$SEED                       READ ONLY  NO

         3 PDBORCL                        READ WRITE NO

SQL>


SQL> select INSTANCE_NUMBER,INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS,EDITION from gv$instance;


INSTANCE_NUMBER INSTANCE_NAME    HOST_NAME                                                        VERSION           STARTUP_T STATUS       EDITION

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

              2 orcl2            node2.localdomain                                                12.1.0.2.0        10-DEC-20 OPEN         EE

              1 orcl1            node1.localdomain                                                12.1.0.2.0        10-DEC-20 OPEN         EE


SQL> show pdbs


    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         2 PDB$SEED                       READ ONLY  NO

         3 PDBORCL                        READ WRITE NO

SQL>

SQL> show con_name


CON_NAME

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

CDB$ROOT

SQL>

SQL>

SQL> show con_id


CON_ID

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

1

SQL>

SQL> alter session set container=PDBORCL;


Session altered.


SQL> show con_name


CON_NAME

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

PDBORCL

SQL> show con_id


CON_ID

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

3

SQL>

SQL>




==================


[oracle@node1 trace]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA1.dg
               ONLINE  ONLINE       node1                    STABLE
               ONLINE  ONLINE       node2                    STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       node1                    STABLE
               ONLINE  ONLINE       node2                    STABLE
ora.asm
               ONLINE  ONLINE       node1                    Started,STABLE
               ONLINE  ONLINE       node2                    Started,STABLE
ora.net1.network
               ONLINE  ONLINE       node1                    STABLE
               ONLINE  ONLINE       node2                    STABLE
ora.ons
               ONLINE  ONLINE       node1                    STABLE
               ONLINE  ONLINE       node2                    STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       node2                    STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       node1                    STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       node1                    STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       node1                    169.254.18.158,STABL
                                                             E
ora.cvu
      1        ONLINE  ONLINE       node1                    STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       node1                    Open,STABLE
ora.node1.vip
      1        ONLINE  ONLINE       node1                    STABLE
ora.node2.vip
      1        ONLINE  ONLINE       node2                    STABLE
ora.oc4j
      1        ONLINE  UNKNOWN      node1                    CHECK TIMED OUT,STAB
                                                             LE
ora.orcl.db
      1        ONLINE  ONLINE       node1                    Open,STABLE
      2        ONLINE  ONLINE       node2                    Open,STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       node2                    STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       node1                    STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       node1                    STABLE
--------------------------------------------------------------------------------
[oracle@node1 trace]$

Cluster status check command

 

12.1.0.2 Grid status check command

=====================================



[root@node1 ~]# crsctl check cluster -all

**************************************************************

node1:

CRS-4537: Cluster Ready Services is online

CRS-4529: Cluster Synchronization Services is online

CRS-4533: Event Manager is online

**************************************************************

node2:

CRS-4537: Cluster Ready Services is online

CRS-4529: Cluster Synchronization Services is online

CRS-4533: Event Manager is online

**************************************************************

[root@node1 ~]#

[root@node1 ~]#

[root@node1 ~]# date

Thu Dec 10 04:10:04 IST 2020


[root@node1 ~]#



[root@node1 ~]# crsctl stat resource -t

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

Name           Target  State        Server                   State details

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

Local Resources

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

ora.DATA1.dg

               ONLINE  ONLINE       node1                    STABLE

               ONLINE  ONLINE       node2                    STABLE

ora.LISTENER.lsnr

               ONLINE  ONLINE       node1                    STABLE

               ONLINE  ONLINE       node2                    STABLE

ora.asm

               ONLINE  ONLINE       node1                    Started,STABLE

               ONLINE  ONLINE       node2                    Started,STABLE

ora.net1.network

               ONLINE  ONLINE       node1                    STABLE

               ONLINE  ONLINE       node2                    STABLE

ora.ons

               ONLINE  ONLINE       node1                    STABLE

               ONLINE  ONLINE       node2                    STABLE

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

Cluster Resources

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

ora.LISTENER_SCAN1.lsnr

      1        ONLINE  ONLINE       node2                    STABLE

ora.LISTENER_SCAN2.lsnr

      1        ONLINE  ONLINE       node1                    STABLE

ora.LISTENER_SCAN3.lsnr

      1        ONLINE  ONLINE       node1                    STABLE

ora.MGMTLSNR

      1        ONLINE  ONLINE       node1                    169.254.18.158 10.0.

                                                             0.1,STABLE

ora.cvu

      1        ONLINE  ONLINE       node1                    STABLE

ora.mgmtdb

      1        ONLINE  ONLINE       node1                    Open,STABLE

ora.node1.vip

      1        ONLINE  ONLINE       node1                    STABLE

ora.node2.vip

      1        ONLINE  ONLINE       node2                    STABLE

ora.oc4j

      1        ONLINE  ONLINE       node1                    STABLE

ora.scan1.vip

      1        ONLINE  ONLINE       node2                    STABLE

ora.scan2.vip

      1        ONLINE  ONLINE       node1                    STABLE

ora.scan3.vip

      1        ONLINE  ONLINE       node1                    STABLE

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

[root@node1 ~]#




[root@node1 ~]# crsctl status resource ora.LISTENER_SCAN2.lsnr -v

NAME=ora.LISTENER_SCAN2.lsnr

TYPE=ora.scan_listener.type

LAST_SERVER=node1

STATE=ONLINE on node1

TARGET=ONLINE

CARDINALITY_ID=1

RESTART_COUNT=0

FAILURE_COUNT=0

FAILURE_HISTORY=

ID=ora.LISTENER_SCAN2.lsnr 1 1

INCARNATION=1

LAST_RESTART=12/10/2020 02:17:20

LAST_STATE_CHANGE=12/10/2020 02:17:19

STATE_DETAILS=

INTERNAL_STATE=STABLE

INSTANCE_COUNT=1



Tuesday, November 24, 2020

Local User Login Error with PDB in Oracle 19c Database -- Error ORA-01017: invalid username/password; logon denied


Getting below error while connecting local user with PDB database 19c .

ORA-01017: invalid username/password; logon denied

  • Make sure you have PDB instance entry in tnsnames.ora 
  • Listener should be up and running also PDB database service should be register with listener 

 

Query to check service status

SQL>

SQL> SELECT name, pdb FROM   v$services ORDER BY name;

NAME                           PDB

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

SYS$BACKGROUND                 CDB$ROOT

SYS$USERS                      CDB$ROOT

sg                             CDB$ROOT

sgXDB                          CDB$ROOT

sg_pdb1                        SG_PDB1

SQL>

SQL>

[oracle@  admin]$ sqlplus test/test@sg_pdb1

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 24 09:17:30 2020

Version 19.3.0.0.0

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

ERROR:

ORA-01017: invalid username/password; logon denied

Enter user-name:

ERROR:

ORA-01017: invalid username/password; logon denied



Enter user-name:

ERROR:

ORA-01017: invalid username/password; logon denied

SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

[oracle@admin]$

[oracle@admin]$ vi sqlnet.ora

[oracle@admin]$

[oracle@admin]$

[oracle@admin]$ sqlplus test/test@sg_pdb1

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 24 09:17:46 2020

Version 19.3.0.0.0

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

Last Successful login time: Tue Nov 24 2020 09:16:12 +00:00

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.3.0.0.0

SQL>

SQL>

SQL> exit

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.3.0.0.0


[oracle@admin]$

[oracle@admin]$

[oracle@admin]$ cat sqlnet.ora

# sqlnet.ora Network Configuration File: /u01/app/oracle/product/19.0.0/network/admin/sqlnet.ora

# Generated by Oracle configuration tools.


NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

SQLNET.ALLOWED_LOGON_VERSION_SERVER=11


[oracle@admin]$

[oracle@admin]$




Friday, November 13, 2020

Wait Event : Log File Sync

 What Exactly Is A 'Log File Sync' Wait event?

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



Log file sync wait event, which in many cases is caused by poor storage performance.


user session issuing a commit command must wait until the LGWR (Log Writer) process writes the log entries associated with the user transaction to the log file on the disk.

Oracle must commit the transaction’s entries to disk (because it is a persistent layer) before acknowledging the transaction commit.

 

At commit time, a process creates a redo record (containing commit opcodes) and copies that redo record into the log buffer. Then, that process signals LGWR to write the contents of log buffer. LGWR writes from the log buffer to the log file and signals user process back completing a commit. A commit is considered successful after the LGWR write is successful.

 

 

A commit is not complete until LGWR writes the log buffers, including the commit redo records to the log files. In a nutshell, after posting LGWR to write, user or background processes wait for LGWR to signal back with a 1-second timeout. The User process charges this wait time as a ‘log file sync’ event.

 

The log file sync wait event represents the time the session is waiting for the log buffers to be written to disk.

 

For example, the following user transaction consists of Insert, Select and Update statements, and completes with a commit:


User Transaction:


Insert…

Select…

Update…

Commit…



Root Causes for 'Log File Sync' Waits

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


LGWR is unable to complete writes fast enough for one of the following reasons:


Disk I/O performance to log files is not good.

LGWR is starving for CPU resource. If the server is very busy, LGWR can starve for CPU too. 

LGWR is unable to complete writes fast enough due to file system or Unix buffer cache limitations.



Guidelines For Resolving 'Log File Sync' Waits

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

If CPU starvation is an issue, then reducing CPU starvation is the correct step to resolve it.


If commit rate is higher, then decreasing commits is correct step but, in a few cases, if that is not possible, increasing the priority of LGWR (using nice) or increasing the priority class of LGWR to RT might provide some relief.


Solid State Disk devices also can be used if the redo size is extreme. in some case , it is also preferable to decrease redo size.


check redo switch per hours , normally it should be 4-5 switch per hours , Sometimes redo logs are very less in size , Oracle recommends, maximum 8 switch per hour .It may be change as per environment to environment  . 


User commit %  and user rollback % can be seen from AWR report which could help to troubleshoot the issue . 


If Redo logs are undersized or huge size both are not good , so tune properly. 


Test in Non-Prod before do any changes in production .