mkdir -p $ORACLE_BASE/admin/[DB_NAME]/scripts
racdb1.sh
#!/bin/sh OLD_UMASK=`umask` umask 0027 mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/adump mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/dpdump mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/hdump mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/pfile mkdir -p [ORACLE_BASE]/cfgtoollogs/dbca/[DB_NAME] ssh oracle@[HOST_NAME2] "mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/adump" ssh oracle@[HOST_NAME2] "mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/dpdump" ssh oracle@[HOST_NAME2] "mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/hdump" ssh oracle@[HOST_NAME2] "mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/pfile" ssh oracle@[HOST_NAME2] "mkdir -p [ORACLE_BASE]/cfgtoollogs/dbca/[DB_NAME]" umask ${OLD_UMASK} ORACLE_SID=[ORACLE_SID1]; export ORACLE_SID PATH=$ORACLE_HOME/bin:$PATH; export PATH echo You should Add this entry in the /etc/oratab: [DB_NAME]:[DB_HOME]:Y [DB_HOME]/bin/sqlplus /nolog @[ORACLE_BASE]/admin/[DB_NAME]/scripts/racdb1.sql
#!/bin/sh OLD_UMASK=`umask` umask 0027 mkdir -p /u01/app/oracle/admin/racdb/adump mkdir -p /u01/app/oracle/admin/racdb/dpdump mkdir -p /u01/app/oracle/admin/racdb/hdump mkdir -p /u01/app/oracle/admin/racdb/pfile mkdir -p /u01/app/oracle/cfgtoollogs/dbca/racdb umask ${OLD_UMASK} ORACLE_SID=racdb1; export ORACLE_SID PATH=$ORACLE_HOME/bin:$PATH; export PATH echo You should Add this entry in the /etc/oratab: racdb:/u01/app/oracle/product/11.2.0/db_1:Y /u01/app/oracle/product/11.2.0/db_1/bin/sqlplus /nolog @/u01/app/oracle/admin/racdb/scripts/racdb1.sql
racdb1.sql
set verify off ACCEPT sysPassword CHAR PROMPT 'Enter new password for SYS: ' HIDE ACCEPT systemPassword CHAR PROMPT 'Enter new password for SYSTEM: ' HIDE host [DB_HOME]/bin/orapwd file=[DB_HOME]/dbs/orapw[ORACLE_SID1] force=y host [GRID_HOME]/bin/setasmgidwrap o=[DB_HOME]/bin/oracle host [DB_HOME]/bin/srvctl add database -d [DB_NAME] -o [DB_HOME] -p /dev/raw/raw20 -n [DB_NAME] host [DB_HOME]/bin/srvctl add instance -d [DB_NAME] -i [ORACLE_SID1] -n [HOST_NAME1] host [DB_HOME]/bin/srvctl add instance -d [DB_NAME] -i [ORACLE_SID2] -n [HOST_NAME2] host [DB_HOME]/bin/srvctl disable database -d [DB_NAME] @[ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateDB.sql @[ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateDBFiles.sql @[ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateDBCatalog.sql @[ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateClustDBViews.sql host echo "SPFILE='/dev/raw/raw20'" > [DB_HOME]/dbs/init[ORACLE_SID1].ora @[ORACLE_BASE]/admin/[DB_NAME]/scripts/lockAccount.sql @[ORACLE_BASE]/admin/[DB_NAME]/scripts/postDBCreation.sql
set verify off ACCEPT sysPassword CHAR PROMPT 'Enter new password for SYS: ' HIDE ACCEPT systemPassword CHAR PROMPT 'Enter new password for SYSTEM: ' HIDE host /u01/app/oracle/product/11.2.0/db_1/bin/orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwracdb1 force=y host /u01/app/11.2.0/grid/bin/setasmgidwrap o=/u01/app/oracle/product/11.2.0/db_1/bin/oracle host /u01/app/oracle/product/11.2.0/db_1/bin/srvctl add database -d racdb -o /u01/app/oracle/product/11.2.0/db_1 -p /dev/raw/raw20 -n racdb host /u01/app/oracle/product/11.2.0/db_1/bin/srvctl add instance -d racdb -i racdb1 -n rac1 host /u01/app/oracle/product/11.2.0/db_1/bin/srvctl add instance -d racdb -i racdb2 -n rac2 host /u01/app/oracle/product/11.2.0/db_1/bin/srvctl disable database -d racdb @/u01/app/oracle/admin/racdb/scripts/CreateDB.sql @/u01/app/oracle/admin/racdb/scripts/CreateDBFiles.sql @/u01/app/oracle/admin/racdb/scripts/CreateDBCatalog.sql @/u01/app/oracle/admin/racdb/scripts/CreateClustDBViews.sql host echo "SPFILE='/dev/raw/raw20'" > /u01/app/oracle/product/11.2.0/db_1/dbs/initracdb1.ora @/u01/app/oracle/admin/racdb/scripts/lockAccount.sql @/u01/app/oracle/admin/racdb/scripts/postDBCreation.sql
CreateDB.sql
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool [ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateDB.log append startup nomount pfile="[ORACLE_BASE]/admin/[DB_NAME]/scripts/init.ora"; CREATE DATABASE "[DB_NAME]" MAXINSTANCES 32 MAXLOGHISTORY 1 MAXLOGFILES 192 MAXLOGMEMBERS 3 MAXDATAFILES 1024 DATAFILE '/dev/raw/raw6' SIZE 699M AUTOEXTEND OFF EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE '/dev/raw/raw7' SIZE 699M AUTOEXTEND OFF SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/dev/raw/raw9' SIZE 699M AUTOEXTEND OFF SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/dev/raw/raw10' SIZE 199M AUTOEXTEND OFF CHARACTER SET KO16MSWIN949 NATIONAL CHARACTER SET AL16UTF16 LOGFILE GROUP 1 ('/dev/raw/raw14') SIZE 199M, GROUP 2 ('/dev/raw/raw15') SIZE 199M, GROUP 3 ('/dev/raw/raw16') SIZE 199M USER SYS IDENTIFIED BY "&&sysPassword" USER SYSTEM IDENTIFIED BY "&&systemPassword"; spool off
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool /u01/app/oracle/admin/racdb/scripts/CreateDB.log append startup nomount pfile="/u01/app/oracle/admin/racdb/scripts/init.ora"; CREATE DATABASE "racdb" MAXINSTANCES 32 MAXLOGHISTORY 1 MAXLOGFILES 192 MAXLOGMEMBERS 3 MAXDATAFILES 1024 DATAFILE '/dev/raw/raw6' SIZE 699M AUTOEXTEND OFF EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE '/dev/raw/raw7' SIZE 699M AUTOEXTEND OFF SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/dev/raw/raw9' SIZE 699M AUTOEXTEND OFF SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/dev/raw/raw10' SIZE 199M AUTOEXTEND OFF CHARACTER SET KO16MSWIN949 NATIONAL CHARACTER SET AL16UTF16 LOGFILE GROUP 1 ('/dev/raw/raw14') SIZE 199M, GROUP 2 ('/dev/raw/raw15') SIZE 199M, GROUP 3 ('/dev/raw/raw16') SIZE 199M USER SYS IDENTIFIED BY "&&sysPassword" USER SYSTEM IDENTIFIED BY "&&systemPassword"; spool off
CreateDBFiles.sql
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool [ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateDBFiles.log append CREATE SMALLFILE UNDO TABLESPACE "UNDOTBS2" DATAFILE '/dev/raw/raw11' SIZE 699M AUTOEXTEND OFF; CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/dev/raw/raw8' SIZE 699M AUTOEXTEND OFF EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; ALTER DATABASE DEFAULT TABLESPACE "USERS"; spool off
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool /u01/app/oracle/admin/racdb/scripts/CreateDBFiles.log append CREATE SMALLFILE UNDO TABLESPACE "UNDOTBS2" DATAFILE '/dev/raw/raw11' SIZE 699M AUTOEXTEND OFF; CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/dev/raw/raw8' SIZE 699M AUTOEXTEND OFF EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; ALTER DATABASE DEFAULT TABLESPACE "USERS"; spool off
CreateDBCatalog.sql
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool [ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateDBCatalog.log append @[DB_HOME]/rdbms/admin/catalog.sql; @[DB_HOME]/rdbms/admin/catblock.sql; @[DB_HOME]/rdbms/admin/catproc.sql; @[DB_HOME]/rdbms/admin/catoctk.sql; @[DB_HOME]/rdbms/admin/owminst.plb; connect "SYSTEM"/"&&systemPassword" @[DB_HOME]/sqlplus/admin/pupbld.sql; connect "SYSTEM"/"&&systemPassword" set echo on spool [ORACLE_BASE]/admin/[DB_NAME]/scripts/sqlPlusHelp.log append @[DB_HOME]/sqlplus/admin/help/hlpbld.sql helpus.sql; spool off spool off
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool /u01/app/oracle/admin/racdb/scripts/CreateDBCatalog.log append @/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/catalog.sql; @/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/catblock.sql; @/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/catproc.sql; @/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/catoctk.sql; @/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/owminst.plb; connect "SYSTEM"/"&&systemPassword" @/u01/app/oracle/product/11.2.0/db_1/sqlplus/admin/pupbld.sql; connect "SYSTEM"/"&&systemPassword" set echo on spool /u01/app/oracle/admin/racdb/scripts/sqlPlusHelp.log append @/u01/app/oracle/product/11.2.0/db_1/sqlplus/admin/help/hlpbld.sql helpus.sql; spool off spool off
CreateClustDBViews.sql
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool [ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateClustDBViews.log append @[DB_HOME]/rdbms/admin/catclust.sql; spool off
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool /u01/app/oracle/admin/racdb/scripts/CreateClustDBViews.log append @/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/catclust.sql; spool off
lockAccount.sql
SET VERIFY OFF set echo on spool [ORACLE_BASE]/admin/[DB_NAME]/scripts/lockAccount.log append BEGIN FOR item IN ( SELECT USERNAME FROM DBA_USERS WHERE ACCOUNT_STATUS IN ('OPEN', 'LOCKED', 'EXPIRED') AND USERNAME NOT IN ( 'SYS','SYSTEM') ) LOOP dbms_output.put_line('Locking and Expiring: ' || item.USERNAME); execute immediate 'alter user ' || sys.dbms_assert.enquote_name( sys.dbms_assert.schema_name( item.USERNAME),false) || ' password expire account lock' ; END LOOP; END; / spool off
SET VERIFY OFF set echo on spool /u01/app/oracle/admin/racdb/scripts/lockAccount.log append BEGIN FOR item IN ( SELECT USERNAME FROM DBA_USERS WHERE ACCOUNT_STATUS IN ('OPEN', 'LOCKED', 'EXPIRED') AND USERNAME NOT IN ( 'SYS','SYSTEM') ) LOOP dbms_output.put_line('Locking and Expiring: ' || item.USERNAME); execute immediate 'alter user ' || sys.dbms_assert.enquote_name( sys.dbms_assert.schema_name( item.USERNAME),false) || ' password expire account lock' ; END LOOP; END; / spool off
postDBCreation.sql
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool [ORACLE_BASE]/admin/[DB_NAME]/scripts/postDBCreation.log append execute DBMS_AUTO_TASK_ADMIN.disable(); @[DB_HOME]/rdbms/admin/catbundle.sql psu apply; select 'utl_recomp_begin: ' || to_char(sysdate, 'HH:MI:SS') from dual; execute utl_recomp.recomp_serial(); select 'utl_recomp_end: ' || to_char(sysdate, 'HH:MI:SS') from dual; select group# from v$log where group# =3; select group# from v$log where group# =4; ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 4 ('/dev/raw/raw17') SIZE 199M, GROUP 5 ('/dev/raw/raw18') SIZE 199M, GROUP 6 ('/dev/raw/raw19') SIZE 199M; ALTER DATABASE ENABLE PUBLIC THREAD 2; host echo cluster_database=true >>[ORACLE_BASE]/admin/[DB_NAME]/scripts/init.ora; host echo remote_listener=[SCAN_NAME]:[LISTENER_PORT]>>[ORACLE_BASE]/admin/[DB_NAME]/scripts/init.ora; connect "SYS"/"&&sysPassword" as SYSDBA set echo on create spfile='/dev/raw/raw20' FROM pfile='[ORACLE_BASE]/admin/[DB_NAME]/scripts/init.ora'; shutdown immediate; host [DB_HOME]/bin/srvctl enable database -d [DB_NAME]; host [DB_HOME]/bin/srvctl start database -d [DB_NAME]; connect "SYS"/"&&sysPassword" as SYSDBA spool off exit;
SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool /u01/app/oracle/admin/racdb/scripts/postDBCreation.log append execute DBMS_AUTO_TASK_ADMIN.disable(); @/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/catbundle.sql psu apply; select 'utl_recomp_begin: ' || to_char(sysdate, 'HH:MI:SS') from dual; execute utl_recomp.recomp_serial(); select 'utl_recomp_end: ' || to_char(sysdate, 'HH:MI:SS') from dual; select group# from v$log where group# =3; select group# from v$log where group# =4; ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 4 ('/dev/raw/raw17') SIZE 199M, GROUP 5 ('/dev/raw/raw18') SIZE 199M, GROUP 6 ('/dev/raw/raw19') SIZE 199M; ALTER DATABASE ENABLE PUBLIC THREAD 2; host echo cluster_database=true >>/u01/app/oracle/admin/racdb/scripts/init.ora; host echo remote_listener=rac-scan:1521>>/u01/app/oracle/admin/racdb/scripts/init.ora; connect "SYS"/"&&sysPassword" as SYSDBA set echo on create spfile='/dev/raw/raw20' FROM pfile='/u01/app/oracle/admin/racdb/scripts/init.ora'; shutdown immediate; host /u01/app/oracle/product/11.2.0/db_1/bin/srvctl enable database -d racdb; host /u01/app/oracle/product/11.2.0/db_1/bin/srvctl start database -d racdb; connect "SYS"/"&&sysPassword" as SYSDBA spool off exit;
init.ora
############################################################################## # Copyright (c) 1991, 2001, 2002 by Oracle Corporation ############################################################################## ########################################### # Cache and I/O ########################################### db_block_size=8192 ########################################### # Cluster Database ########################################### #cluster_database=true #remote_listener=[SCAN_NAME]:[LISTENER_PORT] ########################################### # Cursors and Library Cache ########################################### open_cursors=300 ########################################### # Database Identification ########################################### db_domain="" db_name="[DB_NAME]" ########################################### # File Configuration ########################################### control_files=('/dev/raw/raw12','/dev/raw/raw13') ########################################### # Miscellaneous ########################################### compatible=11.2.0.0.0 diagnostic_dest=[ORACLE_BASE] memory_target=834666496 ########################################### # Processes and Sessions ########################################### processes=150 ########################################### # Security and Auditing ########################################### audit_file_dest="[ORACLE_BASE]/admin/[DB_NAME]/adump" audit_trail=db remote_login_passwordfile=exclusive [ORACLE_SID1].instance_number=1 [ORACLE_SID2].instance_number=2 [ORACLE_SID1].thread=1 [ORACLE_SID2].thread=2 [ORACLE_SID1].undo_tablespace=UNDOTBS1 [ORACLE_SID2].undo_tablespace=UNDOTBS2
############################################################################## # Copyright (c) 1991, 2001, 2002 by Oracle Corporation ############################################################################## ########################################### # Cache and I/O ########################################### db_block_size=8192 ########################################### # Cluster Database ########################################### #cluster_database=true #remote_listener=rac-scan:1521 ########################################### # Cursors and Library Cache ########################################### open_cursors=300 ########################################### # Database Identification ########################################### db_domain="" db_name="racdb" ########################################### # File Configuration ########################################### control_files=('/dev/raw/raw12','/dev/raw/raw13') ########################################### # Miscellaneous ########################################### compatible=11.2.0.0.0 diagnostic_dest=/u01/app/oracle memory_target=834666496 ########################################### # Processes and Sessions ########################################### processes=150 ########################################### # Security and Auditing ########################################### audit_file_dest="/u01/app/oracle/admin/racdb/adump" audit_trail=db remote_login_passwordfile=exclusive racdb1.instance_number=1 racdb2.instance_number=2 racdb1.thread=1 racdb2.thread=2 racdb1.undo_tablespace=UNDOTBS1 racdb2.undo_tablespace=UNDOTBS2
racdb2.sh
#!/bin/sh OLD_UMASK=`umask` umask 0027 mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/adump mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/dpdump mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/hdump mkdir -p [ORACLE_BASE]/admin/[DB_NAME]/pfile mkdir -p [ORACLE_BASE]/cfgtoollogs/dbca/[DB_NAME] umask ${OLD_UMASK} ORACLE_SID=[ORACLE_SID2]; export ORACLE_SID PATH=$ORACLE_HOME/bin:$PATH; export PATH echo You should Add this entry in the /etc/oratab: [DB_NAME]:[DB_HOME]:Y [DB_HOME]/bin/sqlplus /nolog @[ORACLE_BASE]/admin/[DB_NAME]/scripts/racdb2.sql
racdb2.sql
set verify off ACCEPT sysPassword CHAR PROMPT 'Enter new password for SYS: ' HIDE ACCEPT systemPassword CHAR PROMPT 'Enter new password for SYSTEM: ' HIDE host [DB_HOME]/bin/orapwd file=[DB_HOME]/dbs/orapw[ORACLE_SID2] force=y host [GRID_HOME]/bin/setasmgidwrap o=[DB_HOME]/bin/oracle REM host [DB_HOME]/bin/srvctl add database -d [DB_NAME] -o [DB_HOME] -p /dev/raw/raw20 -n [DB_NAME] REM host [DB_HOME]/bin/srvctl add instance -d [DB_NAME] -i [ORACLE_SID1] -n [HOST_NAME1] REM host [DB_HOME]/bin/srvctl add instance -d [DB_NAME] -i [ORACLE_SID2] -n [HOST_NAME2] REM host [DB_HOME]/bin/srvctl disable database -d [DB_NAME] REM @[ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateDB.sql REM @[ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateDBFiles.sql REM @[ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateDBCatalog.sql REM @[ORACLE_BASE]/admin/[DB_NAME]/scripts/CreateClustDBViews.sql host echo "SPFILE='/dev/raw/raw20'" > [DB_HOME]/dbs/init[ORACLE_SID2].ora host echo Run script "[DB_HOME]/admin/[DB_NAME]/scripts/racdb1.sh" from node "[HOST_NAME1]" if you have not already run it. REM @[ORACLE_BASE]/admin/[DB_NAME]/scripts/lockAccount.sql REM @[ORACLE_BASE]/admin/[DB_NAME]/scripts/postDBCreation.sql