oracle12c手动创建cdb实例

oracle12c通过手动创建cdb实例。

环境

操作系统: centos 7.3 64bit
oracle版本:Release 12.2.0.1.0 Production

安装步骤

指定sid

修改~/.bash_profile文件,修改ORACLE_SID名称

1
export ORACLE_SID=dpf

创建初始化文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
oracle@db001:/home/oracle$ cat initdbdpf.ora 
db_name='dpf'
memory_target=2G
processes=150
db_block_size=8192
db_domain=''
diagnostic_dest='/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=dpf)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='undotbs1'
control_files='/oracle/oradata/dpf/control01.ctl', '/oracle/oradata/dpf/control02.ctl'
compatible='12.0.0'
audit_file_dest='/oracle/admin/dpf/adump'
audit_trail='db'
enable_pluggable_database=true

保存到/home/oracle/initdbdpf.ora。

创建目录

创建需要的文件目录

1
mkdir -p /oracle/admin/dpf/adump

连接到oracle

通过sysdba连接到oracle

1
2
3
4
5
6
7
oracle@db001:/home/oracle$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Fri Mar 23 16:20:00 2018

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

SQL> conn / as sysdba

创建spfile文件

从initdborcl.ora创建spfile

1
SQL> create spfile from pfile='/home/oracle/initdbdpf.ora'

启动实例

使用nomount启动

1
2
3
4
5
6
7
8
SQL>startup nomount;
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size 2926472 bytes
Variable Size 1291847800 bytes
Database Buffers 838860800 bytes
Redo Buffers 13848576 bytes

创建数据库实例

准备语句

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
SQL>create database dpf
user sys identified by oracle123
user system identified by oracle123
logfile group 1 ('/oracle/oradata/dpf/redo01a.log','/oracle/oradata/dpf/redo01b.log') size 100m,
group 2 ('/oracle/oradata/dpf/redo02a.log','/oracle/oradata/dpf/redo02b.log') size 100m,
group 3 ('/oracle/oradata/dpf/redo03a.log','/oracle/oradata/dpf/redo03b.log') size 100m
maxloghistory 1
maxlogfiles 16
maxlogmembers 3
maxdatafiles 1024
character set al32utf8
national character set al16utf16
extent management local
datafile '/oracle/oradata/dpf/system01.dbf' size 700m reuse autoextend on next 10240k maxsize unlimited
sysaux datafile '/oracle/oradata/dpf/sysaux01.dbf' size 550m reuse autoextend on next 10240k maxsize unlimited
default tablespace users
datafile '/oracle/oradata/dpf/users01.dbf' size 500m reuse autoextend on maxsize unlimited
default temporary tablespace tempts1
tempfile '/oracle/oradata/dpf/temp01.dbf' size 20m reuse autoextend on next 640k maxsize unlimited
undo tablespace undotbs1
datafile '/oracle/oradata/dpf/undotbs01.dbf' size 200m reuse autoextend on next 5120k maxsize unlimited
enable pluggable database
seed
file_name_convert = ('/oracle/oradata/dpf',
'/oracle/oradata/dpf/pdb1')
system datafiles size 125m autoextend on next 10m maxsize unlimited
sysaux datafiles size 100m
user_data tablespace usertbs
datafile '/oracle/oradata/dpf/pdb1/usertbs01.dbf' size 200m reuse autoextend on maxsize unlimited;

执行完后,通过运行sql脚本创建数据字典视图

1
@?/rdbms/admin/catcdb.sql

执行命令会提示输入1、2参数
Enter value for 1: /oracle/product/12.2.0.1/rdbms/admin
Enter value for 2: /oracle/product/12.2.0.1/rdbms/admin/catcdb.pl

此处会报错,报错内容如下

1
2
3
Can't locate Term/ReadKey.pm in @INC (@INC contains: /U01/app/oracle/product/12.2/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 /U01/app/oracle/product/12.2/rdbms/admin/catcdb.pl line 30.

BEGIN failed--compilation aborted at /U01/app/oracle/product/12.2/rdbms/admin/catcdb.pl line 30.

解决办法;
1、设定环境变量PATH值,增加ORACLE下perl环境变量

1
export PATH=$ORACLE_HOME/perl/bin:$ORACLE_HOME/jdk/bin:$PATH

2、修改/oracle/product/12.2.0.1/rdbms/admin/catcdb.pl文件
修改35行,把util修改成Util。

