Oracle安装部署之命令建库

时间:2022-04-29 12:50:23

1、建目录:

[oracle@wen ~]$ mkdir $ORACLE_BASE/admin/rezin/{a,b,c,dp}dump -p

[oracle@wen ~]$ mkdir $ORACLE_HOME/oradata/rezin

2、建立参数文件

[oracle@wen ~]$ cd $ORACLE_HOME/dbs

[oracle@wen dbs]$ vim initrezin.ora

内容如下:

compatible='11.2.0.1'

db_name='rezin'

db_block_size=8192

core_dump_dest='/u01/app/oracle/admin/rezin/cdump'

sga_max_size=200m

db_create_file_dest='/u01/app/oracle/oradata'

db_create_online_log_dest='/u01/app/oracle/oradata'

undo_management=auto

undo_tablespace='SYS_UNDOTS'

非omf下的建库pfile文件内容(传统):

compatible='11.2.0.1'

db_name='rezin'

db_block_size=8192

core_dump_dest='/u01/app/oracle/admin/rezin/cdump'

sga_max_size=200m

pga_max_size=200m

control_files='/u01/app/oracle/oradata/rezin/control01.ctl'

db_create_file_dest='/u01/app/oracle/oradata'

db_create_online_log_dest='/u01/app/oracle/oradata'

undo_management=auto

undo_tablespace='SYS_UNDOTS'

3、启动实例到nomount阶段

[oracle@wen dbs]$ export ORACLE_SID=rezin

[oracle@wen dbs]$ sqlplus / as sysdba

[uniread] Loaded history (22 lines)

SQL*Plus: Release 11.2.0.1.0 Production on Sat May 23 23:36:46 2015

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

Connected to an idle instance.

SQL> startup nomount

ORACLE instance started.

Total System Global Area  217157632 bytes

Fixed Size                  2211928 bytes

Variable Size             159387560 bytes

Database Buffers           50331648 bytes

Redo Buffers                5226496 bytes

SQL> create spfile from pfile;

File created.

SQL> startup force nomount;

ORACLE instance started.

Total System Global Area  217157632 bytes

Fixed Size                  2211928 bytes

Variable Size             159387560 bytes

Database Buffers           50331648 bytes

Redo Buffers                5226496 bytes

4、建立数据库

SQL> ho ls /u01/app/oracle/oradata/rezin

SQL> create database rezin;

Database created.

SQL> select name from v$datafile;

NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/REZIN/datafile/o1_mf_system_bp195k6f_.dbf

/u01/app/oracle/oradata/REZIN/datafile/o1_mf_sysaux_bp195tmj_.dbf

/u01/app/oracle/oradata/REZIN/datafile/o1_mf_sys_undo_bp1962fs_.dbf

非ofm下的建库语句内容(传统):

create database rezin

maxdatafiles 100

maxlogfiles 16

maxlogmembers 3

maxinstances 1

character set al32utf8

notional character set al16utf16

user sys identified by oracle

user system identified by oracle

datafile

'/u01/app/oracle/oradata/rezin/system01.dbf' size 300m autoextend on next 1m maxsize unlimited extent management local

sysaux datafile

'/u01/app/oracle/oradata/rezin/sysaux01.dbf' size 200m autoextend on

undo tablespace undotbs datafile '/u01/app/oracle/oradata/rezin/undotbs01.dbf' size 300m autoextend on

logfile

group 1 ' /u01/app/oracle/oradata/rezin/redo01.log' 50m

group 2 ' /u01/app/oracle/oradata/rezin/redo01.log' 50m

/

create tablespace users datafile '/u01/app/oracle/oradata/rezin/users01.dbf' size 100m autoextend on

create temporary ablespace temp tempfile '/u01/app/oracle/oradata/rezin/temp01.dbf' size 10m autoextend on

5、建立users表空间和temp表空间并设置其为默认表空间

SQL> create tablespace users;

Tablespace created.

SQL> create temporary tablespace temp;

Tablespace created.

SQL> alter database default tablespace users;

Database altered.

SQL> alter database default temporary tablespace temp;

Database altered.

6、创建脚本并运行脚本、创建数据字典视图

[oracle@wen ~]$vim sgjk.sql

内容如下:

@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catalog.sql

@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catproc.sql

conn system/oracle

@/u01/app/oracle/product/11.2.0/dbhome_1/sqlplus/admin/pupbld.sql

conn / as sysdba

shutdown immediate

startup

SQL>@sgjk.sql

7、配置dbca、oem和netca