手动创建oracle database

文章目录

  • 1.准备sql脚本:createdb.sql
  • 2.切换至目标sid
  • 3.准备pfile文件
  • 4.启动实例至nomount
  • 5.执行创建Database
  • 6.安装dictionary
  • 7.安装系统包
  • 8.安装product_user_table表

1.准备sql脚本:createdb.sql

CREATE DATABASE ORCL
USER SYS IDENTIFIED BY "CJ5X1KaFLdmlhh29hRcWUw=="
USER SYSTEM IDENTIFIED BY "CJ5X1KaFLdmlhh29hRcWUw=="
LOGFILE GROUP 1 ('/u1/oradata/ORCL/redo01a.log') SIZE 50M,
GROUP 2 ('/u1/oradata/ORCL/redo02a.log') SIZE 50M,
GROUP 3 ('/u1/oradata/ORCL/redo03a.log') SIZE 50M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u1/oradata/ORCL/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u1/oradata/ORCL/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u1/oradata/ORCL/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE temp
TEMPFILE '/u1/oradata/ORCL/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/u1/oradata/ORCL/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

2.切换至目标sid

export ORACLE_SID=ORCL
echo $ORACLE_SID
ORCL

3.准备pfile文件

cp $ORACLE_HOME/dbs/init.ora $ORACLE_HOME/dbs/initORCL.ora 
---在新的pfile中增加下面两行
auto_management=AUTO  
undo_tablespace=undotbs  

4.启动实例至nomount

SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup nomount pfile=$ORACLE_HOME/dbs/initORCL.ora
ORA-00371: not enough shared pool memory, should be atleast 123232153 bytes

可能会遭入ORA-00371的错误
据说是oracle的一个bug:

Bug 13606499 - PHSB: DEFAULT MEMORY PARAMETER(INIT.ORA) IS NOT BIG ENOUGH TO START A INSTANCE

这个bug在12.1版本中得到修复
因此,需要在pfile中的share_pool_size改成上面ORA-00371中提示期望的size

shared_pool_size = 123232153

再次启动实例至nomount状态

SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup nomount pfile=$ORACLE_HOME/dbs/initORCL.ora
ORACLE instance started.
Total System Global Area  171966464 bytes
Fixed Size                  2094736 bytes
Variable Size             150997360 bytes
Database Buffers           16777216 bytes
Redo Buffers                2097152 bytes

5.执行创建Database

SQL> @/home/oracle/createdb.sql
Database created.

6.安装dictionary

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

7.安装系统包

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

8.安装product_user_table表

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

你可能感兴趣的:(数据库,oracle,sql)