Oracle 12c 如何连接到 CDB 和 PDB

1  连接到CDB

和普通实例一样的连接。 指定ORACLE_SID 以后可以使用OS认证,也可以使用密码进行连接。

[[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, 2013, 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>

--查看CDB中可用的service:

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.

--通过lsnrctl 也可以判断:

[[email protected] /]$ lsnrctl service

LSNRCTL for Linux: Version 12.1.0.1.0 -Production on 28-APR-2014 11:35:31

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

Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

Services Summary...

Service "cndba" has 1instance(s).

Instance "cndba", status READY, has 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, has 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, has 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, has 1 handler(s) for thisservice...

Handler(s):

"DEDICATED" established:0 refused:0 state:ready

LOCAL SERVER

The command completed successfully

[[email protected] /]$

通过这些service,就可以远程连接CDB。

--EZCONNECT

C:\Users\Dave>sqlplussystem/[email protected]:1521/cndba

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 4月 30 11:36:48 2014

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

连接到:

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连接:

在tnsnames.ora 中配置如下:

cndba =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = cndba)

)

)

--连接:

C:\Users\Dave>sqlplussystem/[email protected]

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 4月 30 11:40:01 2014

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

连接到:

Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0 - 64bit Production

With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options

SQL>

2  在不同Container database中切换

在12c的架构中,因为有CDB和 PDB的存在,所以会有很多不同的container,所以在连接到不同的container时,就需要进行切换。

--查看当前的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

--切换container:

SQL> alter session setcontainer=pcndba2;

Session altered.

SQL> show con_name

CON_NAME

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

PCNDBA2

3  连接到PDB

--EZCONNECT:

C:\Users\Dave>sqlplussystem/[email protected]:1521/pcndba2

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 4月 30 11:54:30 2014

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

连接到:

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

在tnsnames.ora 中添加如下内容:

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 星期三 4月 30 11:55:50 2014

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

连接到:

Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0 - 64bit Production

With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options

SQL>

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

版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

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 的QQ群:

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

注意:加群必须注明表空间和数据文件关系 | 不要重复加群

CNDBA_1: 104207940 (满)    CNDBA_2: 62697716 (满)   CNDBA_3: 283816689

CNDBA_4: 391125754   CNDBA_5: 62697850    CNDBA_6: 62697977   CNDBA_7: 142216823(满)

时间: 2024-12-13 19:24:01

Oracle 12c 如何连接到 CDB 和 PDB的相关文章

浅谈oracle 12C的新特性-CDB和PDB

最近看到好多人都在尝试oracle中的12C新特性-容器数据库,今年3月orcle退出了Release2版本,可以算是一个稳定版本了.下午着手尝试了一下,还是蛮不错得 1.前言 CDB与PDB是Oracle 12C引入的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库(PDB).CDB全称为ContainerDatabase,中文翻译为数据库容器,PDB全称为Pluggable Datab

Oracle 12c 配置和修改 CDB 和 PDB 参数

1  配置CDB 实例参数 配置CDB 的实例参数和普通实例一样,通过ALTER SYSTEM 即可设置初始化参数,一些数据库的配置可以使用ALTERDATABASE 命令. 连接上rootcontainer之后,可以使用alter system命令来修改,默认仅对root container有效,也就是当前的container. 下面2个命令作用相同: ALTER SYSTEM SET parameter_name=value; ALTER SYSTEM SET parameter_name=

Oracle 12C -- clone a non-cdb as a pdb

将non-CDB置为只读模式: $ sqlplus '/as sysdba' SQL> select name, decode(cdb, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option" , open_mode, con_id from v$database; NAME Multitenant Option OPEN_MODE CON_ID --------- -

Oracle 12c 多租户在 CDB 中 Plug A PDB,Unplugging A PDB

Oracle 数据库 12 c 中介绍了多租户选项允许单个容器数据库 (CDB) 来承载多个单独的可插拔数据库 (PDB).本文简单的演示了如何在 CDB 中 Plug A PDB,Unplugging A PDB 操作. 一. plugged PDB into Unplugged PDBSQL> show pdbs    CON_ID CON_NAME  OPEN MODE  RESTRICTED---------- ------------------------------ -------

oracle 12c 学习之三 nocdb 转换成pdb

01:23:06 [email protected]> select name, decode(cdb, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option" , open_mode, con_id from v$database; NAME Multitenant Option OPEN_MODE CON_ID --------- -----------------

Oracle12c多租户如何连接到CDB或PDB、CDB与PDB容器切换

Oracle 数据库 12 c 多租户选项允许单个容器数据库 (CDB) 来承载多个单独的可插拔数据库 (PDB).那么我们如何连接到容器数据库 (CDB) 和可插拔数据库 (PDB). 1. V$SERVICES视图可以显示数据库中的可用服务.SQL> col pdb for a40SQL> col name for a30;SELECT name, pdb FROM v$services ORDER BY name;SQL> NAME       PDB---------------

Oracle 12c CDB 和PDB 数据库的启动与关闭 说明

在Oracle 12c中,分CDB 和PDB,他们的启动和关闭操作整理如下. 1  Container Database (CDB) 对于CDB,启动和关闭与之前传统的方式一样,具体语法如下: STARTUP[NOMOUNT | MOUNT | RESTRICT | UPGRADE | FORCE | READ ONLY] SHUTDOWN[IMMEDIATE | ABORT] 要注意,在12c数据库创建完成后,默认情况下使用sqlplus / as sysdba  登录连接的是CDB. [[e

oracle 12c 创建PDB用户即Local User (PDB与CDB)

Oracle 12C用户创建与表空间分配 数据库安装完成后,首先用系统用户链接数据库容器(CDB), 在数据库容器(CDB)中创建表空间‘imei’ SQL>create tablespace iemi datafile'E:\Oracle_DB\ cdb_iemi.dbf'size 10240m autoextend on next 200m; 表空间已创建. 接下来在Oracle 12C数据库中创建用户时会报ORA-65096错误. SQL> create user imei identi

Oracle 12c 使用scott等普通用户的方法

目录: 一.前言 二.使用普通用户 三.自动启动PDB 一.前言 最近电脑上安装了oracle 12c数据库,想体验下新特性.安装完后,便像11g一样在dos窗口进行下面的操作: SQL*Plus: Release 12.1.0.2.0 Production on 星期日 8月 9 13:06:33 2015 Copyright (c) 1982, 2014, Oracle. All rights reserved. 连接到: Oracle Database 12c Enterprise Edi