Professional Documents
Culture Documents
10g DB Creation
10g DB Creation
1. Create the database using the directories and control files created in step 1.
The followings are the detail steps to perform these two steps.
Summary
=======
Assuming Oracle 10g software are installed on FC 3 system.
-Database name: oradb
-Oracle Datafile directories: /disk1/u01/oracleData /disk2/u02/oracleData
-The following environmental variables are set: $ORACLE_BASE $ORACLE_HOME
Two sections:
A. Preparing file directories and init file.
B. Creating database.
**********************************************
A. Preparing file directories and init file.
**********************************************
STEP 1
********
- /disk1/u01/oracleData and /disk2/u02/oracleData directories are
created by root and set the "oracle" user as owner and groups as
"oinstall".
You can use the following commands to create these directories.
$mkdir -p /disk1/u01/oracleData
$chown oracle /disk1/u01/oracleData
$chown -R oracle /disk1/u01/oracleData
$chgrp -R oinstall /disk1/u01/oracleData
Repeat same steps for /disk2.
STEP 2
********
-Create admin directory in $ORACLE_BASE and datafile directory for new
database.
You can use the following script to do that. This script also copy
the preconfigured init.ora file and create password file.
=========================oracreate.sh====================================
#!/usr/bin/sh
db_name=oradb
oracle_data_disk1=/disk1/u01/oracleData
oracle_data_disk2=/disk2/u02/oracleData
if [ ! -d $ORACLE_BASE/admin ]; then
mkdir $ORACLE_BASE/admin
echo "create $ORACLE_BASE/admin direcotry"
fi
if [ ! -d $oracle_data_disk1 ]; then
mkdir -p $oracle_data_disk1
echo "create $oracle_data_disk1 direcotry"
fi
if [ ! -d $oracle_data_disk2 ]; then
mkdir -p $oracle_data_disk2
echo "create $oracle_data_disk2 direcotry"
fi
mkdir $ORACLE_BASE/admin/$db_name
echo "mkdir $ORACLE_BASE/admin/$db_name"
mkdir $ORACLE_BASE/admin/$db_name/adhoc
echo "mkdir $ORACLE_BASE/admin/$db_name/adhoc"
mkdir $ORACLE_BASE/admin/$db_name/bdump
echo "mkdir $ORACLE_BASE/admin/$db_name/bdump"
mkdir $ORACLE_BASE/admin/$db_name/cdump
echo "mkdir $ORACLE_BASE/admin/$db_name/cdump"
mkdir $ORACLE_BASE/admin/$db_name/create
echo "mkdir $ORACLE_BASE/admin/$db_name/create"
mkdir $ORACLE_BASE/admin/$db_name/exp
echo "mkdir $ORACLE_BASE/admin/$db_name/exp"
mkdir $ORACLE_BASE/admin/$db_name/pfile
echo "mkdir $ORACLE_BASE/admin/$db_name/pfile"
mkdir $ORACLE_BASE/admin/$db_name/udump
echo "mkdir $ORACLE_BASE/admin/$db_name/udump"
mkdir $oracle_data_disk1/$db_name/archive
echo "mkdir $oracle_data_disk1/$db_name/archive"
mkdir $oracle_data_disk1/$db_name/system
echo "mkdir $oracle_data_disk1/$db_name/system"
mkdir $oracle_data_disk1/$db_name/redo
echo "mkdir $oracle_data_disk1/$db_name/redo"
mkdir $oracle_data_disk2/$db_name/redo
echo "mkdir $oracle_data_disk2/$db_name/redo"
mkdir $oracle_data_disk1/$db_name/indx
echo "mkdir $oracle_data_disk1/$db_name/indx"
mkdir $oracle_data_disk1/$db_name/temp
echo "mkdir $oracle_data_disk1/$db_name/temp"
mkdir $oracle_data_disk1/$db_name/users
echo "mkdir $oracle_data_disk1/$db_name/users"
cp init$db_name.ora $ORACLE_HOME/dbs/init$db_name.ora
$ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapw password=ORACLE
entries=5
======================oracreate.sh========================================
======
-You can also use this script to clean the directories and files created
by oracreate.sh
=======================oraclean.sh========================================
======
db_name=oradb
rm -rf $ORACLE_BASE/admin/*
echo "rm -rf $ORACLE_BASE/admin/*"
oracle_data_disk1=/disk1/u01/oracleData
oracle_data_disk2=/disk2/u02/oracleData
rm -rf $oracle_data_disk1/*
rm -rf $oracle_data_disk2/*
echo "rm -rf $oracle_data_disk1/*"
echo "rm -rf $oracle_data_disk2/*"
rm $ORACLE_HOME/dbs/init$db_name.ora
echo "rm $ORACLE_HOME/dbs/init$db_name.ora"
rm $ORACLE_HOME/dbs/orapw
echo "rm $ORACLE_HOME/dbs/orapw"
=======================oraclean.sh========================================
======
open_cursors=300
db_files = 80 #
SMALL
# db_files = 400 #
MEDIUM
# db_files = 1500 #
LARGE
db_file_multiblock_read_count = 8 #
SMALL
# db_file_multiblock_read_count = 16 #
MEDIUM
# db_file_multiblock_read_count = 32 #
LARGE
db_block_buffers = 100 #
SMALL
# db_block_buffers = 550 #
MEDIUM
# db_block_buffers = 3200 #
LARGE
#shared_pool_size = 3500000 #
SMALL
# shared_pool_size = 5000000 #
MEDIUM
# shared_pool_size = 9000000 #
LARGE
shared_pool_size = 52132659
log_checkpoint_interval = 10000
processes = 50 #
SMALL
# processes = 100 #
MEDIUM
# processes = 200 #
LARGE
parallel_max_servers = 5 #
SMALL
# parallel_max_servers = 4 x (number of CPUs) #
MEDIUM
# parallel_max_servers = 4 x (number of CPUs) #
LARGE
log_buffer = 32768 #
SMALL
# log_buffer = 32768 #
MEDIUM
# log_buffer = 163840 #
LARGE
# Edit and uncomment the following line to provide the suffix that will be
# appended to the db_name parameter (separated with a dot) and stored as
the
# global database name when a database is created. If your site uses
# Internet Domain names for e-mail, then the part of your e-mail address
after
# the '@' is a good candidate for this parameter value.
# FOR BETA RELEASE ONLY. Enable debugging modes. Note that these can
# adversely affect performance. On some non-VMS ports the
db_block_cache_*
# debugging modes have a severe effect on performance.
#_db_block_cache_protect = true # memory protect
buffers
#event = "10210 trace name context forever, level 2" # data block checking
#event = "10211 trace name context forever, level 2" # index block
checking
#event = "10235 trace name context forever, level 1" # memory heap
checking
#event = "10049 trace name context forever, level 2" # memory protect
cursors
# Uncomment the following line if you wish to enable the Oracle Trace
product
# to trace server activity. This enables scheduling of server collections
# from the Oracle Enterprise Manager Console.
# Also, if the oracle_trace_collection_name parameter is non-null,
# every session will write to the named collection, as well as enabling
you
# to schedule future collections from the console.
# oracle_trace_enable = TRUE
# Uncomment the following line, if you want to use some of the new 8.1
# features. Please remember that using them may require some downgrade
# actions if you later decide to move back to 8.0.
#compatible = 8.1.0
background_dump_dest = /opt/oracle/admin/oradb/bdump
core_dump_dest = /opt/oracle/admin/oradb/cdump
user_dump_dest = /opt/oracle/admin/oradb/udump
UNDO_MANAGEMENT = AUTO
LOG_ARCHIVE_DEST = /disk1/u01/oracleData/oradb/archive
=====================initoradb.ora========================================
======
*********************
B. Creating database.
*********************
While still in SQL> prompt, run this command to startup oracle engine
without
mounting any database.
SQL>startup nomount;
Then execute create database script crstep2.sql
SQL>sta crstep2.sql;
This step may take several minutes and consumes system resource.
====================crstep3.sql======================================
-- Create the following tablespaces:
-- 1. users tablespace
-- 2. index tablespace
--All new user without an explicit temp table space will be asigned this.
Recommended by oracle.
--CREATE TEMPORARY TABLESPACE tempts1
-- TEMPFILE '/disk1/u01/oracleData/oradb/temp/temp01.dbf' size 256M
reuse;
--ALTER database oradb DEFAULT TEMPORARY TABLESPACE tempts1;
--CREATE ROLLBACK SEGMENT rb1 STORAGE (INITIAL 32K NEXT 64K) TABLESPACE
rbs;
--CREATE ROLLBACK SEGMENT rb2 STORAGE (INITIAL 32K NEXT 64K) TABLESPACE
rbs;
--CREATE ROLLBACK SEGMENT rb3 STORAGE (INITIAL 32K NEXT 64K) TABLESPACE
rbs;
--CREATE ROLLBACK SEGMENT rb4 STORAGE (INITIAL 32K NEXT 64K) TABLESPACE
rbs;
--ALTER ROLLBACK SEGMENT rb1 ONLINE;
--ALTER ROLLBACK SEGMENT rb2 ONLINE;
--ALTER ROLLBACK SEGMENT rb3 ONLINE;
--ALTER ROLLBACK SEGMENT rb4 ONLINE;
========================crstep4.sql=================================
@/opt/oracle/product/10.1.0/Db_1/rdbms/admin/catalog.sql;
@/opt/oracle/product/10.1.0/Db_1/rdbms/admin/catproc.sql;
@/opt/oracle/product/10.1.0/Db_1/sqlplus/admin/pupbld.sql;
========================crstep4.sql=================================
While still in SQL> prompt, run crstep4.sql
SQL>sta crstep4.sql;
This step may take several minutes and consumes system resource. You will
notice a lot of message about Package, Grant, View and Synonym flying
through the screen.
===============crstep5.sql======================
create user joe identified by joepassword;
grant connect,resource,dba to joe;
alter user salim default tablespace users;
===============crstep5.sql======================
Extra Notes
You can change the database from dictionary managed to local managed by using EXTENT MANAGEMENT
LOCAL clause.
For some reasons, after I change to local management in create database clasue, if I add AUTOEXTEND ON
MAXSIZE UNLIMITED to default database tablespace clause, I get create statement error. In my create
database example script, it is this line DATAFILE
'/disk1/u01/oracleData/oradb/system/system01.dbf' size 200M REUSE. May be
this clause does not allow AUTOEXTEND to UNLIMITED.
Local managed also requires larger system tablespace. I bump up system01.dbf from 200M to 325M as the
value shown in Oracle Tutorial. This helps to eliminate insufficient system tablespace issue when creating
system catalogs.
I also try to use the CHARACTER SET US7ASCII and NATIONAL CHARACTER SET AL16UTF16 in
create database clause without problem.
I need to add pupbld.sql in crstep4 to solve error message appears in sqlplus about
PRODUCT_USER_PROFILE not loaded.....If you have not done so, you can run this script directly from
sqlplus but make sure no one is accessing database when the script is run.
http://www.gotidea.net/Database/10gcreatedb.html