Oracle 12c 手工建立CDB資料庫
阿新 • • 發佈:2019-01-23
下面我們來看一下,Oracle 12c 如何的來手工建立cdb的資料庫
與10G,11G一樣,建立資料庫的基本的流程是一樣的
1. 手工建立密碼檔案
2. 建立伺服器引數檔案spfile
3. startup nomount
4. 使用create database的語句才建立我們的資料庫
5. 執行後續的指令碼
下面我們來一步一的分析下每一步的操作
先看看密碼檔案建立,還是與10g,11g相同
orapwd file=orapwenmo password=oracle entries=10
下面我們來建立spfile檔案,在12c資料庫中,也是提供了一個init.ora的檔案的,但是這個init.ora的檔案還是11g的,所以我們需要對這個初始化引數進行一下修改。
cat init.ora |grep -v ^# |grep -v ^$ >>initenmo.ora
原來的引數
db_name='ORCL' memory_target=1G processes = 150 audit_file_dest='<ORACLE_BASE>/admin/orcl/adump' audit_trail ='db' db_block_size=8192 db_domain='' db_recovery_file_dest='<ORACLE_BASE>/fast_recovery_area' db_recovery_file_dest_size=2G diagnostic_dest='<ORACLE_BASE>' dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)' open_cursors=300 remote_login_passwordfile='EXCLUSIVE' undo_tablespace='UNDOTBS1' control_files = (ora_control1, ora_control2) compatible ='11.2.0'
修改以後的引數
*.audit_file_dest='$ORACLE_BASE/admin/enmo/adump' *.audit_trail='db' *.control_files='/u01/app/oracle/oradata/enmo/control01.ctl','/u01/app/oracle/oradata/enmo/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='enmo' *.db_recovery_file_dest='$ORACLE_BASE/fast_recovery_area' *.db_recovery_file_dest_size=2G *.diagnostic_dest='$ORACLE_BASE' *.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)' *.enable_pluggable_database=TRUE *.memory_target=1G *.open_cursors=300 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.undo_tablespace='UNDOTBS1'
我們這兒需要刪除掉compatible 引數以及 把enable_pluggable_database設定為true,這樣我們才能夠建立cdb
下一步,我們需要手動編寫建立cdb的指令碼,
CREATE DATABASE newcdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log')
SIZE 100M BLOCKSIZE 512
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/newcdb/system01.dbf'
SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SYSAUX DATAFILE '/u01/app/oracle/oradata/newcdb/sysaux01.dbf'
SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
DEFAULT TABLESPACE deftbs
DATAFILE '/u01/app/oracle/oradata/newcdb/deftbs01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/newcdb/temp01.dbf'
SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/newcdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
ENABLE PLUGGABLE DATABASE
SEED
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/newcdb/',
'/u01/app/oracle/oradata/pdbseed/')
SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
SYSAUX DATAFILES SIZE 100M
USER_DATA TABLESPACE usertbs
DATAFILE '/u01/app/oracle/oradata/pdbseed/usertbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
我們修改成
CREATE DATABASE enmo
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/enmo/redo01a.log','/u01/app/oracle/oradata/enmo/redo01b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/enmo/redo02a.log','/u01/app/oracle/oradata/enmo/redo02b.log')
SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/enmo/redo03a.log','/u01/app/oracle/oradata/enmo/redo03b.log')
SIZE 100M BLOCKSIZE 512
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/enmo/system01.dbf'
SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SYSAUX DATAFILE '/u01/app/oracle/oradata/enmo/sysaux01.dbf'
SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
DEFAULT TABLESPACE deftbs
DATAFILE '/u01/app/oracle/oradata/enmo/deftbs01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/enmo/temp01.dbf'
SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/enmo/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
ENABLE PLUGGABLE DATABASE
SEED
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/enmo/',
'/u01/app/oracle/oradata/pdbseed/')
SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
SYSAUX DATAFILES SIZE 100M
USER_DATA TABLESPACE usertbs
DATAFILE '/u01/app/oracle/oradata/pdbseed/usertbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
最後我們執行指令碼
@?/rdbms/admin/catcdb.sql
在這行這個指令碼的時候,我們可能會遇到錯誤
Can't locate Term/ReadKey.pm in @INC (@INC contains: /u01/app/oracle/product/11.2.0/db/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 . /u01/app/oracle/product/11.2.0/db/rdbms/admin/) at /u01/app/oracle/product/11.2.0/db/rdbms/admin/catcon.pm line 189.
BEGIN failed--compilation aborted at /u01/app/oracle/product/11.2.0/db/rdbms/admin/catcon.pm line 189.
Compilation failed in require at /u01/app/oracle/product/11.2.0/db/rdbms/admin/catcon.pl line 94.
BEGIN failed--compilation aborted at /u01/app/oracle/product/11.2.0/db/rdbms/admin/catcon.pl line 94.
這個是perl的包沒有安裝,我們直接通過yum源安裝perl組建,就可以順利的完成安裝的工作了。