강좌
클라우드/리눅스에 관한 강좌입니다.
데이터베이스 분류

Oracle Database 생성(8.1.7)

작성자 정보

  • 웹관리자 작성
  • 작성일

컨텐츠 정보

본문

Oracle Database 생성(8.1.7)

 

작성자  : 강명규
OS      : LINUX kernel 2.4.18(x86)
ORACLE  : 8i(8.1.7) EE

이번에 DB생성은 8i환경에서 다른 설치옵션(InterMedia, JServer,..)을 모두 제거한 상태에서
svrmgrl에서 수행했다. 기존에 작성한 글은 오라클 8버전을 기준으로 했기 때문에 현재 많이
사용하고 있는 8i버전에 대해 재작성한 것이다.

본인이 테스트용도로 생성하는 DB이기 때문에 되도록 리소스절약을 위주로 설정하여 설치했다.
설치시 환경은 다음과 같다.

메모리: 160MB
CPU   : Celeron (Mendocino) 400
DISK  : Free Space 950MB

ORACLE_BASE: /u01/app/oracle
ORACLE_HOME: /u01/app/oracle/product/8.17
ORACLE_SID : db

보다시피 상당히 서버라고 하기엔 열악하다.
설치시 1GB의 디스크 여유공간을 요구하는 dbassist를 사용하면 위의 환경에서 DB생성은 불가하다.
나는 dbassist를 사용하여 db생성 스크립트를 만들었고, 그 결과로 다음과 같은 파일이 생성되었다.

[initdb.ora]

db_name = "db"
db_domain = dbakorea.pe.kr

instance_name = db

service_names = db.dbakorea.pe.kr


control_files = ("/u01/app/oracle/oradata/db/control01.ctl",
"/u01/app/oracle/oradata/db/control02.ctl") open_cursors = 300 max_enabled_roles = 30 db_block_buffers = 2048 shared_pool_size = 4194304 large_pool_size = 614400 java_pool_size = 0 log_checkpoint_interval = 10000 log_checkpoint_timeout = 1800 processes = 150 log_buffer = 163840 # audit_trail = false # if you want auditing # timed_statistics = false # if you want timed statistics # max_dump_file_size = 10000 # limit trace file size to 5M each # Uncommenting the lines below will cause automatic archiving if archiving has # been enabled using ALTER DATABASE ARCHIVELOG. # log_archive_start = true # log_archive_dest_1 = "location=/u01/app/oracle/admin/db/arch" # log_archive_format = arch_%t_%s.arc # If using private rollback segments, place lines of the following # form in each of your instance-specific init.ora files: #rollback_segments = ( RBS0, RBS1, RBS2, RBS3, RBS4, RBS5, RBS6 ) # Global Naming -- enforce that a dblink has same name as the db it connects to # global_names = false # 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 # define directories to store trace and alert files background_dump_dest = /u01/app/oracle/admin/db/bdump core_dump_dest = /u01/app/oracle/admin/db/cdump #Uncomment this parameter to enable resource management for your database. #The SYSTEM_PLAN is provided by default with the database. #Change the plan name if you have created your own resource plan.
# resource_manager_plan = system_plan user_dump_dest = /u01/app/oracle/admin/db/udump db_block_size = 4096 remote_login_passwordfile = exclusive os_authent_prefix = "" compatible = "8.0.5" sort_area_size = 65536 sort_area_retained_size = 65536
dbcreate.sh
[dbcreate.sh]

#!/bin/sh
ORACLE_SID=db
export ORACLE_SID


ORACLE_HOME=/u01/app/oracle/product/8.1.7
export ORACLE_HOME

/u01/app/oracle/product/8.1.7/install/dbrun.sh
/u01/app/oracle/product/8.1.7/install/dbrun1.sh
/u01/app/oracle/product/8.1.7/install/dbrun2.sh
/u01/app/oracle/product/8.1.7/install/dbalterTablespace.sh
dbrun.sh
[dbrun.sh]

#!/bin/sh
ORACLE_SID=db
export ORACLE_SID

/u01/app/oracle/product/8.1.7/bin/svrmgrl << EOF
spool /u01/app/oracle/admin/db/create/crdb1.log
connect internal
startup nomount pfile = "/u01/app/oracle/admin/db/pfile/initdb.ora"
CREATE DATABASE "db"
   maxdatafiles 254
   maxinstances 8
   maxlogfiles 32
   character set KO16KSC5601
   national character set US7ASCII
DATAFILE '/u01/app/oracle/oradata/db/system01.dbf' SIZE 150M AUTOEXTEND ON NEXT 10240K
logfile '/u01/app/oracle/oradata/db/redo01.log' SIZE 500K, 
    '/u01/app/oracle/oradata/db/redo02.log' SIZE 500K, 
    '/u01/app/oracle/oradata/db/redo03.log' SIZE 500K;
disconnect
spool off
exit


EOF
[dbrun1.sh]

