Friday, July 26, 2013

orapwd and PDB

orapwd and PDB


The orapwd creates a password file which is used to authenticate the users.


The password provided for the orapwd and the password of sys can be different and Sys can login with the password locally .
And the password given for orapwd comes in only for the REMOTE Login (“@”) .

Changing the password of the orapwd (password file) will not affect the password of the local sys user,
But changing the password of the sys user syncs the password file also.

Lets see an example :

-          Login with the sys using the password “oracle3”

--> sqlplus sys/oracle3@sri12c as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Fri Jul 26 06:31:22 2013

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show user
USER is "SYS"
SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL>

-          Create a password file with the password “oracle1”
--> orapwd file=orapwsri12c password=oracle
-          Now lets the passwords,

--> sqlplus sys/oracle3@sri12c as sysdba

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: sys/oracle1@sri12c as sysdba

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> conn sys/oracle3 as sysdba
Connected.

  The connection failed for the old password when connected using the Network (“@”) and it went fine when we used the password provided in the orapwd.

Also while using the old password and logged in locally, it worked.

-          Alter the sys password to oracle3 and let’s check if the password of the orapwd changes?

SQL> alter user sys identified by oracle3;

User altered.

SQL> conn sys/oracle3@sri12c as sysdba
Connected.

It got changed.


Now 12c PDB, the password file on 12c is for the CDB ,so when you change the password in the password file for the CDB , it goes the same for the PDB’s too.
Once the password is changed, the changed password file -password should be used to login from the next time.

And without the password file ,you will not be able to login to the PDB as we use to login to the PDB as a service “@” .



Thursday, July 25, 2013

Clone PDB (12c Pluggable Database)

Clone PDB
Note: The Clone is done on the same server.

1)  Shutdown  the pdb1
SQL> alter pluggable database pdb1 close;

Pluggable database altered.

2)  Open pdb1  in read only mode
SQL> alter pluggable database pdb1 open read only;

Pluggable database altered.

3) Clone using the below command
SQL> create pluggable database pdb2 from pdb1
FILE_NAME_CONVERT=('/12c/db/pdb1','/12c/db/pdb2');

Pluggable database created.

Elapsed: 00:01:00.23

4) Open the pdb2
SQL> alter pluggable database pdb2 open;

Pluggable database altered.

Elapsed: 00:00:08.95

5) Check the listener to make sure the pdb2 is listed and add the entry in oratab and tnsnames.ora (to use it in oraenv for setting the environment).

6) Connect to the pdb2 and play  ...
--> sqlplus srini/srini@pdb2

SQL*Plus: Release 12.1.0.1.0 Production on Thu Jul 25 07:23:10 2013

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

Last Successful login time: Thu Jul 15 2013 09:12:20 -05:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show con_name

CON_NAME
------------------------------
PDB2


SQL> conn sys@pdb2 as sysdba
Enter password:
Connected.
SQL> select sum(bytes/1024/1024/1024) from dba_data_files;

SUM(BYTES/1024/1024/1024)
-------------------------
               9.21

7) The 9GB DB was cloned in a Minute .


Wednesday, July 24, 2013

Connecting to Pluggable Database (PDB)...

The PDB runs as a service in the CDB.

Below steps will guide to connect to the PDB,

  •  Check if the service is up  - lsnrctl status

lsnrctl status

LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 24-JUL-2013 02:49:59

Copyright (c) 1991, 2013, Oracle.  All rights reserved.
.
.
.

Service "pdb1" has 1 instance(s).
  Instance "pdb1", status READY, has 1 handler(s) for this service...
The command completed successfully
  • Check the if the TNS has the valid  entry for the PDB.

pdb1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Sri12c)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb1)
    )
  )

  • To set the PDB environment ,add the entry in oratab


           pdb1:/app/oracle/12c:N

  • Set the environment using oraenv and connect to the pdb,

sqlplus sys@pdb1 as sysdba

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show con_name

CON_NAME
----------
PDB1

SQL> show con_id

CON_ID
-----------
3

  • The other way to connect to the pdb is :

             sqlplus pdbadmin/*****@Sri12c:1523/pdb1

             ==> Schema/Password@HOST:Port/Service_name