3、先退出sqlplus环境, 进入$ORACLE_HOME/perl/lib/5.22.0/x86_64-linux-thread-multi/Hash目录
然后在执行该sql即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
1、修改catcdb.pl文件35行把unil修改成Util
2、进入hash目录后,进入sqlplus环境
oracle@txbds-dpf-db001:/oracle/product/12.2.0.1/perl/lib/5.22.0/x86_64-linux-thread-multi$ cd /oracle/product/12.2.0.1/perl/lib/5.22.0/x86_64-linux-thread-multi/Hash/
oracle@txbds-dpf-db001:/oracle/product/12.2.0.1/perl/lib/5.22.0/x86_64-linux-thread-multi/Hash$ ll
total 28
drwxr-xr-x 2 oracle oinstall 4096 Apr 20 2017 Util
-rwxr-x--- 1 oracle oinstall 23392 May 12 2016 Util.pm
oracle@txbds-dpf-db001:/oracle/product/12.2.0.1/perl/lib/5.22.0/x86_64-linux-thread-multi/Hash$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Fri Mar 23 14:03:51 2018

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

SQL> conn / as sysdba
Connected.
SQL> @?/rdbms/admin/catcdb.sql

SQL> host perl -I &&rdbms_admin &&rdbms_admin_catcdb --logDirectory &&1 --logFilename &&2
Enter value for 1: /oracle/product/12.2.0.1/rdbms/admin
Enter value for 2: /oracle/product/12.2.0.1/rdbms/admin/catcdb.pl
Enter new password for SYS: oracle123
Enter new password for SYSTEM: oracle123
Enter temporary tablespace name: dpf-temp
No options to container mapping specified, no options will be installed in any containers
catcon: ALL catcon-related output will be written to [/oracle/product/12.2.0.1/rdbms/admin/catalog_catcon_14267.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catalog*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catalog_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/oracle/product/12.2.0.1/rdbms/admin/catproc_catcon_14355.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catproc*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catproc_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/oracle/product/12.2.0.1/rdbms/admin/catoctk_catcon_15507.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catoctk*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catoctk_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/oracle/product/12.2.0.1/rdbms/admin/owminst_catcon_15593.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/owminst*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/owminst_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/oracle/product/12.2.0.1/rdbms/admin/pupbld_catcon_16013.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/pupbld*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/pupbld_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/oracle/product/12.2.0.1/rdbms/admin/pupbld_catcon_16097.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/pupbld*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/pupbld_*.lst] files for spool files, if any
validate_script_path: sqlplus script /oracle/product/12.2.0.1/sqlplus/admin/help/hlpbld does not exist or is unreadable
catconExec: empty Path returned by validate_script_path for
SrcDir = /oracle/product/12.2.0.1/sqlplus/admin/help, FileName = hlpbld
catcon.pl: Unexpected error encountered in catconExec; exiting
exec_DB_script: /oracle/product/12.2.0.1/rdbms/admin/pupbld_catcon_16097_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 @@/oracle/product/12.2.0.1/rdbms/admin/pupbld_catcon_kill_sess_16097_ALL.sql

exec_DB_script: sent
host sqlplus -v > /oracle/product/12.2.0.1/rdbms/admin/pupbld_catcon_16097_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(/oracle/product/12.2.0.1/rdbms/admin/pupbld_catcon_16097_exec_DB_script.done) succeeded after 1 attempt(s)
sureunlink: verify that the file really no longer exists
sureunlink: confirmed that /oracle/product/12.2.0.1/rdbms/admin/pupbld_catcon_16097_exec_DB_script.done no longer exists after 1 attempts
exec_DB_script: deleted /oracle/product/12.2.0.1/rdbms/admin/pupbld_catcon_16097_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 Fri Mar 23 14:27:09 2018

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

SQL> Connected.
SQL> SQL> SQL>
SQL> ALTER SYSTEM KILL SESSION '99,16498' force timeout 0 -- process 16133
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 [/oracle/product/12.2.0.1/rdbms/admin/catclust_catcon_16148.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catclust*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catclust_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/oracle/product/12.2.0.1/rdbms/admin/catfinal_catcon_16566.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catfinal*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catfinal_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/oracle/product/12.2.0.1/rdbms/admin/catbundleapply_catcon_16650.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catbundleapply*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/catbundleapply_*.lst] files for spool files, if any
catcon.pl: completed successfully
catcon: ALL catcon-related output will be written to [/oracle/product/12.2.0.1/rdbms/admin/utlrp_catcon_16734.lst]
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/utlrp*.log] files for output generated by scripts
catcon: See [/oracle/product/12.2.0.1/rdbms/admin/utlrp_*.lst] files for spool files, if any
catcon.pl: completed successfully

这样,数据库实例就创建好了。

文章目录
  1. 1. 环境
  2. 2. 安装步骤
    1. 2.1. 指定sid
    2. 2.2. 创建初始化文件
    3. 2.3. 创建目录
    4. 2.4. 连接到oracle
    5. 2.5. 创建spfile文件
    6. 2.6. 启动实例
    7. 2.7. 创建数据库实例