Oracle 12CR2 using create database command for create non-CDB rac database on Oracle Linux

在Oracle Linux7,数据库版本为12.2中使用create database来创建non-CDB数据库
1.设置实例标识符(SID)

[root@jytest1 ~]# su - oracle
Last login: Fri Apr 21 11:24:50 CST 2017
[oracle@jytest1 ~]$ export ORACLE_SID=orcl1

2.创建相关目录

ASMCMD [+data] > mkdir orcl
ASMCMD [+data] > ls
jy/
orcl/
ASMCMD [+data] > mkdir +data/orcl/CONTROLFILE
ASMCMD [+data] > mkdir +data/orcl/DATAFILE
ASMCMD [+data] > mkdir +data/orcl/ONLINELOG
ASMCMD [+data] > mkdir +data/orcl/TEMPFILE
ASMCMD [+data] > mkdir +data/orcl/PASSWORD
ASMCMD [+data] > mkdir +data/orcl/PARAMETERFILE

3.创建密码文件

[oracle@jytest1 dbs]$ orapwd file='/u01/app/oracle/product/12.2.0/db/dbs/orapworcl1'  force=y password=xxzx#7817600

4.创建参数文件,参数文件至少要包含db_name,control_files与memory_target参数

[oracle@jytest1 dbs]$ vi initorcl1.ora
db_name=orcl
control_files='+data/orcl/controlfile/control01.ctl','+data/orcl/controlfile/control02.c tl'
memory_target=1G

5.连接实例

[oracle@jytest1 dbs]$ sqlplus sys/xxzx#7817600 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Apr 19 19:15:50 2017

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

Connected to an idle instance.

6.启动实例

SQL> startup nomount pfile='/u01/app/oracle/product/12.2.0/db/dbs/initorcl1.ora'
ORACLE instance started.

Total System Global Area 1073741824 bytes
Fixed Size                  8628936 bytes
Variable Size             750781752 bytes
Database Buffers          306184192 bytes
Redo Buffers                8146944 bytes

7.创建服务器参数文件spfile

SQL>create spfile='+DATA/orcl/PARAMETERFILE/spfileorcl.ora' from pfile='/u01/app/oracle/product/12.2.0/db/dbs/initorcl1.ora';

8.执行create database语句

SQL> CREATE DATABASE orcl
  2  USER SYS IDENTIFIED BY xxzx#7817600
  3  USER SYSTEM IDENTIFIED BY xxzx#7817600
  4  LOGFILE GROUP 1 ('+data/orcl/onlinelog/redo01.log') SIZE 100M BLOCKSIZE 512,
  5  GROUP 2 ('+data/orcl/onlinelog/redo02.log') SIZE 100M BLOCKSIZE 512,
  6  GROUP 3 ('+data/orcl/onlinelog/redo03.log') SIZE 100M BLOCKSIZE 512
  7  MAXLOGHISTORY 1
  8  MAXLOGFILES 16
  9  MAXLOGMEMBERS 3
 10  MAXDATAFILES 1024
 11  CHARACTER SET ZHS16GBK
 12  NATIONAL CHARACTER SET AL16UTF16
 13  EXTENT MANAGEMENT LOCAL
 14  DATAFILE '+data/orcl/datafile/system01.dbf'
 15  SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
 16  SYSAUX DATAFILE '+data/orcl/datafile/sysaux01.dbf'
 17  SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
 18  DEFAULT TABLESPACE users
 19  DATAFILE '+data/orcl/datafile/users01.dbf'
 20  SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
 21  DEFAULT TEMPORARY TABLESPACE tempts1
 22  TEMPFILE '+data/orcl/tempfile/temp01.dbf'
 23  SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
 24  UNDO TABLESPACE undotbs1
 25  DATAFILE '+data/orcl/datafile/undotbs01.dbf'
 26  SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
 27  USER_DATA TABLESPACE usertbs
 28  DATAFILE '+data/orcl/datafile/usertbs01.dbf'
 29  SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

Database created.

9.运行脚本来创建数据字典视图
用sys用户执行以下脚本

SQL> @$ORACLE_HOME/rdbms/admin/catalog.sql

Session altered.

SQL>@$ORACLE_HOME/rdbms/admin/catproc.sql

SQL> Rem END catproc.sql

SQL>@$ORACLE_HOME/rdbms/admin/utlrp.sql

SQL> Rem END utlrp.sql

使用system用户执行以下脚本

SQL>@$ORACLE_HOME/sqlplus/admin/pupbld.sql

