How Oracle 12c connects to CDB and PDB

Source: Internet
Author: User


1 Connecting to CDB

The same connection as the normal instance. Specify that ORACLE_SID can use OS authentication later, or you can connect using a password.

[Email protected]/]$ echo $ORACLE _sid

Cndba

[Email protected]/]$ Sqlplus/as SYSDBA

Sql*plus:release 12.1.0.1.0 Production Onmon APR 28 11:33:43 2014

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

Connected to:

Oracle Database 12c Enterprise editionrelease 12.1.0.1.0-64bit Production

With the partitioning, OLAP, Advancedanalytics and Real application testing options

Sql> Conn System/oracle

Connected.

Sql>

-- To view the available service in CDB :

sql> COLUMN name FORMAT A30

Sql> SELECT name,pdb

2 from V$services

3 ORDER by name;

NAME PDB

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

Sys$background Cdb$root

Sys$users Cdb$root

CNDBA Cdb$root

Cndbaxdb Cdb$root

Pcndba2 PCNDBA2

PDBCNDBA PDBCNDBA

6 rows selected.

-- The LSNRCTL can also be judged by :

[[email protected]/]$ LSNRCTL Service

Lsnrctl for linux:version 12.1.0.1.0-production on 28-apr-2014 11:35:31

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

Connecting to (Description= (address= (PROTOCOL=IPC) (key=extproc1521)))

Services Summary ...

Service "CNDBA" has 1instance (s).

Instance "Cndba", status ready, have 1 handler (s) for thisservice ...

Handler (s):

"Dedicated" established:0 refused:0 State:ready

LOCAL SERVER

Service "Cndbaxdb" has 1instance (s).

Instance "Cndba", status ready, have 1 handler (s) for thisservice ...

Handler (s):

"D000" established:0 refused:0 current:0 max:1022 state:ready

DISPATCHER <machine:ora12c, pid:10085>

(Address= (PROTOCOL=TCP) (host=ora12c) (port=14696))

Service "Pcndba2" has 1instance (s).

Instance "Cndba", status ready, have 1 handler (s) for thisservice ...

Handler (s):

"Dedicated" established:0 refused:0 State:ready

LOCAL SERVER

Service "PDBCNDBA" has 1instance (s).

Instance "Cndba", status ready, have 1 handler (s) for thisservice ...

Handler (s):

"Dedicated" established:0 refused:0 State:ready

LOCAL SERVER

The command completed successfully

[Email protected]/]$

With these service, you can connect to CDB remotely.

--ezconnect

C:\users\dave>sqlplussystem/[email PROTECTED]:1521/CNDBA

Sql*plus:release 11.2.0.1.0 Production on Wednesday April 30 11:36:48 2014

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

Connect to:

Oracle Database 12c Enterprise editionrelease 12.1.0.1.0-64bit Production

With the partitioning, OLAP, Advancedanalytics and Real application testing options

Sql>

-- Connect via Tnsnames.ora :

The configuration in Tnsnames.ora is as follows:

CNDBA =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.10) (PORT = 1521))

(Connect_data =

(SERVER = dedicated)

(service_name = CNDBA)

)

)

-- Connection:

C:\users\dave>sqlplussystem/[email protected]

Sql*plus:release 11.2.0.1.0 Production on Wednesday April 30 11:40:01 2014

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

Connect to:

Oracle Database 12c Enterprise editionrelease 12.1.0.1.0-64bit Production

With the partitioning, OLAP, Advancedanalytics and Real application testing options

Sql>

2 switching between different container database

In the 12c architecture, there are many different container because of the presence of CDB and PDB, so it is necessary to switch when connecting to different container.

-- to view the current container:

Sql> Show Con_name

Con_name

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

Cdb$root

sql> SELECT sys_context (' USERENV ', ' Con_name ') from dual;

Sys_context (' USERENV ', ' con_name ')

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

Cdb$root

Sql> Set Lin 140

Sql> Select con_id, Dbid,guid, name, Open_mode from V$pdbs;

con_id DBID GUID NAME Open_mode

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

2 4088301206 f7c1e3c96bbf0585e0430a01a8c05459 pdb$seed READ only

3 426143573f7c209eb1dfc0854e0430a01a8c0b787 pdbcndba READ WRITE

4 1231796139 f812de1b6a8f363ae0430a01a8c0c759 PCNDBA2 READ WRITE

-- Toggle Container:

Sql> alter session SETCONTAINER=PCNDBA2;

Session altered.

Sql> Show Con_name

Con_name

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

PCNDBA2

3 Connecting to the PDB

--ezconnect:

c:\users\dave>sqlplussystem/[email protected]:1521/pcndba2

Sql*plus:release 11.2.0.1.0 Production on Wednesday April 30 11:54:30 2014

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

Connect to:

Oracle Database 12c Enterprise editionrelease 12.1.0.1.0-64bit Production

With the partitioning, OLAP, Advancedanalytics and Real application testing options

Sql>

--tnsnames.ora

In Tnsnames.ora, add the following:

PCNDBA =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.10) (PORT = 1521))

(Connect_data =

(SERVER = dedicated)

(service_name = pcndba2)

)

)

C:\users\dave>Sqlplussystem/[email protected]

Sql*plus:release 11.2.0.1.0 Production on Wednesday April 30 11:55:50 2014

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

Connect to:

Oracle Database 12c Enterprise editionrelease 12.1.0.1.0-64bit Production

With the partitioning, OLAP, Advancedanalytics and Real application testing options

Sql>

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

Copyright, the article allows reprint, but must be linked to the source address, otherwise investigate legal responsibility!

Aboutdave:

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

qq:251097186

Email: [email protected]

Blog:http://blog.csdn.net/tianlesoftware

Weibo:http://weibo.com/tianlesoftware

Twitter:http://twitter.com/tianlesoftware

Facebook:http://www.facebook.com/tianlesoftware

Linkedin:http://cn.linkedin.com/in/tianlesoftware

Dave's QQ Group:

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

Note: Add group must indicate tablespace and data file relationship | Do not repeat the addition group

cndba_1:104207940 (Full) cndba_2:62697716 (full) cndba_3:283816689

cndba_4:391125754 cndba_5:62697850 cndba_6:62697977 cndba_7:142216823 (full)

How Oracle 12c connects to CDB and PDB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.