Create a Database With Command Line

手動データベースを作成する手順:
1. ocm.sh

mkdir -p /u01/app/oracle/admin/ocm/adump
mkdir -p /u01/app/oracle/admin/ocm/bdump
mkdir -p /u01/app/oracle/admin/ocm/cdump
mkdir -p /u01/app/oracle/admin/ocm/dpdump
mkdir -p /u01/app/oracle/admin/ocm/pfile
mkdir -p /u01/app/oracle/admin/ocm/udump
mkdir -p /u01/app/oracle/flash_recovery_area
mkdir -p /u01/app/oracle/oradata/ocm
mkdir -p /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/dbca/ocm
mkdir -p /u01/app/oracle/product/10.2.0/db_1/dbs
ORACLE_SID=ocm; export ORACLE_SID
echo You should Add this entry in the /etc/oratab: ocm:/u01/app/oracle/product/10.2.0/db_1:Y
/u01/app/oracle/product/10.2.0/db_1/bin/sqlplus /nolog @/u01/app/oracle/admin/ocm/scripts/ocm.sql

2. ocm.sql
set verify off
PROMPT specify a password for sys as parameter 1;
DEFINE sysPassword = &1
PROMPT specify a password for system as parameter 2;
DEFINE systemPassword = &2
PROMPT specify a password for sysman as parameter 3;
DEFINE sysmanPassword = &3
PROMPT specify a password for dbsnmp as parameter 4;
DEFINE dbsnmpPassword = &4
host /u01/app/oracle/product/10.2.0/db_1/bin/orapwd file=/u01/app/oracle/product/10.2.0/db_1/dbs/orapwocm password=&&sysPassword force=y
@/u01/app/oracle/admin/ocm/scripts/CreateDB.sql
@/u01/app/oracle/admin/ocm/scripts/CreateDBFiles.sql
@/u01/app/oracle/admin/ocm/scripts/CreateDBCatalog.sql
@/u01/app/oracle/admin/ocm/scripts/emRepository.sql
@/u01/app/oracle/admin/ocm/scripts/postDBCreation.sql

3. CreateDB.sql

connect "SYS"/"&&sysPassword" as SYSDBA
set echo on
spool /u01/app/oracle/admin/ocm/scripts/CreateDB.log
startup nomount pfile="/u01/app/oracle/admin/ocm/scripts/init.ora";
CREATE DATABASE "ocm"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
DATAFILE '/u01/app/oracle/oradata/ocm/system01.dbf' SIZE 300M REUSE AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/oradata/ocm/sysaux01.dbf' SIZE 120M REUSE AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/app/oracle/oradata/ocm/temp01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT  640K MAXSIZE UNLIMITED
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u01/app/oracle/oradata/ocm/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT  5120K MAXSIZE UNLIMITED
CHARACTER SET WE8ISO8859P1
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/ocm/redo01.log') SIZE 51200K,
GROUP 2 ('/u01/app/oracle/oradata/ocm/redo02.log') SIZE 51200K,
GROUP 3 ('/u01/app/oracle/oradata/ocm/redo03.log') SIZE 51200K
USER SYS IDENTIFIED BY "&&sysPassword" USER SYSTEM IDENTIFIED BY "&&systemPassword";
spool off

4. CreateDBFiles.sql

connect "SYS"/"&&sysPassword" as SYSDBA
set echo on
spool /u01/app/oracle/admin/ocm/scripts/CreateDBFiles.log
CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/u01/app/oracle/oradata/ocm/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT  AUTO;
ALTER DATABASE DEFAULT TABLESPACE "USERS";
spool off

5. CreateDBCatalog.sql

onnect "SYS"/"&&sysPassword" as SYSDBA
set echo on
spool /u01/app/oracle/admin/ocm/scripts/CreateDBCatalog.log
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catalog.sql;
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catblock.sql;
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catproc.sql;
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catoctk.sql;
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/owminst.plb;
connect "SYSTEM"/"&&systemPassword"
@/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/pupbld.sql;
connect "SYSTEM"/"&&systemPassword"
set echo on
spool /u01/app/oracle/product/10.2.0/admin/ocm/scripts/sqlPlusHelp.log
@/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/help/hlpbld.sql helpus.sql;
spool off
spool off

6. emRepository.sql

connect "SYS"/"&&sysPassword" as SYSDBA
set echo off
spool /u01/app/oracle/admin/ocm/scripts/emRepository.log
@/u01/app/oracle/product/10.2.0/db_1/sysman/admin/emdrep/sql/emreposcre /u01/app/oracle/product/10.2.0/db_1 SYSMAN &&sysmanPassword TEMP ON;
WHENEVER SQLERROR CONTINUE;
spool off
spool off

7. postDBCreation.sql

connect "SYS"/"&&sysPassword" as SYSDBA
set echo on
spool /u01/app/oracle/admin/ocm/scripts/postDBCreation.log
shutdown immediate;
connect "SYS"/"&&sysPassword" as SYSDBA
startup mount pfile="/u01/app/oracle/admin/ocm/scripts/init.ora";
alter database archivelog;
alter database open;
connect "SYS"/"&&sysPassword" as SYSDBA
set echo on
create spfile='/u01/app/oracle/product/10.2.0/db_1/dbs/spfileocm.ora' FROM pfile='/u01/app/oracle/admin/ocm/scripts/init.ora';
shutdown immediate;
connect "SYS"/"&&sysPassword" as SYSDBA
startup ;
alter user SYSMAN identified by "&&sysmanPassword" account unlock;
alter user DBSNMP identified by "&&dbsnmpPassword" account unlock;
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;
host /u01/app/oracle/product/10.2.0/db_1/bin/emca -config dbcontrol db -silent -DB_UNIQUE_NAME ocm -PORT 1521 -EM_HOME /u01/app/oracle/product/10.2.0/db_1 -LISTENER LISTENER -SERVICE_NAME ocm.localdomain -SYS_PWD &&sysPassword -SID ocm -ORACLE_HOME /u01/app/oracle/product/10.2.0/db_1 -DBSNMP_PWD &&dbsnmpPassword -HOST OCM.localdomain -LISTENER_OH /u01/app/oracle/product/10.2.0/db_1 -LOG_FILE /u01/app/oracle/admin/ocm/scripts/emConfig.log -SYSMAN_PWD &&sysmanPassword;
spool /u01/app/oracle/admin/ocm/scripts/postDBCreation.log
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License