Oracle 12c 手動建立CDB

eric0435發表於2017-08-08

使用create database建立CDB的具體操作如下:
1.指定例項標識(SID)
ORACLE_SID環境變數被用來區分不同的例項。
1.決定例項的唯一標識SID
2.開啟命令視窗
3.設定ORACLE_SID環境變數

在Unix/Linux下設定ORACLE_SID環境變數如下:
export ORACLE_SID=mynewdb

setenv ORACLE_SID=mynewdb

在Windows下設定ORACLE_SID環境變數如下:
set ORACLE_SID=mynewdb

2.確保所需的環境變數被設定
依賴於平臺,在啟動SQL*Plus之後,可能需要設定相關的環境變數,或者驗證相關的設定。例如,在大多數平臺中,ORACLE_SID與ORACLE_HOME必須設定。另外,建議PATH環境變數包含ORACLE_HOME/bin目錄。在Unix/Linux平
臺中,必須手動設定這些環境變數。在Windows平臺中,OUI會自動設定ORACLE_HOME與ORACLE_SID。如果在安裝期間不建立資料庫,OUI不會設定ORACLE_SID,並且在之後建立資料庫時必須要設定ORACLE_SID環境變數。

3.選擇資料庫管理員稽核方法
為了建立資料庫,使用者必須被稽核並且被授予相關的系統許可權。稽核方法有以下兩種:
.使用密碼檔案
.使用作業系統稽核

4.建立初始化引數檔案
當Oracle例項啟動時,它將讀取初始化引數檔案。這個引數檔案可以是文字檔案可以使用文字編輯器進行編輯,或者是二進位制檔案,可以由資料庫進行動態修改。二進位制引數檔案也叫伺服器引數檔案。對於這一步操作,可以先建立一個文字引數檔案,之後透過文字引數檔案來建立伺服器引數檔案。

5.建立例項只限於Windows平臺
對於Windows平臺,在連線例項之前,必須手動建立例項。ORADIM命令就是用來建立新例項,其語法如下:oradim -NEW -SID sid -STARTMODE MANUAL -PFILE file.注意在建立新例項時,不要將-STARTMODE引數指定為AUTO,因為這會造成新例項啟動與mount資料庫,而這時資料庫是不存在的。

6.連線例項
啟動SQL*Plus並且使用有sysdba許可權的使用者連線到資料庫例項。
.使用密碼檔案進行稽核,輸入以下命令並輸入sys使用者的密碼
$sqlplus /nolog
SQL>connect sys as sysdba

.使用作業系統稽核,輸入以下命令
$sqlplus /nolog
SQL>conn / as sysdba

7.建立伺服器引數檔案
伺服器引數檔案能透過alter system命令來修改引數,並且這種修改會永久生效。可以透過文字引數檔案來建立伺服器引數檔案。

8.啟動例項
啟動例項但不mount資料庫執行以下命令
startup nomount

9.使用create database語句來建立CDB
當使用create database語句來建立CDB時,必須在操作CDB之前完成額外的操作。這些操作包含對資料字典表建立檢視,安裝標準的PL/SQL包。執行catcdb.sql指令碼。

使用create database語句來建立語句需要注意
9.1 將enable_pluggable_database引數設定為true。在CDB中,db_name引數指定root的名稱。將SID設定為root名稱是常見的做法。這個名稱最多有30個字元。

9.2使用create database語句來建立新的CDB。
9.2.1 不使用OMF來建立CDB

9.2.2 使用OMF來建立CDB

不使用OMF來建立CDB
下面的例子將介紹如何不使用OMF功能來建立CDB
1.設定SID

[root@jytest3 ~]# su - oracle
Last login: Fri Aug  4 15:07:33 CST 2017
[oracle@jytest3 ~]$ cd $ORACLE_HOME/dbs

[oracle@jytest3 dbs]$ export ORACLE_SID=test

2.建立密碼檔案

[oracle@jytest3 dbs]$ orapwd file=$ORACLE_HOME/dbs/orapwtest password=abcdefg format=12.2 entries=20

3.建立初始化引數

