当前位置:网站首页>登录连接 CDB 和 PDB
登录连接 CDB 和 PDB
2022-07-05 17:42:00 【用户8006012】
[email protected]> select name from v$datafile;
NAME
------------------------------------------------------------------------------------------------------------------------
/oradata/ORCL/system01.dbf
/oradata/ORCL/sysaux01.dbf
/oradata/ORCL/undotbs01.dbf
/oradata/ORCL/pdbseed/system01.dbf
/oradata/ORCL/pdbseed/sysaux01.dbf
/oradata/ORCL/users01.dbf
/oradata/ORCL/pdbseed/undotbs01.dbf
7 rows selected.
[email protected]> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
[email protected]>
1 连接 CDB 和 PDB
1.1 设置 ORACLE_SID
配置 ORACLE_SID,使用 OS 验证连接 cdb1
[[email protected]:/home/oracle]$ export ORACLE_SID=cdb1
[[email protected]:/home/oracle]$ echo $ORACLE_SID1.2 连接多租户数据库 cdb1
设置了 ORACLE_SID 环境变量后,直接使用 sqlplus 本地操作系统认证登录
[[email protected]:/home/oracle]$ sqlplus / as sysdbadbca 建库后, tnsnames.ora 中已经增加了 ORCL
[[email protected]:/home/oracle]$ cat $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.3.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = orcl19C)(PORT = 1521))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = orcl19C)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
使用 tnsnames 服务名登录
[[email protected]:/home/oracle]$ sqlplus sys/[email protected] as sysdba1.3 查看数据库是否是多租户数据库
[email protected]> select name,cdb from v$database;
NAME CDB
--------- ---
ORCL YES1.4 查看当前连接的容器
[email protected]> show con_name
CON_NAME
------------------------------
CDB$ROOT
[email protected]> show con_id
CON_ID
------------------------------
11.5 查看可插拔数据库 pdb 状态
[email protected]> select name,con_id,open_mode from v$pdbs;
NAME CON_ID OPEN_MODE
------------------------------ ---------- ----------
PDB$SEED 2 READ ONLY
[email protected]> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO1.6 连接到可插拔数据库 pdb
方法一:alter session set container
[email protected]> alter session set container=pdb1;
[email protected]> show con_name
方法二:使用服务名连接
查看 pdb1 服务名
[email protected]> select name,con_id from v$services;
ezconnect 方式
使用 ezconnect 的方式,明确指定主机名(ip 地址)、端口号、服务名
[[email protected] ~]$ sqlplus sys/[email protected]:1521/pdb1 as sysdba
配置 tnsnames.ora 增加 pdb1
编写客户端网络配置文件 tnsnames.ora,增加 pdb1 的配置
[[email protected] ~]$ cd $ORACLE_HOME/network/admin
[[email protected] admin]$ vi tnsnames.ora
pdb1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = orcl19C)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
sqlplus 通过服务名连接 pdb1
[[email protected] ~]$ sqlplus sys/[email protected] as sysdba
[email protected]> show con_name
[email protected]> show pdbs
cdb 使用 connect 命令切换到 pdb
查看当前容器
[email protected]> show pdbs
sqlplus 中使用 connect 命令直接切换到 pdb1
[email protected]> conn sys/[email protected] as sysdba
[email protected]> show pdbs1.7 pdb 切换回 cdb
1.7.1 方法一:alter session set container
[email protected]> alter session set container=cdb$root;
[email protected]> show pdbs
建议通过服务名的方式切换或连接
[email protected]> conn sys/[email protected] as sysdba边栏推荐
- EPM相关
- Is it safe for China Galaxy Securities to open an account? How long can I buy stocks after opening an account
- 毫无章法系列
- Neural network self cognition model
- Is it safe to open an account online? What is the general interest rate of securities financing?
- Teamcenter 消息注册前操作或後操作
- Sentinel-流量防卫兵
- Zabbix
- rsync
- LeetCode每日一题:合并两个有序数组
猜你喜欢

MySQL之知识点(七)

RSE2020/云检测:基于弱监督深度学习的高分辨率遥感图像精确云检测

"Xiaodeng in operation and maintenance" is a single sign on solution for cloud applications

Server configuration jupyter environment

Kafaka技术第一课

Zabbix

职场进阶指南:大厂人必看书籍推荐

Ten capabilities that cyber threat analysts should have

LeetCode每日一题:合并两个有序数组

Configure pytorch environment in Anaconda - win10 system (small white packet meeting)
随机推荐
SQL Server(2)
解决“双击pdf文件,弹出”请安装evernote程序
Configure pytorch environment in Anaconda - win10 system (small white packet meeting)
Please tell me why some tables can find data by writing SQL, but they can't be found in the data map, and the table structure can't be found
Leetcode daily question: the first unique character in the string
Anaconda中配置PyTorch环境——win10系统(小白包会)
Server configuration jupyter environment
Webapp development - Google official tutorial
mybash
RSE2020/云检测:基于弱监督深度学习的高分辨率遥感图像精确云检测
CVPR 2022 best student paper: single image estimation object pose estimation in 3D space
Count the running time of PHP program and set the maximum running time of PHP
Disabling and enabling inspections pycharm
Abnormal recovery of virtual machine Oracle -- Xi Fenfei
Cartoon: interesting [pirate] question
2022 information system management engineer examination outline
较文心损失一点点性能提升很多
Which platform of outer disk gold is regular and safe, and how to distinguish it?
Why is February 28 in the Gregorian calendar
Sentinel-流量防卫兵