#!/bin/sh
ORACLE_SID=db
export ORACLE_SID

/u01/app/oracle/product/8.1.7/bin/svrmgrl << EOF
spool /u01/app/oracle/admin/db/create/crdb2.log
connect internal
@/u01/app/oracle/product/8.1.7/rdbms/admin/catalog.sql;

REM ********** ALTER SYSTEM TABLESPACE *********
ALTER TABLESPACE SYSTEM
DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 50);
ALTER TABLESPACE SYSTEM
MINIMUM EXTENT 64K;

REM ********** TABLESPACE FOR Tool **********
CREATE TABLESPACE TOOLS DATAFILE '/u01/app/oracle/oradata/db/tools01.dbf' SIZE 8M REUSE
 AUTOEXTEND ON NEXT 320K
MINIMUM EXTENT 32K
DEFAULT STORAGE ( INITIAL 32K NEXT 32K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0);

REM ********** TABLESPACE FOR ROLLBACK **********
CREATE TABLESPACE RBS DATAFILE '/u01/app/oracle/oradata/db/rbs01.dbf' SIZE 50M REUSE
 AUTOEXTEND ON NEXT 5120K
MINIMUM EXTENT 512K
DEFAULT STORAGE ( INITIAL 512K NEXT 512K MINEXTENTS 8 MAXEXTENTS 4096);

REM ********** TABLESPACE FOR TEMPORARY **********
CREATE TABLESPACE TEMP DATAFILE '/u01/app/oracle/oradata/db/temp01.dbf' SIZE 50M REUSE
 AUTOEXTEND ON NEXT 640K
MINIMUM EXTENT 64K
DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)
TEMPORARY; REM ********** TABLESPACE FOR USER ********** CREATE TABLESPACE USERS DATAFILE '/u01/app/oracle/oradata/db/users01.dbf' SIZE 50M REUSE AUTOEXTEND ON NEXT 1280K MINIMUM EXTENT 128K DEFAULT STORAGE ( INITIAL 128K NEXT 128K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0); REM ********** TABLESPACE FOR INDEX ********** CREATE TABLESPACE INDX DATAFILE '/u01/app/oracle/oradata/db/indx01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 1280K MINIMUM EXTENT 128K DEFAULT STORAGE ( INITIAL 128K NEXT 128K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0); REM **** Creating four rollback segments **************** CREATE PUBLIC ROLLBACK SEGMENT RBS0 TABLESPACE RBS STORAGE ( OPTIMAL 4096K ); CREATE PUBLIC ROLLBACK SEGMENT RBS1 TABLESPACE RBS STORAGE ( OPTIMAL 4096K ); CREATE PUBLIC ROLLBACK SEGMENT RBS2 TABLESPACE RBS STORAGE ( OPTIMAL 4096K ); CREATE PUBLIC ROLLBACK SEGMENT RBS3 TABLESPACE RBS STORAGE ( OPTIMAL 4096K ); CREATE PUBLIC ROLLBACK SEGMENT RBS4 TABLESPACE RBS STORAGE ( OPTIMAL 4096K ); CREATE PUBLIC ROLLBACK SEGMENT RBS5 TABLESPACE RBS STORAGE ( OPTIMAL 4096K ); CREATE PUBLIC ROLLBACK SEGMENT RBS6 TABLESPACE RBS STORAGE ( OPTIMAL 4096K ); ALTER ROLLBACK SEGMENT "RBS0" ONLINE; ALTER ROLLBACK SEGMENT "RBS1" ONLINE; ALTER ROLLBACK SEGMENT "RBS2" ONLINE; ALTER ROLLBACK SEGMENT "RBS3" ONLINE; ALTER ROLLBACK SEGMENT "RBS4" ONLINE; ALTER ROLLBACK SEGMENT "RBS5" ONLINE; ALTER ROLLBACK SEGMENT "RBS6" ONLINE; REM **** SYS and SYSTEM users **************** alter user sys temporary tablespace TEMP; alter user system temporary tablespace TEMP; disconnect spool off exit EOF
[dbrun2.sh]

#!/bin/sh
ORACLE_SID=db
export ORACLE_SID

/u01/app/oracle/product/8.1.7/bin/svrmgrl << EOF
spool /u01/app/oracle/admin/db/create/crdb3.log
connect internal
@/u01/app/oracle/product/8.1.7/rdbms/admin/catproc.sql
@/u01/app/oracle/product/8.1.7/rdbms/admin/caths.sql
@/u01/app/oracle/product/8.1.7/rdbms/admin/otrcsvr.sql
connect system/manager
@/u01/app/oracle/product/8.1.7/sqlplus/admin/pupbld.sql

disconnect
spool off
exit


EOF
[dbalterTablespace.sh]

#!/bin/sh
ORACLE_SID=db
export ORACLE_SID

/u01/app/oracle/product/8.1.7/bin/svrmgrl << EOF
connect internal/oracle
alter user system default tablespace TOOLS;
alter user system temporary tablespace TEMP;

