1-企业管理器介绍
图形化工具 Enterprise Management Database Control
EMDC Enterprise Management Database Control 针对单台服务器(单实例)管理的(11g及之前)
EMDE Enterprise Management Database Express(12c及之后)
EMGC Enterprise Management Grid Control (grid infrastructure)集中管理多套服务器
EMCC Enterprise Management Colud Control Oracle强烈推荐云控制器
如何配置EMDE
SQL> exec dbms_xdb_config.SETHTTPSPORT(5500);
PL/SQL procedure successfully completed.
通过浏览器输入 https://192.168.45.128:5500/em
了解EMGC和EMCC的体系
2-容器数据库的创建-PDB$SEED
从PDB$SEED创建PDB
带位置子句
1)子句:FILE_NAME_CONVERT
mkdir /u01/app/oracle/oradata/CDB19C1/hr
create pluggable database hr
admin user henry identified by henry roles=(connect)
file_name_convert=('种子容器数据文件所在的路径','新创建的PDB数据文件所在路径');
create pluggable database hr
admin user henry identified by henry roles=(connect)
file_name_convert=('/u01/app/oracle/oradata/CDB19C1/pdbseed/','/u01/app/oracle/oradata/CDB19C1/hr/');
2)子句:CREATE_FILE_DEST(隐含开启了OMF)
mkdir /u01/app/oracle/oradata/CDB19C1/sales
create pluggable database sales
admin user henry identified by henry roles=(connect)
create_file_dest='新创建的PDB数据文件所在路径';
create pluggable database sales
admin user henry identified by henry roles=(connect)
create_file_dest='/u01/app/oracle/oradata/CDB19C1/sales/';
不带位置子句
1)DB_CREATE_FILE_DEST
SQL> !mkdir /u01/app/oracle/oradata/CDB19C1/orders
SQL> alter system set db_create_file_dest='/u01/app/oracle/oradata/CDB19C1/orders';
create pluggable database orders
admin user henry identified by henry roles=(connect);
2)PDB_FILE_NAME_CONVERT
mkdir /u01/app/oracle/oradata/CDB19C1/prod5
SQL> alter system set
pdb_file_name_convert='/u01/app/oracle/oradata/CDB19C1/pdbseed/','/u01/app/oracle/oradata/CDB19C1/prod5';
create pluggable database prod5
admin user henry identified by henry roles=(connect);
3-克隆本地PDB
需求:本地PDB数据库PDB,里面有个SCOTT用户,用户下面有张表:EMP
通过PDB数据库,在本地快速克隆出一个测试库
1)PDB(PDB)数据库改为只读模式
show pdbs
alter pluggable database pdb close;
alter pluggable database pdb open read only;
2)创建目录
SQL> !mkdir /u01/app/oracle/oradata/CDB19C1/erp
3)本地克隆PDB
SQL> create pluggable database erp from pdb
create_file_dest='/u01/app/oracle/oradata/CDB19C1/erp';
Pluggable database created.
4)开启PDB验证数据
SQL> alter pluggable database erp open;
Pluggable database altered.
5)把源PDB数据库开启
sqlplus / as sysdba
Alter pluggable database pdb close;
Alter pluggable database pdb open;
4-删除PDB
首先需要关闭数据库
Alter pluggable database xxx close;
然后进行删除
Drop pluggable database xxx including datafiles;
如果要进行keep datafiles,需要提前unplug
SQL> alter pluggable database hr unplug into '/tmp/xxx.xml';
5-CDB和PDB备份恢复
基于PDB时间点恢复
1)备份
2)在ERP里面创建一个用户
SQL> alter session set container=ERP;
SQL> create user oracle identified by oracle;
SQL> grant dba to oracle;
SQL> conn oracle/oracle@erp
create table test(id number);
insert into test select object_id from dba_objects where rownum conn sys/oracle@erp as sysdba
Connected.
SQL> select current_scn from v$database;
4) 删除用户oracle
SQL> show user
USER is "SYS"
SQL>
SQL> drop user oracle cascade;
SQL> select username from dba_users where username='ORACLE';
5)关闭ERP
SQL> alter pluggable database erp close;
6)RMAN还原恢复ERPTEST
run{
set until scn 2834234;
restore pluggable database erp;
recover pluggable database erp auxiliary destination='/soft/backup/auxi';
alter pluggable database erp open resetlogs;
}