CREATE ORACLE DATABASE FROM SCRATCH
I have created the database named ORCL, you should replace that with your own databasename 'dbname'
insert this line in /etc/oratab
dbname:/u01/app/oracle/product/11.2.0/dbhome_1:Y
create file with following content createdirorcl.sh chmod 750 and execute as root
createdirorcl.sh
Start file_____________________________________________________________________________________________________________________________
#!/bin/sh
dbname='insert here your databasename without quotes'
if [ -z "$1" ]; then
echo "Error, no databasename inserted"
exit
fi
mkdir /u01/app/oracle/dbs/$dbname
mkdir /u01/app/oracle/dbs/$dbname/datafile
mkdir /u01/app/oracle/dbs/$dbname/controlfile
mkdir /u01/app/oracle/dbs/$dbname/onlinelog
mkdir /u01/app/oracle/fra/$dbname
mkdir /u01/app/oracle/fra/$dbname/onlinelog
mkdir /u01/app/oracle/fra/$dbname/controlfile
chmod -R 750 /u01/app/oracle/dbs/$dbname
chmod -R 750 /u01/app/oracle/fra/$dbname
chown oracle:oinstall -R /u01/app/oracle/dbs/$dbname
chown oracle:oinstall -R /u01/app/oracle/fra/$dbname
End file_____________________________________________________________________________________________________________________________
[root@DBSRV01 /]# su - oracle
create file /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora -- chmod 644
initorcl.ora (change ORCL with your dbname)
Start file_____________________________________________________________________________________________________________________________
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files=(/u01/app/oracle/dbs/ORCL/controlfile/control1.ctl,/u01/app/oracle/dbs/ORCL/controlfile/control2.ctl,/u01/app/oracle/fra/ORCL/controlfile/control3.ctl)
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/dbs'
*.db_domain=''
*.db_recovery_file_dest='/u01/app/oracle/fra'
*.db_name='ORCL'
*.db_recovery_file_dest_size=2G
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP)(SERVICE=ORCLXDB)'
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.memory_max_target=3G
*.memory_target=2G
*.open_cursors=300
*.optimizer_mode='RULE'
*.pga_aggregate_target=530579456
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.utl_file_dir='/u01/app/ORCL/log'
*.undo_management=AUTO
*.undo_tablespace=undotbs
End file_____________________________________________________________________________________________________________________________
[oracle@DBSRV01 ~]$ . oraenv
ORACLE_SID = [oracle] ? dbname
Create password file
[oracle@DBSRV01 ~]$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle entries=10
create file /u01/app/oracle/dbs/create'dbname'.sql -- chmod 755
createORCL.sql (change ORCL with your dbname)
Start file_____________________________________________________________________________________________________________________________
set echo on
spool /u01/app/oracle/dbs/ORCL/CreateDB.log append
startup nomount pfile="/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora";
CREATE DATABASE "ORCL"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
DATAFILE '/u01/app/oracle/dbs/ORCL/datafile/system.dbf' SIZE 500M REUSE
AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/dbs/ORCL/datafile/sysaux01.dbf' SIZE 500M REUSE
AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/app/oracle/dbs/ORCL/datafile/temp01.dbf' SIZE 20M REUSE
AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE "UNDOTBS" DATAFILE '/u01/app/oracle/dbs/ORCL/datafile/undotbs01.dbf' SIZE 200M REUSE
AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
CHARACTER SET WE8ISO8859P15
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('/u01/app/oracle/dbs/ORCL/onlinelog/redo1a.log','/u01/app/oracle/fra/ORCL/onlinelog/redo1b.log') SIZE 50M,
GROUP 2 ('/u01/app/oracle/dbs/ORCL/onlinelog/redo2a.log','/u01/app/oracle/fra/ORCL/onlinelog/redo2b.log') SIZE 50M,
GROUP 3 ('/u01/app/oracle/dbs/ORCL/onlinelog/redo3a.log','/u01/app/oracle/fra/ORCL/onlinelog/redo3b.log') SIZE 50M
USER SYS IDENTIFIED BY "oracle" USER SYSTEM IDENTIFIED BY "oracle"
;
End file_____________________________________________________________________________________________________________________________
[oracle@Ecatest1 ~]$ sqlplus / as sysdba
SQL> show user;
USER is "SYS"
SQL> @$ORACLE_BASE/dbs/create'dbname'.sql
SQL> SELECT INSTANCE_NAME, DATABASE_STATUS, INSTANCE_ROLE from v$instance;
INSTANCE_NAME DATABASE_STATUS INSTANCE_ROLE
---------------- ----------------- ------------------
orcl ACTIVE PRIMARY_INSTANCE
SQL> select status from v$instance;
STATUS
------------
OPEN
Execute the catalog.sql,catproc.sql and pupbld.sql scripts:
Creates dictionary tables and views
SQL>@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catalog.sql
Creates PL/SQL procedures,functions and packages necessary.
SQL>@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catproc.sql
Create user profiles.
SQL> conn system
Enter password: oracle
Connected.
SQL>@/u01/app/oracle/product/11.2.0/dbhome_1/sqlplus/admin/pupbld.sql
SQL> conn sys / as sysdba
Enter password: oracle
Connected.
Create TABLESPACE USER
SQL> CREATE TABLESPACE USERS DATAFILE '/u01/app/oracle/dbs/ORCL/datafile/users.dbf' size 50M reuse DEFAULT;
Tablespace created.
SQL> ALTER DATABASE DEFAULT TABLESPACE USERS;
Database altered.
SQL> CREATE TABLESPACE INDX LOGGING DATAFILE '/u01/app/oracle/dbs/ORCL/datafile/indx01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
Tablespace created.
SQL> create spfile from pfile;
File created.
SQL> select log_mode from v$database;
LOG_MODE
------------
NOARCHIVELOG
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
No Comments