Sie sind auf Seite 1von 8

----------Manually Create oracle database 10g--------======= 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" ##########Create Data file direcotry################## mkdir $oracle_data_disk1/$db_name echo "mkdir $oracle_data_disk1/$db_name" mkdir $oracle_data_disk2/$db_name echo "mkdir $oracle_data_disk2/$db_name" 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 orac reate.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============================================== -This is the example of initoradb.ora initialization file. ======================initoradb.ora============================================ # # $Header: init.ora 06-aug-98.10:24:40 atsukerm Exp $ # # Copyright (c) 1991, 1997, 1998 by Oracle Corporation # NAME # init.ora # FUNCTION # NOTES # MODIFIED # atsukerm 08/06/98 - fix for 8.1. # hpiao 06/05/97 - fix for 803 # glavash 05/12/97 - add oracle_trace_enable comment # hpiao 04/22/97 - remove ifile=, events=, etc. # alingelb 09/19/94 - remove vms-specific stuff # dpawson 07/07/93 - add more comments regarded archive start # maporter 10/29/92 - Add vms_sga_use_gblpagfile=TRUE # jloaiza 03/07/92 - change ALPHA to BETA # danderso 02/26/92 - change db_block_cache_protect to _db_block_cache_p # ghallmar 02/03/92 - db_directory -> db_domain # maporter 01/12/92 - merge changes from branch 1.8.308.1 # maporter 12/21/91 - bug 76493: Add control_files parameter # wbridge 12/03/91 - use of %c in archive format is discouraged # ghallmar 12/02/91 - add global_names=true, db_directory=us.acme.com # thayes 11/27/91 - Change default for cache_clone # jloaiza 08/13/91 merge changes from branch 1.7.100.1 # jloaiza 07/31/91 add debug stuff # rlim 04/29/91 removal of char_is_varchar2 # Bridge 03/12/91 - log_allocation no longer exists # Wijaya 02/05/91 - remove obsolete parameters # ############################################################################## # Example INIT.ORA file # # This file is provided by Oracle Corporation to help you customize # your RDBMS installation for your site. Important system parameters # are discussed, and example settings given. # # Some parameter settings are generic to any size installation. # For parameters that require different values in different size # installations, three scenarios have been provided: SMALL, MEDIUM # and LARGE. Any parameter that needs to be tuned according to # installation size will have three settings, each one commented # according to installation size. # # Use the following table to approximate the SGA size needed for the # three scenarious provided in this file: # # -------Installation/Database Size-----# SMALL MEDIUM LARGE

# Block 2K 4500K 6800K 17000K # Size 4K 5500K 8800K 21000K # # To set up a database that multiple instances will be using, place # all instance-specific parameters in one file, and then have all # of these files point to a master file using the IFILE command. # This way, when you change a public # parameter, it will automatically change on all instances. This is # necessary, since all instances must run with the same value for many # parameters. For example, if you choose to use private rollback segments, # these must be specified in different files, but since all gc_* # parameters must be the same on all instances, they should be in one file. # # INSTRUCTIONS: Edit this file and the other INIT files it calls for # your site, either by using the values provided here or by providing # your own. Then place an IFILE= line into each instance-specific # INIT file that points at this file. # # NOTE: Parameter values suggested in this file are based on conservative # estimates for computer memory availability. You should adjust values upward # for modern machines. # # You may also consider using Database Configuration Assistant tool (DBCA) # to create INIT file and to size your initial set of tablespaces based # on the user input. ############################################################################### # replace DEFAULT with your database name db_name=oradb instance_name=oradb open_cursors=300 db_files = 80 # db_files = 400 # db_files = 1500 db_file_multiblock_read_count = 8 # db_file_multiblock_read_count = 16 # db_file_multiblock_read_count = 32 db_block_buffers = 100 # db_block_buffers = 550 # db_block_buffers = 3200 #shared_pool_size = 3500000 # shared_pool_size = 5000000 # shared_pool_size = 9000000 shared_pool_size = 52132659 log_checkpoint_interval = 10000 processes = 50 # processes = 100 # processes = 200 parallel_max_servers = 5 # parallel_max_servers = 4 x (number of CPUs) # parallel_max_servers = 4 x (number of CPUs) log_buffer = 32768 # SMALL # MEDIUM # LARGE # SMALL # MEDIUM # LARGE # SMALL # SMALL # MEDIUM # LARGE # SMALL # MEDIUM # LARGE # SMALL # MEDIUM # LARGE # SMALL # MEDIUM # LARGE

