Thursday 10 September 2015

Remote Connection to Pluggable Database 12c

Database details

SQL> select  banner from  v$version;

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

SQL>


pluggable database list 

SQL> select con_id, name from v$containers;

    CON_ID NAME
---------- ------------------------------
         1 CDB$ROOT
         2 PDB$SEED
         3 PDB1

=> I have only one pluggable database PDB1


1) create user(local user) in pluggable database

SQL> show con_id

CON_ID
------------------------------
1
SQL> show user
USER is "SYS"

SQL>  alter pluggable database pdb1 open;

Pluggable database altered.


SQL> alter session set container=pdb1;

Session altered.

SQL> show con_id

CON_ID
------------------------------
3
SQL> show user
USER is "SYS"


SQL> create user local_scott
  2  identified by tiger
  3  CONTAINER=CURRENT;

User created.

SQL> grant connect,resource to local_scott;

Grant succeeded.

2) edit listener file listener.ora (add plugglabe database entry)

/u01/app/oracle/product/12.1.0.2/db_1/network/admin   ---file location

[oracle@cdb1 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0.2/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = cdb1)
      (ORACLE_HOME = /u01/app/oracle/product/12.1.0.2/db_1)
      (SID_NAME = cdb1)
    )
  )
(SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/12.1.0.2/db_1)
      (SID_NAME = orcl)
    )
  )
(SID_LIST =
    (SID_DESC =
      (SID_NAME = PDB1)
      (ORACLE_HOME = /u01/app/oracle/product/12.1.0.2/db_1)
    )
)
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = cdb1.example.com)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

3)Edit tnsfile  file tnsnames.ora  (add pluggable database entry)

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0.2/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

CDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = cdb1.example.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = cdb1)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = cdb1.example.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
PDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = cdb1.example.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PDB1)
    )
  )

4) check test conectivity

[oracle@cdb1 admin]$ tnsping pdb1

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 11-SEP-2015 06:59:41

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = cdb1.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PDB1)))
OK (10 msec)

5) connect pluggable database using local user (local_scott)

[oracle@cdb1 admin]$ sqlplus local_scott/tiger@pdb1

SQL*Plus: Release 12.1.0.2.0 Production on Fri Sep 11 07:04:56 2015

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

Last Successful login time: Fri Sep 11 2015 07:04:39 +05:30

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

SQL> show con_id

CON_ID
------------------------------
3
SQL> show user;
USER is "LOCAL_SCOTT"
SQL>




















work on autovacuum postgreSQL parameter

 In This blog, we are discussing the auto vacuum parameter on a small scale. we will understand the below parameters and will see how to mod...