&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
A script for automated manual create db:
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
WARNING:
1. This script is created for Milo Luo for reduce the human intervention.
2. It's only base the basic creataion
of database, if you may use this script in other scenarioes, please do
check script and what you will do.
3. This script has been test on RHEL 5u5
32bit with Oracle 10.2.0.1.0, please know that what this script will do
for you if you're using a critical database.
ALL YOU NEED TO DO ARE:
1. Make sure the variables are adjust to your environment:
2. Your data and dumps path are the same with this script
3. Make sure the datafiles and other files locations are adjusted your requirement.
%%%%%%%%%%%%%%%%%%%%%
manual_create_db_v0.2.sh
%%%%%%%%%%%%%%%%%%%%%
#!/bin/bash
# Purpose: manually create db without too much human intervention.
# WARNING: Before you use this script, you'd better know what will do in your OS.
# Author: Milo
# Date: April 9, 2010
# Environment decalration
ORACLE_SID=liuzhou
DB_NAME=$ORACLE_SID
ORACLE_BASE=/u01/app/oracle/
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
DATA_DIR=$ORACLE_BASE/oradata/$ORACLE_SID
DUMP_DIR=$ORACLE_BASE/admin/$ORACLE_SID
CHAR_SET='we8iso8859p1'
NCHAR_SET='al16utf16'
export ORACLE_SID=$ORACLE_SID
export ORACLE_BASE=$ORACLE_BASE
export ORACLE_HOME=$ORACLE_HOME
echo "Step 1: prepared the directories"
# Step 1: prepared that directories
mkdir -p $DATA_DIR
mkdir -p ${DUMP_DIR}/{a,b,c,u}dump
# To make sure has this dir
mkdir -p ${ORACLE_BASE}/flash_recovery_area &> /dev/null
echo "Step 2: New the passwd file and init the pfile"
# Step 2: New the passwd file and init the pfile
orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle
# Create pfile with these contents:
cat >> $ORACLE_HOME/dbs/init${ORACLE_SID}.ora << EOF
compatible=10.2.0.1.0
db_name=$DB_NAME
shared_pool_size=200m
audit_file_dest=${DUMP_DIR}/adump
background_dump_dest=${DUMP_DIR}/bdump
core_dump_dest=${DUMP_DIR}/cdump
user_dump_dest=${DUMP_DIR}/udump
control_files=${DATA_DIR}/control01.ctl
db_recovery_file_dest=${ORACLE_BASE}/flash_recovery_area
db_recovery_file_dest_size=1g
undo_management=auto
undo_tablespace=undotbs01
EOF
echo "Step 3: Create DB"
# Step 3: Create DB
sqlplus /nolog << EOF
conn / as sysdba
-- Start instance
startup nomount;
-- Pls set DB_NAME to your correct name, also check the location, files and sizes
-- Create database
create database $DB_NAME
maxinstances 8
maxloghistory 1
maxlogfiles 16
maxlogmembers 3
maxdatafiles 100
datafile '${DATA_DIR}/system01.dbf' size 300m autoextend on extent management local
sysaux datafile '${DATA_DIR}/sysaux01.dbf' size 120m autoextend on
default temporary tablespace temp tempfile '${DATA_DIR}/temp01.dbf' size 20m
undo tablespace undotbs01 datafile '${DATA_DIR}/undotbs01.dbf' size 40m
default tablespace users01 datafile '${DATA_DIR}/users01.dbf' size 300m
character set $CHAR_SET
national character set $NCHAR_SET
logfile
group 1 '${DATA_DIR}/redo01.log' size 50m,
group 2 '${DATA_DIR}/redo02.log' size 50m;
-- Change the system user's password
alter user system identified by oracle;
-- Connenct to sys user
connect / as sysdba;
-- Import the data dictionaries and plsql packages
@?/rdbms/admin/catalog
@?/rdbms/admin/catproc
-- Drop the warning note, when normal use login
conn system/oracle
@?/sqlplus/admin/pupbld
EOF
%%%%%%%%%%%%%%%%%%%%%
Test after manually create it
[oracle@vm ~]$ export ORACLE_SID=liuzhou
[oracle@vm ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Apr 10 12:50:36 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string liuzhou
db_unique_name string liuzhou
global_names boolean FALSE
instance_name string liuzhou
lock_name_space string
log_file_name_convert string
service_names string liuzhou
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> select count(*) from dba_objects;
COUNT(*)
----------
9404
Script might update or not, base on whether it's necessary, you are free to use this script if you wish. But please let me know.
Have fun! :)
Milo
阅读(1776) | 评论(0) | 转发(1) |