管理多组用户环境 多租户架构使Oracle数据库可以作为多租户容器数据库(CDB)运行,该数据库包括零个,一个或多个客户创建的可插拔数据库(PDB); 一、创建和配置CDB #######create database step1>确定ORACLE_SID export ORACLE_SID=mynewdb step2>环境变量配置 step3>数据库管理验证,密码文件创建 step4>创建初始化参数文件 db_name='ming' ###must be memory_target=512M processes = 150 db_block_size=8192 db_domain='' db_recovery_file_dest='/u01/app/oracle/flash_recovery_area' db_recovery_file_dest_size=2G diagnostic_dest='/u01/app/oracle/' dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)' open_cursors=300 remote_login_passwordfile='EXCLUSIVE' undo_tablespace='UNDOTBS1' control_files = (/u01/app/oracle/ora_control1.ctl, /u01/app/oracle/ora_control2) compatible ='12.0.0' step5>连接到实例 sqlplus / nolog SQL>conn /as sysdba step6>创建参数文件(确保参数文件的目录都已经创建) SQL> create spfile from pfile; step7>启动实例 SQL> startup nomount; step8>使用create database 创建CDB #########方法一:使用OMF(oracle Managed files) 需要配置参数db_create_file_dest,enable_pluggable_database alter system set db_create_file_dest='/u01/app/oracle/oradata'; alter system set enable_pluggable_database=true scope=spfile; #### CREATE DATABASE ming USER SYS IDENTIFIED BY 123456 USER SYSTEM IDENTIFIED BY 123456 EXTENT MANAGEMENT LOCAL DEFAULT TABLESPACE users DEFAULT TEMPORARY TABLESPACE temp UNDO TABLESPACE undotbs1 ENABLE PLUGGABLE DATABASE SEED SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED SYSAUX DATAFILES SIZE 100M; #######配置per环境变量 SQL> @?/rdbms/admin/catcdb.sql ######环境变量配置 export PATH=$ORACLE_HOME/perl/bin:$PATH export PERL5LIB=$ORACLE_HOME/perl/lib/5.14.1:$ORACLE_HOME/perl/lib/site_perl/5.14.1/x86_64-linux-thread-multi ####note 12.1是sql的方式调用 n 12.2全新改版,使用perl脚本封装 #######生成日志 SQL> host perl -I &&rdbms_admin &&rdbms_admin_catcdb --logDirectory &&1 --logFilename &&2 #######CDB创建完成 二、创建和删除PDB 方法一:创建PDB CDB处于读/写模式,当前容器是CDB根目录、当前用户具有create pluggable database 系统特权 step1>确保在容器的跟目录 SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') FROM DUAL; step2>运行创建语句 CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY 123456; CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY password ROLES =(DBA);###方法二 CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY password STORAGE (MAXSIZE 2G) DEFAULT TABLESPACE sales DATAFILE '/disk1/oracle/dbs/salespdb/sales01.dbf' SIZE 250M AUTOEXTEND ON PATH_PREFIX = '/disk1/oracle/dbs/salespdb/' FILE_NAME_CONVERT = ('/disk1/oracle/dbs/pdbseed/', '/disk1/oracle/dbs/salespdb/'); #####方法三 方法二:unplug/plug unplug: alter pluggable database test unplug into 'path/test.xml'; plug: create pluggable database my_pdb using 'path/test.xml'; ######删除数据库软件 图形化界面: 路径: software + db DB : DBCA ---delete database SQL> mount; alter session distcitxxxx;(drop) drop database; show database name; 数据库文件,参数文件,控制文件都删除; rman target / drop database include xxx; 备份,归档,数据 software: 图形化: 命令: rm -rf $ORACLE_BASE /usr/local/bin/ /etc/ora* oraInst.loc oratabs
学问:纸上得来终觉浅,绝知此事要躬行
为事:工欲善其事,必先利其器。
转载请标注出处!