# log_buffer = 32768 # log_buffer = 163840 # audit_trail = true # timed_statistics = true max_dump_file_size = 10240 # # # # # # if you want auditing # if you want timed statistics # limit trace file size to 5 Meg each

# MEDIUM # LARGE

Uncommenting the line below will cause automatic archiving if archiving has been enabled using ALTER DATABASE ARCHIVELOG. log_archive_start = true log_archive_dest = disk$rdbms:[oracle.archive] log_archive_format = "T%TS%S.ARC"

# If using private rollback segments, place lines of the following # form in each of your instance-specific init.ora files: # rollback_segments = (name1, name2) # # # # # # If using public rollback segments, define how many rollback segments each instance will pick up, using the formula # of rollback segments = transactions / transactions_per_rollback_segment In this example each instance will grab 40/5 = 8: transactions = 40 transactions_per_rollback_segment = 5

# Global Naming -- enforce that a dblink has same name as the db it connects to global_names = TRUE # # # # # 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. # global database name is db_name.db_domain

# db_domain = us.acme.com

# FOR DEVELOPMENT ONLY, ALWAYS TRY TO USE SYSTEM BACKING STORE # vms_sga_use_gblpagfil = TRUE # 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 = #event = "10210 trace name #event = "10211 trace name #event = "10235 trace name #event = "10049 trace name true context context context context forever, forever, forever, forever, level level level level 2" 2" 1" 2" # # # # # memory protect buffers data block checking index block checking memory heap checking memory protect cursors

# define parallel server (multi-instance) parameters #ifile = ora_system:initps.ora # define two control files by default control_files = ("/disk1/u01/oracleData/oradb/control01.ctl", "/disk1/u01/oracleData/oradb/control02.ctl", "/disk1/u01/oracleData/oradb/control03.ctl") # # # # 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. ********************* STEP 1: Connect to oracle and create SPFILE ------------------------------------------Connect into oracle 10g software with system user and password manager. You need to change system password for security. -Create SPFILE using initoradb.ora with this command. Assuming your $ORACLE_HOME environmental varial has this value: /opt/oracle/product/10.1.0/Db_1 Save the following script in the current directory when you issue sqlplus command to connect to oracle. =================crstep1.sql ================================ create SPFILE='/opt/oracle/product/10.1.0/Db_1/dbs/spfileoradb.ora' from PFILE='/opt/oracle/product/10.1.0/Db_1/dbs/initoradb.ora'; =================crstep1.sql ================================ $sqlplus /nolog SQL>connect system/manager as sysdba; SQL>sta crstep1.sql STEP 2: Creating database oradb -------------------------------I recommend save your create database statement in a script. I use the following script to create oradb database. Oracle recommend a UNDO and DEFAULT TEMPORARY tablespace for each database. -All new user without an explicit temporary tablespace will be asigned this TEMPORARY tablespace. ===================================crstep2.sql================================== CREATE DATABASE oradb LOGFILE GROUP 1 ('/disk1/u01/oracleData/oradb/redo/redo01.log', '/disk2/u02/oracleData/oradb/redo/redo01.log') size 20M REUS E, GROUP 2 ('/disk1/u01/oracleData/oradb/redo/redo02.log', '/disk2/u02/oracleData/oradb/redo/redo02.log') size 20M REUS E, GROUP 3 ('/disk1/u01/oracleData/oradb/redo/redo03.log', '/disk2/u02/oracleData/oradb/redo/redo03.log') size 20M REUS E, GROUP 4 ('/disk1/u01/oracleData/oradb/redo/redo04.log', '/disk2/u02/oracleData/oradb/redo/redo04.log') size 20M REUS