EOF
사실 위의 내용이 전부고 별달리 설명할 것은 없다. 그냥 쉘상에서 dbcreate.sh를 수행해주면 된다. 각 파일이 하는 내용을 보자. dbcreate.sh 환경변수 ORACLE_SID, ORACLE_HOME를 설정 dbrun.sh -> dbrun1.sh -> dbrun2.sh -> dbalterTablespace.sh순으로 실행 dbrun.sh create database문 수행 $ORACLE_BASE/admin/db/create/crdb1.log에 실행로그가 기록됨 system tablespace의 datafile 크기를 260MB에서 150MB로 변경했음 dbrun1.sh $ORACLE_HOME/rdbms/admin/catalog.sql 수행 system 테이블스페이스의 저장옵션 변경 system 을 제외한 나머지 테이블스페이스 생성(system 테이블스페이스는 create database시 수행됨) 롤백세그먼트생성 sys, system사용자의 임시 tablespace를 TEMP tablespace로 설정 $ORACLE_BASE/admin/db/create/crdb2.log에 실행로그가 기록됨 RBS tablespace의 datafile 크기를 516MB에서 50MB로 변경 TEMP tablespace의 datafile 크기를 68MB에서 50MB로 변경 USERS tablespace의 datafile 크기를 104MB에서 50MB로 변경 INDX tablespace의 datafile 크기를 54MB에서 10MB로 변경 USERS,INDX는 사실 필수로 생성해야할 tablespace는 아니다. 내키지 않으면 설치하지 않아도 상관없다. dbrun2.sh /u01/app/oracle/admin/db/create/crdb3.log에 실행로그가 기록됨 sys유저로 아래의 스크립트 수행 $ORACLE_HOME/rdbms/admin/catproc.sql $ORACLE_HOME/rdbms/admin/caths.sql $ORACLE_HOME/rdbms/admin/otrcsvr.sql system유저로 아래의 스크립트 수행 $ORACLE_HOME/sqlplus/admin/pupbld.sql dbalterTablespace.sh system사용자의 default tablespace를 tools, temporary tablespace를 temp로 설정 [수행과정] dbcreate.sh만 실행하면 나머지 과정은 알아서 처리한다. 시스템에 따라 다르겠지만, 1시간정도 걸리니 다른 일을 하고 있는 것이 좋을 것이다. (나의 경우 30분 정도 걸렸다.) MS-SQL, MySQL, DB2등 다른 DBMS에 비해 오라클은 DB생성시간이 수십배 걸린다. [oracle@ns install]$ ./dbcreate.sh [마무리 작업] 오라클환경변수 설정 /etc/profile.d/myset.sh라는 파일을 만들어 755권한으로 실행가능하도록 변경하고 다음의 내용으로 설정하면 다음 로그인부터 자동으로 오라클 환경설정이 이루어진다. # Setting for Oracle export ORACLE_SID=db export ORACLE_OWNER=oracle export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/8.1.7 export ORACLE_DOC=$ORACLE_HOME/doc export NLS_LANG=AMERICAN_AMERICA.KO16KSC5601 export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data export TNS_ADMIN=$ORACLE_HOME/network/admin export EDITOR=vi export PATH=$PATH:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib system,sys사용자의 암호를 변경, 사용자 생성과 테이블 생성 [oracle@ns 8.1.7]$ sqlplus sys/change_on_install SQL*Plus: Release 8.1.7.0.0 - Production on Sun Apr 28 15:26:53 2002 (c) Copyright 2000 Oracle Corporation. All rights reserved. Connected to: Oracle8i Enterprise Edition Release 8.1.7.0.1 - Production With the Partitioning option JServer Release 8.1.7.0.1 - Production SQL> password Changing password for SYS Old password: New password: Retype new password: SQL> conn system/manager Connected. SQL> password Changing password for SYSTEM Old password: New password: Retype new password: SQL> create user kang identified by xxxxxx 2 default tablespace users 3 temporary tablespace temp; User created. SQL> grant connect,resource to kang; Grant succeeded. SQL> conn kang/xxxxxx Connected. SQL> create table test 2 ( 3 id varchar(10), 4 name varchar(10) 5 ); Table created. SQL> insert into test values('maddog', '강명규'); 1 row created. SQL> commit; Commit complete. SQL> select * from test; ID NAME ---------- ---------- maddog 강명규 SQL> quit Disconnected from Oracle8i Enterprise Edition Release 8.1.7.0.1 - Production With the Partitioning option JServer Release 8.1.7.0.1 - Production [oracle@ns 8.1.7]$ 이상으로 오라클 8i에서 간단한 DB생성을 다루었다. 실제 여러가지 설치옵션을 제거한 것이므로 이를 고려하기를 바란다. Copyleft(C) 명규의 DBAKOREA All rights free

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,041 명
  • 현재 강좌수 :  35,855 개
  • 현재 접속자 :  105 명