oracle手动创建新的数据库

8月 8, 2017 |

一、创建初始化文件(加上db_name=octavia)
本文由javacoder.cn整理,转载注明出处,基于oracle-xe 11.2 版本

cd /u01/app/oracle/product/11.2.0/xe/dbs/
vi initOCTAVIA.ora
db_name='OCTAVIA'
processes = 50
db_block_size=8192
db_domain=''
dispatchers='(PROTOCOL=TCP) (SERVICE=OCTAVIA)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='OCTAVIA_UNDOTBS1'
control_files = (/u01/dbfile/octavia/control.dbf)
compatible ='11.2.0'

二、创建对应的目录及赋予权限

mkdir -p /u01/dbfile/octavia
mkdir -p /u01/oraredo/octavia
chown -R oracle:dba /u01

三、设置环境变量

vi /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
将export ORACLE_SID=OCTAVIA
source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

四、建库操作
将如下sql保存为/u01/app/oracle/db.sql

CREATE DATABASE OCTAVIA
CHARACTER SET AL32UTF8
DATAFILE
'/u01/dbfile/octavia/system01.dbf'
SIZE 500M REUSE
EXTENT MANAGEMENT LOCAL
UNDO TABLESPACE OCTAVIA_UNDOTBS1 DATAFILE
'/u01/dbfile/octavia/undotbs01.dbf'
SIZE 200M
SYSAUX DATAFILE
'/u01/dbfile/octavia/sysaux01.dbf'
SIZE 200M
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE
'/u01/dbfile/octavia/temp01.dbf'
SIZE 500M
DEFAULT TABLESPACE USERS DATAFILE
'/u01/dbfile/octavia/users01.dbf'
SIZE 20M
LOGFILE GROUP 1
('/u01/oraredo/octavia/redo01a.rdo') SIZE 50M,
GROUP 2
('/u01/oraredo/octavia/redo02a.rdo') SIZE 50M,
GROUP 3
('/u01/oraredo/octavia/redo03a.rdo') SIZE 50M
USER sys IDENTIFIED BY 123456
USER system IDENTIFIED BY 123456;

sqlplus / as sysdba
SQL>create spfile from pfile;
SQL>startup nomount
SQL>@/u01/app/oracle/db.sql
SQL>shutdown normal

我测试用的是xe版本,老是会剩下一个进程没杀掉,kill -9

SQL>startup
SQL>@/u01/app/oracle/product/11.2.0/xe/rdbms/admin/catalog.sql
SQL>@/u01/app/oracle/product/11.2.0/xe/rdbms/admin/catproc.sql

后面两个sql创建必要的数据字典和包,存储过程

Posted in: Oracle

Comments are closed.