[oracle@jytest3 dbs]$ vi inittest.ora
db_name='test'
memory_target=4G
memory_max_target=4G
control_files='+data/test/controlfile/testcdb/control01.ctl','+data/test/controlfile/testcdb/control02.ctl'
enable_pluggable_database=true

4.啟動例項但不mount

[oracle@jytest3 dbs]$ export ORACLE_SID=test
[oracle@jytest3 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 4 20:59:37 2017

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

Connected to an idle instance.

SQL> startup pfile='$ORACLE_HOME/dbs/inittest.ora' nomount
ORACLE instance started.

Total System Global Area 4294967296 bytes
Fixed Size                  8628936 bytes
Variable Size            2315257144 bytes
Database Buffers         1962934272 bytes
Redo Buffers                8146944 bytes

5.執行create database語句來建立CDB
下面的語句將建立一個名為test的CDB資料庫。這個名字與引數檔案中的db_name同名。並且滿足以下條件:
.已經設定control_files引數
.建立了+data/test/datafile/testcdb目錄
.建立了+data/test/datafile/pdbseed目錄
.建立了+data/test/onlinelog/testcdb目錄

為了建立包含root與CDB seed的CDB庫在create database語句中包含了enable pluggable database子句。在這個例子還包含了seed file_name_convert子句來指定CDB seed檔案的檔名與目錄。

SQL> create database test
  2  user sys identified by xxzx_7817600
  3  user system identified by xxzx_7817600
  4  logfile group 1 ('+data/test/onlinelog/testcdb/redo01.log')
  5  size 100m blocksize 512,
  6  group 2 ('+data/test/onlinelog/testcdb/redo02.log')
  7  size 100m blocksize 512,
  8  group 3 ('+data/test/onlinelog/testcdb/redo03.log')
  9  size 100m blocksize 512
 10  maxloghistory 1
 11  maxlogfiles 16
 12  maxlogmembers 3
 13  maxdatafiles 1024
 14  character set al32utf8
 15  national character set al16utf16
 16  extent management local
 17  datafile '+data/test/datafile/testcdb/system01.dbf'
 18  size 700m reuse autoextend on next 10240k maxsize unlimited
 19  sysaux datafile '+data/test/datafile/testcdb/sysaux01.dbf'
 20  size 550m reuse autoextend on next 10240k maxsize unlimited
 21  default tablespace deftbs
 22  datafile '+data/test/datafile/testcdb/deftbs01.dbf'
 23  size 500m reuse autoextend on maxsize unlimited
 24  default temporary tablespace tempts1
 25  tempfile '+data/test/datafile/testcdb/temp01.dbf'
 26  size 20m reuse autoextend on next 640k maxsize unlimited
 27  undo tablespace undotbs1
 28  datafile '+data/test/datafile/testcdb/undotbs01.dbf'
 29  size 200m reuse autoextend on next 5120k maxsize unlimited
 30  enable pluggable database
 31  seed file_name_convert = ('+data/test/datafile/testcdb/','+data/test/datafile/pdbseed/')
 32  local undo on;

Database created.

6.執行指令碼$ORACLE_HOME/rdbms/admin/catcdb.sql

SQL> @$ORACLE_HOME/rdbms/admin/catcdb.sql
SQL>
SQL> Rem The script relies on the caller to have connected to the DB
SQL>
SQL> Rem This script invokes catcdb.pl that does all the work, so we just need to
SQL> Rem construct strings for $ORACLE_HOME/rdbms/admin and
SQL> Rem $ORACLE_HOME/rdbms/admin/catcdb.pl
SQL>
SQL> Rem $ORACLE_HOME
SQL> column oracle_home new_value oracle_home noprint
SQL> select sys_context('userenv', 'oracle_home') as oracle_home from dual;




SQL>
SQL> Rem OS-dependent slash
SQL> column slash new_value slash noprint
SQL> select sys_context('userenv', 'platform_slash') as slash from dual;




SQL>
SQL> Rem $ORACLE_HOME/rdbms/admin
SQL> column rdbms_admin new_value rdbms_admin noprint
SQL> select '&&oracle_home'||'&&slash'||'rdbms'||'&&slash'||'admin' as rdbms_admin from dual;
old   1: select '&&oracle_home'||'&&slash'||'rdbms'||'&&slash'||'admin' as rdbms_admin from dual
new   1: select '/u01/app/oracle/product/12.2.0/db'||'/'||'rdbms'||'/'||'admin' as rdbms_admin from dual




SQL>
SQL> Rem $ORACLE_HOME/rdbms/admin/catcdb.pl
SQL> column rdbms_admin_catcdb new_value rdbms_admin_catcdb noprint
SQL> select '&&rdbms_admin'||'&&slash'||'catcdb.pl' as rdbms_admin_catcdb from dual;
old   1: select '&&rdbms_admin'||'&&slash'||'catcdb.pl' as rdbms_admin_catcdb from dual
new   1: select '/u01/app/oracle/product/12.2.0/db/rdbms/admin'||'/'||'catcdb.pl' as rdbms_admin_catcdb from dual




SQL>
SQL> host perl -I &&rdbms_admin &&rdbms_admin_catcdb --logDirectory &&1 --logFilename &&2
Enter value for 1:
Enter value for 2:
Can't locate Term/ReadKey.pm in @INC (you may need to install the Term::ReadKey module) (@INC contains: /u01/app/oracle/product/12.2.0/db/rdbms/admin /usr/lib/perl5/site_perl/5.22.0/x86_64-linux /usr/lib/perl5/site_perl/5.22.0 /usr/lib/perl5/5.22.0/x86_64-linux /usr/lib/perl5/5.22.0 .) at /u01/app/oracle/product/12.2.0/db/rdbms/admin/catcdb.pl line 30.
BEGIN failed--compilation aborted at /u01/app/oracle/product/12.2.0/db/rdbms/admin/catcdb.pl line 30.

對於這種錯誤參考了楊建榮的解決方法,丟擲的錯誤提示找不到ReadKey.pm,Linux,Unix其實都是自帶Perl的,但這裡需要的檔案在$ORACLE_HOME下的Perl目錄,只需要把這個目錄引用到PATH變數中就可以了,比如:
export PATH=$PATH:$ORACLE_HOME/OPatch:$ORACLE_HOME/perl/bin:$ORACLE_HOME/jdk/bin

[oracle@jytest3 dbs]$ export PATH=$PATH:$ORACLE_HOME/OPatch:$ORACLE_HOME/perl/bin:$ORACLE_HOME/jdk/bin
[oracle@jytest3 dbs]$ export ORACLE_SID=test
[oracle@jytest3 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 4 22:12:56 2017

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> @$ORACLE_HOME/rdbms/admin/catcdb.sql
SQL>
SQL> Rem The script relies on the caller to have connected to the DB
SQL>
SQL> Rem This script invokes catcdb.pl that does all the work, so we just need to
SQL> Rem construct strings for $ORACLE_HOME/rdbms/admin and
SQL> Rem $ORACLE_HOME/rdbms/admin/catcdb.pl
SQL>
SQL> Rem $ORACLE_HOME
SQL> column oracle_home new_value oracle_home noprint
SQL> select sys_context('userenv', 'oracle_home') as oracle_home from dual;




SQL>
SQL> Rem OS-dependent slash
SQL> column slash new_value slash noprint
SQL> select sys_context('userenv', 'platform_slash') as slash from dual;




SQL>
SQL> Rem $ORACLE_HOME/rdbms/admin
SQL> column rdbms_admin new_value rdbms_admin noprint
SQL> select '&&oracle_home'||'&&slash'||'rdbms'||'&&slash'||'admin' as rdbms_admin from dual;
old   1: select '&&oracle_home'||'&&slash'||'rdbms'||'&&slash'||'admin' as rdbms_admin from dual
new   1: select '/u01/app/oracle/product/12.2.0/db'||'/'||'rdbms'||'/'||'admin' as rdbms_admin from dual




SQL>
SQL> Rem $ORACLE_HOME/rdbms/admin/catcdb.pl
SQL> column rdbms_admin_catcdb new_value rdbms_admin_catcdb noprint
SQL> select '&&rdbms_admin'||'&&slash'||'catcdb.pl' as rdbms_admin_catcdb from dual;
old   1: select '&&rdbms_admin'||'&&slash'||'catcdb.pl' as rdbms_admin_catcdb from dual
new   1: select '/u01/app/oracle/product/12.2.0/db/rdbms/admin'||'/'||'catcdb.pl' as rdbms_admin_catcdb from dual




SQL>
SQL> host perl -I &&rdbms_admin &&rdbms_admin_catcdb --logDirectory &&1 --logFilename &&2
Enter value for 1:
Enter value for 2:
Can't locate util.pm in @INC (you may need to install the util module) (@INC contains: /u01/app/oracle/product/12.2.0/db/rdbms/admin /u01/app/oracle/product/12.2.0/db/perl/lib/site_perl/5.22.0/x86_64-linux-thread-multi /u01/app/oracle/product/12.2.0/db/perl/lib/site_perl/5.22.0 /u01/app/oracle/product/12.2.0/db/perl/lib/5.22.0/x86_64-linux-thread-multi /u01/app/oracle/product/12.2.0/db/perl/lib/5.22.0 .) at /u01/app/oracle/product/12.2.0/db/rdbms/admin/catcdb.pl line 35.
BEGIN failed--compilation aborted at /u01/app/oracle/product/12.2.0/db/rdbms/admin/catcdb.pl line 35.

這個問題把util改為Util

[oracle@jytest3 ~]$  find $ORACLE_HOME -name util.pm | wc -l
0

[oracle@jytest3 ~]$ find $ORACLE_HOME -name Util.pm | wc -l
5
[oracle@jytest3 ~]$ find $ORACLE_HOME -name Util.pm
/u01/app/oracle/product/12.2.0/db/perl/lib/5.22.0/x86_64-linux-thread-multi/Hash/Util.pm
/u01/app/oracle/product/12.2.0/db/perl/lib/5.22.0/x86_64-linux-thread-multi/List/Util.pm
/u01/app/oracle/product/12.2.0/db/perl/lib/5.22.0/x86_64-linux-thread-multi/Scalar/Util.pm
/u01/app/oracle/product/12.2.0/db/perl/lib/5.22.0/x86_64-linux-thread-multi/Sub/Util.pm
/u01/app/oracle/product/12.2.0/db/perl/lib/site_perl/5.22.0/HTTP/Headers/Util.pm

這個過程中到底該選哪個目錄下的Util.pm呢,如果多點耐心仔細看看裡面的內容還是能夠找到一些頭緒的,最後選擇的是:

/u01/app/oracle/product/12.2.0/db/perl/lib/5.22.0/x86_64-linux-thread-multi/Hash/Util.pm

需要手工修改catcdb.pl指令碼
那麼問題來了,這個catcdb.pl指令碼是不是要改動呢。修改檔案catcdb.pl,把下面的util修改為Util

use Term::ReadKey; # to not echo password
use Getopt::Long;
use Cwd;
use File::Spec;
use Data::Dumper;
use Utilqw(trim, splitToArray);
use catcon qw(catconSqlplus);

再來一輪測試,結果發現還是會有報錯,這種嘗試會讓你開始懷疑自己的選擇到底是不是正確的方向。如果還是沒有找到,說明在當前的環境變數中沒有匹配到相關的內容,我們需要直接切換到目錄Hash下,然後執行指令碼才可以,這個時候輸出才算有了改觀,提示你輸入密碼。

[oracle@jytest3 Hash]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 4 22:25:23 2017

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> @$ORACLE_HOME/rdbms/admin/catcdb.sql
SQL> Rem
SQL> Rem $Header: rdbms/admin/catcdb.sql /main/7 2016/06/23 11:38:38 akruglik Exp $
SQL> Rem
SQL> Rem catcdb.sql
SQL> Rem
SQL> Rem Copyright (c) 2013, 2016, Oracle and/or its affiliates.
SQL> Rem All rights reserved.
SQL> Rem
SQL> Rem    NAME
SQL> Rem         catcdb.sql - 
SQL> Rem
SQL> Rem    DESCRIPTION
SQL> Rem         invoke catcdb.pl
SQL> Rem
SQL> Rem    NOTES
SQL> Rem         
SQL> Rem
SQL> Rem    PARAMETERS:
SQL> Rem         - log directory
SQL> Rem         - base for log file name
SQL> Rem
SQL> Rem    MODIFIED   (MM/DD/YY)
SQL> Rem    akruglik    06/21/16 - Bug 22752041: pass --logDirectory and
SQL> Rem                           --logFilename to catcdb.pl
SQL> Rem    akruglik    11/10/15 - use catcdb.pl to collect passowrds and pass them
SQL> Rem                           on to catcdb_int.sql using env vars
SQL> Rem    aketkar     04/30/14 - remove SQL file metadata
SQL> Rem    cxie        08/16/13 - remove SQL_PHASE
SQL> Rem    cxie        07/10/13 - 17033183: add shipped_file metadata
SQL> Rem    cxie        03/19/13 - create CDB with all options installed
SQL> Rem    cxie        03/19/13 - Created
SQL> Rem
SQL>
SQL> set echo on
SQL>
SQL> Rem The script relies on the caller to have connected to the DB
SQL>
SQL> Rem This script invokes catcdb.pl that does all the work, so we just need to
SQL> Rem construct strings for $ORACLE_HOME/rdbms/admin and
SQL> Rem $ORACLE_HOME/rdbms/admin/catcdb.pl
SQL>
SQL> Rem $ORACLE_HOME
SQL> column oracle_home new_value oracle_home noprint
SQL> select sys_context('userenv', 'oracle_home') as oracle_home from dual;




SQL>
SQL> Rem OS-dependent slash
SQL> column slash new_value slash noprint
SQL> select sys_context('userenv', 'platform_slash') as slash from dual;




SQL>
SQL> Rem $ORACLE_HOME/rdbms/admin
SQL> column rdbms_admin new_value rdbms_admin noprint
SQL> select '&&oracle_home'||'&&slash'||'rdbms'||'&&slash'||'admin' as rdbms_admin from dual;
old   1: select '&&oracle_home'||'&&slash'||'rdbms'||'&&slash'||'admin' as rdbms_admin from dual
new   1: select '/u01/app/oracle/product/12.2.0/db'||'/'||'rdbms'||'/'||'admin' as rdbms_admin from dual




SQL>
SQL> Rem $ORACLE_HOME/rdbms/admin/catcdb.pl
SQL> column rdbms_admin_catcdb new_value rdbms_admin_catcdb noprint
SQL> select '&&rdbms_admin'||'&&slash'||'catcdb.pl' as rdbms_admin_catcdb from dual;
old   1: select '&&rdbms_admin'||'&&slash'||'catcdb.pl' as rdbms_admin_catcdb from dual
new   1: select '/u01/app/oracle/product/12.2.0/db/rdbms/admin'||'/'||'catcdb.pl' as rdbms_admin_catcdb from dual




SQL>
SQL> host perl -I &&rdbms_admin &&rdbms_admin_catcdb --logDirectory &&1 --logFilename &&2
Enter new password for SYS: xxzx_7817600
Enter new password for SYSTEM: xxzx_7817600
Enter temporary tablespace name: tempts1
No options to container mapping specified, no options will be installed in any containers
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/catalog_catcon_27898.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catalog*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catalog_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/catproc_catcon_3352.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catproc*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catproc_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/catoctk_catcon_9051.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catoctk*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catoctk_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/owminst_catcon_9233.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/owminst*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/owminst_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_catcon_11572.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_catcon_11761.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_*.lst] files for spool files, if any
validate_script_path: sqlplus script /u01/app/oracle/product/12.2.0/db/sqlplus/admin/help/hlpbld does not exist or is unreadable
catconExec: empty Path returned by validate_script_path for
    SrcDir = /u01/app/oracle/product/12.2.0/db/sqlplus/admin/help, FileName = hlpbld
catcon.pl: Unexpected error encountered in catconExec; exiting
exec_DB_script: /u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_catcon_11761_exec_DB_script.done did not need to be deleted before running a script
exec_DB_script: opened Reader and Writer
exec_DB_script: connected
exec_DB_script: executed set echo on

exec_DB_script: executed @@/u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_catcon_kill_sess_11761_ALL.sql

exec_DB_script: sent
host sqlplus -v > /u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_catcon_11761_exec_DB_script.done to Writer
exec_DB_script: sent -exit- to Writer
exec_DB_script: closed Writer
exec_DB_script: marker was undefined; read and ignore output, if any
exec_DB_script: finished reading and ignoring output
exec_DB_script: waiting for child process to exit
exec_DB_script: child process exited
sureunlink: unlink(/u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_catcon_11761_exec_DB_script.done) succeeded after 1 attempt(s)
sureunlink: verify that the file really no longer exists
sureunlink: confirmed that /u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_catcon_11761_exec_DB_script.done no longer exists after 1 attempts
exec_DB_script: deleted /u01/app/oracle/product/12.2.0/db/rdbms/log/pupbld_catcon_11761_exec_DB_script.done after running a script
exec_DB_script: closed Reader
exec_DB_script: waitpid returned
kill_sqlplus_sessions: output produced in exec_DB_script [

    SQL*Plus: Release 12.2.0.1.0 Production on Sat Aug 5 00:30:52 2017

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

    SQL> Connected.
    SQL> SQL> SQL>
    SQL> ALTER SYSTEM KILL SESSION '78,1729' force timeout 0 -- process 11802
      2  /

    System altered.

    SQL>
    SQL> SQL>
    SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
  ] end of output produced in exec_DB_script
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/catclust_catcon_11824.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catclust*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catclust_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/catfinal_catcon_12430.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catfinal*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catfinal_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/catbundleapply_catcon_12604.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catbundleapply*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/catbundleapply_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/db/rdbms/log/utlrp_catcon_12789.lst]
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/utlrp*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/db/rdbms/log/utlrp_*.lst] files for spool files, if any
catcon.pl: completed successfully

