手工建库步骤:
1、创建数据库所需的目录,包括数据文件存放目录,日志存放目录,归档存放目录等
2、创建密码文件
3、创建参数文件
4、通过刚创建的pfile参数将数据库启动的nomount状态
5、开始执行create database 命令创建数据库
6、创建数据库相关视图和数据字典
7、检查数据库状态,是否创建完成
8、将创建数据库用的pfile参数创建成spfile,以后启动的时候不需要指定。
9、重启数据库,验证第八步骤
10、数据库创建完成。
---------------------------------------------------------------------------
执行步骤如下
---------------------------------------------------------------------------
1、创建建库所需的相关目录
[root@ora10g ~]# su - oracle [oracle@ora10g ~]$ cd /oradata/ [oracle@ora10g oradata]$ ls admin archive flash_back lost+found wwl [oracle@ora10g oradata]$ mkdir wwl02 [oracle@ora10g wwl02]$ mkdir -p /oradata/wwl02/admin/bdump /oradata/wwl02/admin/udump /oradata/wwl02/admin/cdump /oradata/wwl02/data/ [oracle@ora10g oradata]$ mkdir -p /oradata/wwl02/archive /oradata/wwl02/flash_back_area [oracle@ora10g oradata]$ cd wwl01 [oracle@ora10g wwl02]$ ls admin archive data flash_back_area [oracle@ora10g wwl02]$ cd admin/ [oracle@ora10g admin]$ ls -rtl 总计 12 drwxr-xr-x 2 oracle oinstall 4096 11-19 03:00 udump drwxr-xr-x 2 oracle oinstall 4096 11-19 03:00 cdump drwxr-xr-x 2 oracle oinstall 4096 11-19 03:00 bdump
2、创建数据库的密码文件
[oracle@ora10g oradata]$ cd $ORACLE_HOME/dbs [oracle@ora10g dbs]$ orapwd file=orawwl02 password=oracle entries=5 force=y; [oracle@ora10g dbs]$ ls hc_wwl.dat initdw.ora init.ora lkWWL orapwwwl orawwl02 spfilewwl.ora [oracle@ora10g dbs]$ cp init.ora initwwl02.ora
3、创建参数文件,并修改参数文件内容
[oracle@ora10g wwl02]$ cd $ORACLE_HOME/dbs [oracle@ora10g dbs]$ more initdw.ora |grep -v '^#'|grep -v '^$' >initwwl02.ora [oracle@ora10g wwl02]$ vi ?@/dbs/initwwl02.ora [oracle@ora10g wwl02]$ cat /orasoft/product/10.2.0/db_1/dbs/initwwl02.ora db_name = wwl02 instance_name = wwl02 pga_aggregate_target = 30M #DEMO db_cache_size = 100M #DEMO shared_pool_size = 80M #DEMO parallel_threads_per_cpu = 4 #SMALL star_transformation_enabled = true db_file_multiblock_read_count = 16 query_rewrite_enabled = true query_rewrite_integrity = trusted background_dump_dest = /oradata/wwl02/admin/bdump user_dump_dest = /oradata/wwl02/admin/udump core_dump_dest = /oradata/wwl02/admin/cdump control_files = /oradata/wwl02/data/control01.ctl undo_management = auto undo_tablespace = undotbs
4、用刚才创建的参数文件把实例启动到nomount状态
[oracle@ora10g ~]$ export ORACLE_SID=wwl02 [oracle@ora10g ~]$ echo $ORACLE_SID wwl02 [oracle@ora10g wwl02]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Sat Nov 19 03:18:47 2011 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount pfile = /orasoft/product/10.2.0/db_1/dbs/initwwl02.ora ORACLE instance started. Total System Global Area 218103808 bytes Fixed Size 1218604 bytes Variable Size 109053908 bytes Database Buffers 104857600 bytes Redo Buffers 2973696 bytes
5、创建数据库,数据库名称为wwl02
SQL> create database wwl02 2 user sys identified by oracle 3 user system identified by oracle 4 datafile '/oradata/wwl02/data/system01.dbf' size 300m 5 sysaux datafile '/oradata/wwl02/data/sysaux01.dbf' size 100m 6 default temporary tablespace temp tempfile '/oradata/wwl02/data/temp01.dbf' size 100m 7 undo tablespace undotbs datafile '/oradata/wwl02/data/undotbs01.dbf' size 100m 8 logfile 9 group 1 '/oradata/wwl02/data/redo01a.log' size 10m, 10 group 2 '/oradata/wwl02/data/redo02a.log' size 10m, group 3 '/oradata/wwl02/data/redo03a.log' size 10m character set zhs16gbk; 11 12 Database created.
6、执行建库后的脚本,创建系统的视图和数据字典
SQL> @?/rdbms/admin/catalog.sql SQL> @?/rdbms/admin/catproc.sql conn system/oracle SQL> @?/sqlplus/admin/pupbld.sql
7、检查数据库现在是否open状态。
SQL> select instance_name,status from v$instance; INSTANCE_NAME STATUS ---------------- ------------ wwl02 OPEN 1 row selected.
8、将创建数据库用的pfile参数创建成spfile
SQL> show parameter spfile NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ spfile string SQL> create spfile from pfile = '/orasoft/product/10.2.0/db_1/dbs/initwwl02.ora'; File created.
9、重启数据库后,数据库开始默认使用spfile启动数据库。
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area 218103808 bytes Fixed Size 1218604 bytes Variable Size 109053908 bytes Database Buffers 104857600 bytes Redo Buffers 2973696 bytes Database mounted. Database opened. SQL> show parameter spfile NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ spfile string /orasoft/product/10.2.0/db_1/d bs/spfilewwl02.ora SQL> SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options [oracle@ora10g wwl02]$ exit logout [root@ora10g ~]# exit logout