Oracle Installation reference: Https://www.cnblogs.com/zhichaoma/p/9288739.htmlfor CDB, startup and shutdown are the same as in previous traditional ways, with the following syntax:Startup[nomount | MOUNT | RESTRICT | UPGRADE | Force | READ only]Shutdown[immediate | ABORT]Create CDB manually1. Modify the ~/.bash_profile file, modify the Oracle_sid name
Export ORACLE_SID=ORCL
2. Create the required directory
$ mkdir-p/data/app/oracle/oradata/orcl$ mkdir-p/data/app/oracle/oradata/pdbseed$ mkdir-p/data/app/oracle/admin/ orcl/adump$ mkdir-p/data/app/oracle/fast_recovery_area
3. Create an initialization configuration file
$ vim $ORACLE _home/dbs/initcdb.oradb_name= ' orcl ' memory_target=1gprocesses = 150#audit_file_dest= ' <oracle_base >/admin/orcl/adump ' audit_file_dest= '/data/app/oracle/admin/orcl/adump ' audit_trail = ' db ' db_block_size=8192db_ domain= ' db_recovery_file_dest= '/data/app/oracle/fast_recovery_area ' db_recovery_file_dest_size=2gdiagnostic_ dest= '/data/app/oracle ' dispatchers= ' (protocol=tcp) (SERVICE=ORCL) ' open_cursors=300 remote_login_passwordfile= ' EXCLUSIVE ' undo_tablespace= ' UNDOTBS1 ' control_files = (/data/app/oracle/oradata/orcl/ora_control01.ctl,/data/app/ ORACLE/ORADATA/ORCL/ORA_CONTROL02.CTL) compatible = ' 12.2.0 ' enable_pluggable_database=true
4. Start creating a library
$ sqlplus/as sysdbasql> shutdown abortsql> create SPFile from pfile= ' $ORACLE _home/dbs/initcdb.ora '; Sql> Startup Nomount
sql> CREATE DATABASE orcluser SYS identified by Passuser SYSTEM identified by Passlogfile GROUP 1 ('/data/app/oracle/or Adata/orcl/redo01a.log ', '/data/app/oracle/oradata/orcl/redo01b.log ') SIZE 100M BLOCKSIZE, GROUP 2 ('/data/app/ora Cle/oradata/orcl/redo02a.log ', '/data/app/oracle/oradata/orcl/redo02b.log ') SIZE 100M BLOCKSIZE 512MAXLOGHISTORY 1MAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 1024CHARACTER set al32utf8national CHARACTER set Al16utf16extent MANAGEMENT Localdatafile '/data/app/oracle/oradata/orcl/system01.dbf ' SIZE 700MSYSAUX datafile '/data/app/oracle/oradata/orcl/ sysaux01.dbf ' size 550MDEFAULT tablespace deftbs datafile '/data/app/oracle/oradata/orcl/deftbs01.dbf ' size 500MDEFAULT temporary tablespace tempts1 tempfile '/data/app/oracle/oradata/orcl/temp01.dbf ' SIZE 20M UNDO tablespace UNDOTBS1 datafile '/data/app/oracle/oradata/orcl/undotbs01.dbf ' SIZE 200M ENABLE pluggable databaseseedfile_name_ CONVERT = ('/data/app/oracle/oradata/orcl/', '/data/app/oracle/oradata/pdbseed/') SYSTEM datafiles size 125M autoextend on NEXT 10M MAXSIZE unlimitedsysaux datafiles SIZE 100muser_data tablesp ACE usertbsdatafile '/data/app/oracle/oradata/pdbseed/usertbs01.dbf ' SIZE 200M;
填充数据字典,如果是12cR2版本,则直接执行catcdb.sql代替以下脚本
使用sysdba权限执行以下脚本
Sql> @?/rdbms/admin/catalog.sql--Database dictionary, dynamic view creation, etc. sql> @?/rdbms/admin/catproc.sql--pl/sql stored procedure related code sql> @?/ Rdbms/admin/utlrp.sql --Compiling
Use the system user to execute the following script
sql> @?/sqlplus/admin/pupbld.sql #SQL *plus Related
12cr2
Note: This process may be a bit long
Sql> @?/rdbms/admin/catcdb.sql
You are prompted for the following information
Enter value for 1:/data/app/oracle/product/12.2.0/db_1/rdbms/adminenter value for 2:/data/app/oracle/product/12.2.0/ db_1/rdbms/admin/catcdb.pl
If the following error occurs
1) Error-1
Can ' t locate util.pm in @INC (@INC contains:/DATA/APP/ORACLE/PRODUCT/12.2.0/DB_1/RDBMS/ADMIN/USR/LOCAL/LIB64/PERL5
/data/app/oracle/product/12.2.0/db_1/rdbms/admin/catcdb.pl line 35.BEGIN failed--compilation aborted at/data/app/ oracle/product/12.2.0/db_1/rdbms/admin/catcdb.pl Line 35.
Workaround:
$ find $ORACLE _home-name util.pm | wc-l0$ find $ORACLE _home-name util.pm | wc-l5$ Find $ORACLE _home-name util.pm/data/app/oracle/product/12.2.0/db_1/perl/lib/5.22.0/x86_64- linux-thread-multi/hash/util.pm/data/app/oracle/product/12.2.0/db_1/perl/lib/5.22.0/x86_64-linux-thread-multi/ List/util.pm/data/app/oracle/product/12.2.0/db_1/perl/lib/5.22.0/x86_64-linux-thread-multi/scalar/util.pm/data /app/oracle/product/12.2.0/db_1/perl/lib/5.22.0/x86_64-linux-thread-multi/sub/util.pm/data/app/oracle/product/ 12.2.0/db_1/perl/lib/site_perl/5.22.0/http/headers/util.pm
Manually modifying catcdb.pl scripts
Use Util qw (trim, splittoarray); Util change to Util
Another round of tests, the result is that there will be an error, this attempt will make you start to doubt whether your choice is in the right direction.
If still not found, the description in the current environment variable does not match to the relevant content, we need to switch directly to the directory hash, and then run the script can, this time there is an error
2) Error-2
Can ' Tlocate term/readkey.pm in @INC (@INC contains:/data/app/oracle/product/12.2.0/db_1/rdbms/admin/usr/local/lib64 /perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share /perl5.) at/data/app/oracle/product/12.2.0/db_1/rdbms/admin/catcdb.pl Line 30.beginfailed--compilation aborted at/data/app/ oracle/product/12.2.0/db_1/rdbms/admin/catcdb.pl Line 30.
Declaring environment variables
Export path= $ORACLE _home/bin: $ORACLE _home/opatch: $ORACLE _home/perl/bin: $ORACLE _home/jdk/bin: $PATH
Validation results
Sql> select name, DECODE (CDB, ' YES ', ' multitenant Option enabled ', ' Regular 12c Database: ') ' Multitenant Option ", Open_mode, con_id from V$database;
Create PDB
1. View current Container
$ sqlplus/as sysdbasql> show Con_name; Con_name------------------------------Cdb$root
2. Create a new PDB
$ mkdir-p/data/app/oracle/oradata/pdb1sql> Create pluggable database pdb1 Admin user pdb1 identified by PDB1 File_nam e_convert= ('/data/app/oracle/oradata/pdbseed/', '/data/app/oracle/oradata/pdb1/');
3. View all PDB
Sql> show PDBs; con_id con_name OPEN MODE RESTRICTED------------------------------------------------------------2 pdb$ SEED READ only NO 3 PDB1 mounted
4. Start and close a created PDB
1) Start PDB and close PDB
A) Start the PDB
sql> Alter pluggable database PDB1 open; Pluggable database altered. Sql> show PDBs; con_id con_name OPEN MODE RESTRICTED------------------------------------------------------------2 pdb$ SEED Read Only No 3 PDB1 READ WRITE NO
b) Turn off the PDB
sql> Alter pluggable database PDB1 close; Pluggable database altered. Sql> show PDBs; con_id con_name OPEN MODE RESTRICTED------------------------------------------------------------2 pdb$ SEED READ only NO 3 PDB1 mounted
2) Start and close the PDB using traditional startup and shutdown commands via Sqlplus
A) Start the PDB
Sql> alter session set CONTAINER=PDB1; Session altered. Sql> show PDBs; con_id con_name OPEN MODE RESTRICTED------------------------------------------------------------3 PDB1 mountedsql> startuppluggable Database opened. Sql> show PDBs; con_id con_name OPEN MODE RESTRICTED------------------------------------------------------------3 PDB1 READ WRITE NO
b) Turn off the PDB
sql> shutdown immediate; Pluggable Database closed. Sql> show PDBs; con_id con_name OPEN MODE RESTRICTED------------------------------------------------------------3 PDB1 Mounted
5. Configuring monitoring
$ vim $ORACLE _home/network/admin/listener.ora# Listener.ora network Configuration File:/data/app/oracle/product/ 12.2.0/db_1/network/admin/listener.ora# Generated by Oracle configuration tools. LISTENER = (description_list = ( DESCRIPTION = ( ADDRESS = (PROTOCOL = TCP) (HOST = DB) (PORT = 1521)) (Addre SS = (PROTOCOL = IPC) (KEY = EXTPROC1521)) ) Sid_list_listener = (sid_list = ( sid_desc= ( Global_dbname = ORCL) ( sid_name = ORCL) ) (sid_desc= (global_dbname = PDB1) (sid_name = PDB1) ) )
$ vim $ORACLE _home/network/admin/tnsnames.ora //If this file does not exist, manually create LISTENER_ORCL = (ADDRESS = (PROTOCOL = TCP) (HOST = db) (port = 1521)) ORCL = (DESCRIPTION = ( ADDRESS = (PROTOCOL = TCP) (HOST = db) (port = 1521)) (Connect_data =< c5/> (SERVER = dedicated) (service_name = ORCL) ) ) pdb1 = (DESCRIPTION = ( ADDRESS = (PROTOCOL = TCP) (HOST = DB) (PORT = 1521)) (Connect_data = (SERVER = dedicated) (service_name = pdb1) ) )
6. Test and Login
$ tnsping pdb1//Test Login $ sqlplus pdb1/[email protected] //Login
Data pump Import Export PDB data
Take PDB1 database as an example
1. Start the PDB1 database
$ sqlplus/as sysdbasql> alter session set CONTAINER=PDB1; Sql> Startup
2. Create an Import data catalog and a database mapping relationship
$ mkdir-p/home/oracle/dump_dirsql> alter session set CONTAINER=PDB1; Sql> Create directory Dump_dir as '/home/oracle/dump_dir ';
3. Create a data pump for DBA Authority Import Export user
Sql> Grant DBA to DP identified by DP; Sql> Grant Read,write on the directory Dump_dir to DP;
4. Exporting data
$ EXPDP dp/[email protected] directory= "Dump_dir" dumpfile= "Aa.dmp" Logfile=aa.log
5. Import data
$ IMPDP dp/[email protected] directory= "Dump_dir" dumpfile= "Aa.dmp" Logfile=bb.log
Oracle 12c CDB and PDB