首页 > 代码库 > 手工建库

手工建库


联机文档地址:

http://docs.oracle.com/cd/E11882_01/server.112/e25494/create.htm#ADMIN002

 

 

环境描述:

$ env | grep ORACLE

ORACLE_OWNER=oracle

ORACLE_SID=example

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=/u01/app/oracle/product/11.2.0

 

1.创建初始化参数文件

A.PFILE parameter description.

$ cd $ORACLE_HOME/dbs

$ cat example.txt

 

# First,specify the name of database db_name=‘example‘

instance_type=‘RDBMS‘

# Set db_name and organization name.

db_name=‘example‘

db_domain=‘‘    # Or set ‘test.com‘

# Following two parameters set the max number of open files and processes.

db_files=1000

processes=200

# Following is the default block size.

db_block_size=8192

# Following is the default audit_trail value.

audit_trail=db

# Following parameter sets the database compatibility level.

#compatible=11.2.0.0.0

# Two control files.

control_files=(‘/u01/app/oradata/example/control01.ctl‘,‘/u01/app/oradata/example/control02.ctl‘)

# Following parameters set MEMORY the SGA and the PGA targets.

memory_target=1G   #memory=SGA + PGA

# The following will ensure that flashback logs are retained for 2 hours

db_flashback_retention_target=7200

# Following two parameters configure the optional flash recovery area.

db_recovery_file_dest=/u01/app/oracle/flash_recovery_area‘

db_recovery_file_dest_size=5G

# Following twop arameters control the archiving of the redo log files.

log_archive_dest_1=‘location=/u01/app/archivelog1/examplemandatory reopen‘

log_archive_format=‘log_%t_%S_%r.arc‘

# Following is the default optimizer mode.

optimizer_mode=all_rows

# The following line makes it necessary to use a password file to connect as SYSDBA.

remote_login_passwordfile=exclusive

# Following parameter allows certain operations to resume after a suspension.

resumable_timeout=1800

# The following twop arameters pertain to automatic undo management.

undo_management=auto

undo_retention=7200

# The following is optional, since I‘m using only a single undo tablespace.

undo_tablespace=undotbs01

 

B.Createa pfile.

$ cd $ORACLE_HOME/dbs

$ grep -v ^# example.txt > example.ora

$ orapwd file=orapwexample password=system entries=10

PS:Authentication password file is named: file= orapw + SID

创建初始化参数文件可参考联机文档:
http://docs.oracle.com/cd/E11882_01/server.112/e25494/create.htm#ADMIN12541

 

2.创建数据目录:

$ mkdir -p /u01/app/archivelog1/example

$ mkdir -p /u01/app/oradata/example

$ mkdir -p /u01/app/oracle/admin/example/adump

 

3.启动实例到nomount状态.

$ sqlplus / as sysdba;

SQL> create spfile from pfile=‘$ORACLE_HOME/dbs/example.ora‘;

SQL> startup nomount;

 

$ ps -ef | greporacle

 

 

4.创建数据库脚本:

$ cd $ORACLE_HOME/dbs

$ cat create_bd.sql

spool dbcreate.log;

CREATE DATABASE example

   USER SYS IDENTIFIED BY system

   USER SYSTEM IDENTIFIED BY system

LOGFILE GROUP 1 ‘/u01/app/oradata/example/redo01.rdo‘ SIZE 50M,

           GROUP 2 ‘/u01/app/oradata/example/redo02.rdo‘  SIZE 50M,

GROUP 3 ‘/u01/app/oradata/example/redo03.rdo‘  SIZE 50M

MAXLOGFILES  5

   MAXLOGMEMBERS 5

   MAXLOGHISTORY 1

   MAXDATAFILES 100

   CHARACTER SET AL32UTF8

   NATIONAL CHARACTER SET AL16UTF16

   EXTENT MANAGEMENT LOCAL

   DATAFILE ‘/u01/app/oradata/example/system01.dbf‘SIZE 1024M REUSE

   SYSAUX DATAFILE ‘/u01/app/oradata/example/sysaux01.dbf‘SIZE 1024M REUSE

   DEFAULT TABLESPACE users

      DATAFILE ‘/u01/app/oradata/example/users01.dbf‘

      SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED

   DEFAULT TEMPORARY TABLESPACE tempts1

      TEMPFILE ‘/u01/app/oradata/example/temp01.dbf‘

      SIZE 2000M REUSE

   UNDO TABLESPACE undotbs01

      DATAFILE ‘/u01/app/oradata/example/undotbs01.dbf‘

      SIZE 2000M REUSE AUTOEXTEND ON MAXSIZEUNLIMITED

spool off

$ sqlplus / as sysdba

SQL> @$ORACLE_HOME/dbs/create_db.sql;

创建数据库脚本本,可参考联机文档:

http://docs.oracle.com/cd/E11882_01/server.112/e25494/create.htm#ADMIN12480

 

4.执行创建数据字典的脚本:

SQL> spool log1.

SQL> @?/rdbms/admin/catalog.sql;

SQL> spool log2

SQL> @?/rdbms/admin/catproc.sql;

 

SQL> connect system/system

SQL> spool log3

SQL> @?/sqlplus/admin/pupbld.sql;


本文出自 “~Never” 博客,请务必保留此出处http://ospub.blog.51cto.com/6238506/1586712

手工建库