E MAXLOGFILES 5 MAXLOGMEMBERS 5 MAXDATAFILES 500 MAXINSTANCES 1 DATAFILE '/disk1/u01/oracleData/oradb/system/system01.dbf' size 200M REUSE AUTOEXTEND ON NEXT 1M MAXSIZE 200M SYSAUX DATAFILE '/disk1/u01/oracleData/oradb/system/sysaux01.dbf' SIZE 300M R EUSE UNDO TABLESPACE undots DATAFILE '/disk1/u01/oracleData/oradb/system/undo01.dbf' SIZE 256M REU SE AUTOEXTEND ON MAXSIZE UNLIMITED DEFAULT TEMPORARY TABLESPACE tempts TEMPFILE '/disk1/u01/oracleData/oradb/temp/temp01.dbf' size 256M reuse CHARACTER SET WE8ISO8859P1; ===================================crstep2.sql================================== 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. STEP 3: Create custom table space ---------------------------------We decide to use undo table space in create database statement. Hence we don't explicitly create rollback segment in this step. -Oracle official documentation recommends using undo tablespace which is better managed by oracle 10g. -Support for rollback segment will be deprecated in future release. I only create users and index tablespace. Lines start with two dashes are commented. I keep them here to show the syntax to create rollback segments. ====================crstep3.sql====================================== -- Create the following tablespaces: -- 1. users tablespace -- 2. index tablespace --CREATE ROLLBACK SEGMENT rb_temp STORAGE (INITIAL 64k NEXT 128K); --ALTER ROLLBACK SEGMENT rb_temp ONLINE; -CREATE TABLESPACE users DATAFILE '/disk1/u01/oracleData/oradb/users/users01.dbf' size 256M, '/disk1/u01/oracleData/oradb/users/users02.dbf' size 256M AUTOEXTEND ON NEXT 512K MINIMUM EXTENT 64K DEFAULT STORAGE (INITIAL 256K NEXT 128K MINEXTENTS 2 MAXEXTENTS 2048); CREATE TABLESPACE indx DATAFILE '/disk1/u01/oracleData/oradb/indx/indx01.dbf' size 256M, '/disk1/u01/oracleData/oradb/indx/indx02.dbf' size 256M ; --All new user without an explicit temp table space will be asigned this. Recomm ended 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 --CREATE --CREATE --CREATE --ALTER --ALTER --ALTER --ALTER

ROLLBACK ROLLBACK ROLLBACK ROLLBACK ROLLBACK ROLLBACK ROLLBACK ROLLBACK

SEGMENT SEGMENT SEGMENT SEGMENT SEGMENT SEGMENT SEGMENT SEGMENT

rb1 rb2 rb3 rb4 rb1 rb2 rb3 rb4

STORAGE STORAGE STORAGE STORAGE ONLINE; ONLINE; ONLINE; ONLINE;

(INITIAL (INITIAL (INITIAL (INITIAL

32K 32K 32K 32K

NEXT NEXT NEXT NEXT

64K) 64K) 64K) 64K)

TABLESPACE TABLESPACE TABLESPACE TABLESPACE

rbs; rbs; rbs; rbs;

--ALTER ROLLBACK SEGMENT rb_temp OFFLINE; --DROP ROLLBACK SEGMENT rb_temp; ====================crstep3.sql====================================== While still in SQL> prompt, run crstep3.sql SQL>sta crstep3.sql; This step may take several minutes and consumes system resource. STEP 4:Building default catalog and dictionaries. ------------------------------------------------Basically, run the scripts provided by oracle 10g to create dictionaries. Here is the script. ========================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 th e screen. STEP 5:Creating user and start using new database ------------------------------------------------Here is the example script to create user. You can run individual script in SQL> prompt also. User joe will have dba privilege in oradb database. ===============crstep5.sql====================== create user joe identified by joepassword; grant connect,resource,dba to joe; alter user salim default tablespace users; ===============crstep5.sql====================== While still in SQL> prompt, run crstep5.sql SQL>sta crstep5.sql; SQL>exit; The last step is to start listener with this command. $lsnrctl start ----------Enjoy using new database. ------------Farid Ahmed

Das könnte Ihnen auch gefallen