10年工作经验,专研网站运维。
全部博文(454)
分类: 系统运维
2013-02-18 13:24:20
1 首先ORACLE_SID问题
[oracle@paopao ~]$ echo $ORACLE_SID
orcl
因为要创建的数据库名为orcl1,所以更改ORACLE_SID如下:
[oracle@paopao ~]$ export ORACLE_SID=orcl1
2 准备初始化参数文件
##########################################################################
####
# Copyright (c) 1991, 2001, 2002 by Oracle Corporation
##########################################################################
####
###########################################
# Cache and I/O
###########################################
db_block_size=8192
db_file_multiblock_read_count=16
###########################################
# Cursors and Library Cache
###########################################
open_cursors=300
###########################################
# Database Identification
###########################################
db_domain=""
db_name=orcl1
###########################################
# Diagnostics and Statistics
###########################################
background_dump_dest=/home/oracle/oracle/product/10.2.0/db_1/admin/orcl1/b
dump
core_dump_dest=/home/oracle/oracle/product/10.2.0/db_1/admin/orcl1/cdump
user_dump_dest=/home/oracle/oracle/product/10.2.0/db_1/admin/orcl1/udump
###########################################
# File Configuration
###########################################
control_files=
("/home/oracle/oracle/product/10.2.0/oradata/orcl1/control01.ctl",
"/home/oracle/oracle/product/10.2.0/oradata/orcl1/control02.ctl",
"/home/oracle/oracle/product/10.2.0/oradata/orcl1/control03.ctl")
###########################################
# Job Queues
###########################################
job_queue_processes=10
###########################################
# Miscellaneous
###########################################
compatible=10.2.0.1.0
###########################################
# Processes and Sessions
###########################################
processes=150
###########################################
# SGA Memory
###########################################
sga_target=285212672
###########################################
# Security and Auditing
###########################################
audit_file_dest=/home/oracle/oracle/product/10.2.0/db_1/admin/orcl1/adump
remote_login_passwordfile=EXCLUSIVE
###########################################
# Shared Server
###########################################
dispatchers="(PROTOCOL=TCP) (SERVICE=orcl1XDB)"
###########################################
# Sort, Hash Joins, Bitmap Indexes
###########################################
pga_aggregate_target=94371840
###########################################
# System Managed Undo and Rollback Segments
###########################################
undo_management=AUTO
undo_tablespace=UNDOTBS1
3 准备建库脚本
CREATE DATABASE orcl1
USER sys IDENTIFIED BY admin
USER system IDENTIFIED BY manager
maxinstances 1
maxloghistory 1
maxlogfiles 5
maxlogmembers 5
DATAFILE '/home/oracle/oracle/product/10.2.0/oradata/orcl1/system01.dbf'
size 400M REUSE
SYSAUX DATAFILE
'/home/oracle/oracle/product/10.2.0/oradata/orcl1/sysaux01.dbf' size 400M
REUSE
DEFAULT TEMPORARY tablespace temp01
TEMPFILE '/home/oracle/oracle/product/10.2.0/oradata/orcl1/temp01.dbf'
size 100M REUSE
UNDO TABLESPACE "undotbs1"
DATAFILE '/home/oracle/oracle/product/10.2.0/oradata/orcl1/undotbs01.dbf'
size 200M REUSE
DEFAULT TABLESPACE users
DATAFILE '/home/oracle/oracle/product/10.2.0/oradata/orcl1/users01.dbf'
size 100M REUSE
CONTROLFILE REUSE
LOGFILE group 1
('/home/oracle/oracle/product/10.2.0/oradata/orcl1/redo01.log') size 10M
REUSE,
group 2
('/home/oracle/oracle/product/10.2.0/oradata/orcl1/redo02.log') size 10M
REUSE,
group 3
('/home/oracle/oracle/product/10.2.0/oradata/orcl1/redo03.log') size 10M
REUSE;
4 创建必要的目录
[oracle@paopao ~]$ mkdir -pv /home/oracle/oracle/product/10.2.0/db1/admin/orcl1{adump,bdump,cdump,dpbump,udump,pfile}
更改它们的权限
[oracle@paopao ~]$ chmod 775 -Rv /home/oracle/oracle/product/10.2.0/db1/admin/
更改他们的所属主组
[oracle@paopao ~]$ chown oracle:oinstall -Rv /home/oracle/oracle/product/10.2.0/db1/admin/
[oracle@paopao ~]$ mkdir /home/oracle/oracle/product/10.2.0/oradata/orcl1
[oracle@paopao ~]$ mkdir /home/oracle/oracle/product/10.2.0/oradata/orcl1/arch -pv
[oracle@paopao ~]$ chmod 775 -Rv /home/oracle/oracle/product/10.2.0/oradata/orcl1
[oracle@paopao ~]$ chown oracle:oinstall -Rv /home/oracle/oracle/product/10.2.0/oradata/orcl1
5 [oracle@paopao ~]$ /home/oracle/oracle/product/10.2.0/db_1/bin/sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 16 04:10:12 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn sys/admin as sysdba
Connected to an idle instance.
SQL> startup nomount pfile='/home/oracle/oracle/product/10.2.0/db_1/admin/orcl1/pfile/pfileorcl1.ora';
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
6 执行上面的脚本创建数据库
SQL> @/home/oracle/oracle/product/10.2.0/oradata/orcl1/createdb.sql
Database created.
7 以下两个命令将创建数据字典
SQL>@/home/oracle/oracle/product/10.2.0/db_1/rdbms/admin/catalog.sql
SQL>@/home/oracle/oracle/product/10.2.0/db_1/rdbms/admin/catproc.sql
SQL>@/home/oracle/oracle/product/10.2.0/db_1/rdbms/admin/catblock.sql;
SQL>@/home/oracle/oracle/product/10.2.0/db_1/rdbms/admin/catoctk.sql;
SQL>@/home/oracle/oracle/product/10.2.0/db_1/rdbms/admin/owminst.plb;
SQL>@/home/oracle/oracle/product/10.2.0/db_1/rdbms/admin/catclust.sql;
SQL>@/home/oracle/oracle/product/10.2.0/db_1/sqlplus/admin/pupbld.sql;
8 创建spfile
SQL> create spfile='/home/oracle/oracle/product/10.2.0/db_1/admin/orcl1/pfile/spfileorcl1.ora' from pfile='/home/oracle/oracle/product/10.2.0/db_1/admin/orcl1/pfile/pfileorcl1.ora'
9 把数据库打开到正常状态
SQL>alter database mount;
SQL>alter database open;