使用OMF來建立CDB
下面的例子將介紹如何使用OMF功能來建立CDB
1.設定SID

[root@jytest3 ~]# su - oracle
Last login: Fri Aug  4 15:07:33 CST 2017
[oracle@jytest3 ~]$ cd $ORACLE_HOME/dbs

[oracle@jytest3 dbs]$ export ORACLE_SID=cs

2.建立密碼檔案

[oracle@jytest3 dbs]$ orapwd file=$ORACLE_HOME/dbs/orapwcs password=xxzx_7817600 format=12.2 entries=20

3.建立初始化引數

[oracle@jytest3 dbs]$ vi inittest.ora
db_name='cs'
memory_target=4G
memory_max_target=4G
control_files='+data/cs/controlfile/control01.ctl','+data/cs/controlfile/control02.ctl'
enable_pluggable_database=true
db_create_file_dest=+data

4.啟動例項但不mount

[oracle@jytest3 dbs]$ export ORACLE_SID=cs
[oracle@jytest3 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 4 20:59:37 2017

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

Connected to an idle instance.

SQL> startup pfile='$ORACLE_HOME/dbs/initcs.ora' nomount
ORACLE instance started.

Total System Global Area 4294967296 bytes
Fixed Size                  8628936 bytes
Variable Size            2315257144 bytes
Database Buffers         1962934272 bytes
Redo Buffers                8146944 bytes

5.執行create database語句來建立CDB
下面的語句將建立一個名為cs的CDB資料庫。這個名字與引數檔案中的db_name同名。為了建立包含root與CDB seed的CDB庫在create database語句中包含了enable pluggable database子句。在這個例子還包含了
seed tablespace datafiles子句來指定CDB seed檔案的檔名與目錄。

SQL> create database cs
  2  user sys identified by xxzx_7817600
  3  user system identified by xxzx_7817600
  4  extent management local
  5  default tablespace users
  6  default temporary tablespace temp
  7  undo tablespace undotbs1
  8  enable pluggable database
  9  seed
 10  system datafiles size 125m autoextend on next 10m maxsize unlimited
 11  sysaux datafiles size 100m;

Database created.

6.執行指令碼$ORACLE_HOME/rdbms/admin/catcdb.sql

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2143272/,如需轉載,請註明出處,否則將追究法律責任。

相關文章