文章目录
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
db_name=default --修改为想要的名字
---在新的pfile中增加下面两行
undo_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.
注意createdb.sql中undo tablespace名字需要与参数文件中的undo_tablespace指定的值一样,否则会出现如下错误
@/home/oracle/createdb.sql
CREATE DATABASE ORCL
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-01501: CREATE DATABASE failed
ORA-01519: error while processing file '?/rdbms/admin/sql.bsq' near line 5799
ORA-00604: error occurred at recursive SQL level 1
ORA-30012: undo tablespace 'UNDOTBS1' does not exist or of wrong type
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