SQL> alter session set "_ORACLE_SCRIPT" = false;

Session altered.

10.将数据库注册为RAC数据库,在节点2配置实例orcl2的参数文件

[oracle@jytest2 dbs]$ vi initorcl2.ora
SPFILE='+DATA/orcl/PARAMETERFILE/spfileorcl.ora'

设置RAC数据库所需要的相关参数

SQL> alter system set thread=1 scope=spfile sid='orcl1';

System altered.

SQL> alter system set thread=2 scope=spfile sid='orcl2';

System altered.

SQL> alter system set instance_number=1 scope=spfile sid='orcl1';

System altered.

SQL> alter system set instance_number=2 scope=spfile sid='orcl2';

System altered.

SQL> alter system set cluster_database=true scope=sfpile sid='*';

System altered.

SQL> alter system set cluster_database_instances=2 scope=sfpile sid='*';

System altered.

添加重做线程

SQL> alter database add logfile thread 2 group 4('+data/orcl/onlinelog/redo04.log') SIZE 100M BLOCKSIZE 512;

Database altered.

SQL> alter database add logfile thread 2 group 5('+data/orcl/onlinelog/redo05.log') SIZE 100M BLOCKSIZE 512;

Database altered.

SQL> alter database add logfile thread 2 group 6('+data/orcl/onlinelog/redo06.log') SIZE 100M BLOCKSIZE 512;

Database altered.

SQL> alter database enable thread 2;

Database altered.

向crs注册数据库

[oracle@jytest1 dbs]$ srvctl add database -db orcl -oraclehome  /u01/app/oracle/product/12.2.0/db/  -dbtype RAC -spfile  +DATA/orcl/PARAMETERFILE/spfileorcl.ora -diskgroup 'data'


[oracle@jytest1 dbs]$ srvctl add instance -db orcl -instance orcl1 -node jytest1
[oracle@jytest1 dbs]$ srvctl add instance -db orcl -instance orcl2 -node jytest2
[oracle@jytest1 dbs]$ srvctl config database -db orcl
Database unique name: orcl
Database name:
Oracle home: /u01/app/oracle/product/12.2.0/db/
Oracle user: oracle
Spfile: +DATA/orcl/PARAMETERFILE/spfileorcl.ora
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: orcl1,orcl2
Configured nodes: jytest1,jytest2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

11.将密码文件存储在ASM磁盘组中

[oracle@jytest1 dbs]$ orapwd file='+data/orcl/password/pwdorcl' dbuniquename='orcl'

Enter password for SYS:

ASMCMD [+data/orcl/password] > ls -lt
Type      Redund  Striped  Time             Sys  Name
PASSWORD  UNPROT  COARSE   APR 21 11:00:00  Y    pwdorcl.294.941886275
PASSWORD  UNPROT  COARSE   APR 21 11:00:00  N    pwdorcl =>  +DATA/orcl/PASSWORD/pwdorcl.294.941886275

Enter password for SYS:
[oracle@jytest1 dbs]$ srvctl config database -db orcl
Database unique name: orcl
Database name:
Oracle home: /u01/app/oracle/product/12.2.0/db/
Oracle user: oracle
Spfile: +DATA/orcl/PARAMETERFILE/spfileorcl.ora
Password file: +DATA/orcl/password/pwdorcl
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: orcl1,orcl2
Configured nodes: jytest1,jytest2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

12.检查crs状态信息

[grid@jytest2 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.CRS.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.DATA.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.TEST.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.chad
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.net1.network
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.ons
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.proxy_advm
               OFFLINE OFFLINE      jytest1                  STABLE
               OFFLINE OFFLINE      jytest2                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       jytest1                  169.254.123.145 88.8
                                                             8.88.1,STABLE
ora.asm
      1        ONLINE  ONLINE       jytest1                  Started,STABLE
      2        ONLINE  ONLINE       jytest2                  Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.jy.db
      1        ONLINE  ONLINE       jytest1                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
      2        ONLINE  ONLINE       jytest2                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
ora.jytest1.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.jytest2.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       jytest1                  Open,STABLE
ora.orcl.db
      1        ONLINE  ONLINE       jytest1                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db/,STABLE
      2        ONLINE  ONLINE       jytest2                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db/,STABLE
ora.qosmserver
      1        ONLINE  INTERMEDIATE jytest1                  CHECK TIMED OUT,STAB
                                                             LE
ora.scan1.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
--------------------------------------------------------------------------------

到此操作完成!

发表评论

电子邮件地址不会被公开。