다음 이전 차례

3. 데이터베이스 생성

Oracle서버를 설치한 지금부터 설치를 시험할 데이터베이스를 설치할 필요가 있다. 만약 Oracle 7.2.x나 이전 버전을 사용한다면, 아래부분에 있는 문제해결지침을 읽기바란다.

3.1 설치관련 파일 설치

$ORACLE_HOME/dbs/init.ora를 $ORACLE_HOME/dbs/initorcl.ora로 복사한다.


        $ cd $ORACLE_HOME/dbs
        $ cp init.ora initorcl.ora

다음줄을 생성한 파일에 추가한다.
        db_name = orcl
        COMPATIBLE=7.3.3.0.0

3.2 데이터베이스 설치 스크립트를 생성

$ORACLE_HOME/dbs디렉토리에 makedb.sql의 이름으로 파일을 생성한다.


        connect internal
        startup nomount
        set echo on
        spool makedb.log
        create database orcl
               maxinstances 1
               maxlogfiles  8
               datafile '$ORACLE_HOME/dbs/orcl_syst_01.dbf' size 40M reuse
               logfile
                       '$ORACLE_HOME/dbs/orcl_redo_01.dbf' size 1M reuse,
                       '$ORACLE_HOME/dbs/orcl_redo_02.dbf' size 1M reuse,
                       '$ORACLE_HOME/dbs/orcl_redo_03.dbf' size 1M reuse;
       @$ORACLE_HOME/rdbms/admin/catalog.sql
       create tablespace rollback
               datafile '$ORACLE_HOME/dbs/orcl_roll_01.dbf' size 8.5M reuse;
       create tablespace temp
               datafile '$ORACLE_HOME/dbs/orcl_temp_01.dbf' size 5M reuse
               temporary;
       create tablespace users
               datafile '$ORACLE_HOME/dbs/orcl_user_01.dbf' size 10M reuse;
       create rollback segment r1 tablespace rollback storage ( optimal 5M );
       alter rollback segment r1 online;
       connect system/manager
       @$ORACLE_HOME/rdbms/admin/catdbsyn.sql
       connect internal
       @$ORACLE_HOME/rdbms/admin/catproc.sql
       connect system/manager
       @$ORACLE_HOME/sqlplus/admin/pupbld.sql
       spool off
       exit

3.3 데이터베이스 설치 스크립트를 실행

svrmgrl명령을 수행한 후 스크립트를 실행한다.


        $ cd $ORACLE_HOME/dbs
        $ svrmgrl
        Oracle Server Manager Release 2.3.3.0.0 - Production
        Copyright (c) Oracle Corporation 1994, 1995. All rights reserved.
        Oracle7 Server Release 7.3.3.0.0 - Production Release
        PL/SQL Release 2.3.3.0.0 - Production
        SVRMGR> connect internal
        Connected.
        SVRMGR> startup nomount
        ORACLE instance started.
        Total System Global Area       4313312 bytes
        Fixed Size                       41876 bytes
        Variable Size                  4140364 bytes
        Database Buffers                122880 bytes
        Redo Buffers                      8192 bytes
        SVRMGR> @makedb
        <loads of messages>
        SVRMGR> exit
        Server Manager complete.

3.4 데이터베이스 구동시키기

우선은 수동으로(이후에는 자동으로 구동될 것이다.)데이터베이스를 구동시킬필요가 있다. Oracle 데이터베이스를 시작하기위해서는 "connect internal"을 한후에 "startup"이라는 command를 실행해야 한다.


       $ svrmgrl
      Oracle Server Manager Release 2.3.3.0.0 - Production
      Copyright (c) Oracle Corporation 1994, 1995. All rights reserved.
      Oracle7 Server Release 7.3.3.0.0 - Production Release
       PL/SQL Release 2.3.3.0.0 - Production
      SVRMGR> connect internal
       Connected.
       SVRMGR> startup
       ORACLE instance started.
       Total System Global Area       4313316 bytes
       Fixed Size                       41876 bytes
       Variable Size                  4140368 bytes
       Database Buffers                122880 bytes
       Redo Buffers                      8192 bytes
       Database mounted.
       Database opened.
       SVRMGR> exit
       Server Manager complete.

3.5 데이터베이스 중지시키기

Oracle데이터베이스를 중지시키기않고 Linux서버를 재실행시키는 것은 데이터베이스를 파괴시킬 수 있는 큰 위험이 있다는 것을 명심해야 한다. 그러므로,Linux shutdown명령을 사용하기전에 데이터베이스를 중지시키는 것이 바람직한것이다.


       $ svrmgrl
      Oracle Server Manager Release 2.3.3.0.0 - Production
      Copyright (c) Oracle Corporation 1994, 1995. All rights reserved.
      Oracle7 Server Release 7.3.3.0.0 - Production Release
       PL/SQL Release 2.3.3.0.0 - Production
      SVRMGR> connect internal
       Connected.
       SVRMGR> shutdown
       Database closed.
       Database dismounted.
       ORACLE instance shut down.
       SVRMGR> exit
       Server Manager complete.

3.6 기본사용자 생성

데이터베이스가 생성되면서 자동적으로 두 개의 특별한 사용자계정이 생성된다. 다음에 그 부분을 명시한다.


       Username                Password
      SYSTEM                  MANAGER
       SYS                     change_on_install

이러한 사용자계정은 전형적으로 데이터베이스를 위한 기본적인 데이터딕셔너리정보를 유지하기 위한 것이다. 가능한한 빠른시간내에 기본적인으로 지정된 암호를 바꾸는 것이 좋다. 이러한 부분을 다음과 같은 과정으로 변경된다.
        sqlplus system/manager
        SQL*Plus: Release 3.3.3.0.0 - Production on Sat Feb 21 12:43:33 1998
        Copyright (c) Oracle Corporation 1979, 1996.  All rights reserved.

        Connected to:
        Oracle7 Server Release 7.3.3.0.0 - Production Release
        SQL> alter user system identified by <newpassword>;
        User altered.
        SQL> alter user sys identified by <newpassword>;
        User altered.
        SQL> exit;
        Disconnected from Oracle7 Server Release 7.3.3.0.0 - Production Release
        PL/SQL Release 2.3.3.0.0 - Production

system/manager라는 Oracle 사용자 계정은 UNIX시스템에서의 root를 사용하는 것과 유사하기 때문에 우리는 문제를 발생시키는 것을 최소화하기 위해 되도록 적은 권한을 갖는 사용자를 생성할 필요가 있다. (사용자를 생성하기 전에 데이터베이스를 실행시키는 것을 기억하라) SQL*PLUS에 연결하고 사용자를 생성한다.
       $ sqlplus system/manager
      SQL*Plus: Release 3.3.3.0.0 - Production on Sat Feb 21 12:43:33 1998
      Copyright (c) Oracle Corporation 1979, 1996.  All rights reserved.

      Connected to:
       Oracle7 Server Release 7.3.3.0.0 - Production Release
       PL/SQL Release 2.3.3.0.0 - Production
      SQL> create user <user> identified by <psw>
         2  default tablespace users
         3  temporary tablespace temp;
      User created.
      SQL> grant connect, resource to <user>
      Grant succeeded.
      SQL> exit
       Disconnected from Oracle7 Server Release 7.3.3.0.0 - Production Release
       PL/SQL Release 2.3.3.0.0 - Production

시스템에 새로운 사용자계정을 생성하였기 때문에 새로운 계정을 가지고 시스템에 로그인 할수 있다. Oracle데이터베이스에 로그인하기 위해서는 다음과 같다.
       $ sqlplus <user>/<password>

이부분이 에러메세지없이 수행된다면, 성공적으로 오라클 데이타베이스를 설치한것이다. 이 서버가 아닌 다른 호스트에서 이 오라클 데이타베이스에 접근 하지 않는다면 모든 작업은 완료된것이다. 그러나, 대부분 사람들은 네트워크를 이용하여 원격으로 데이타베이스 서버에 접속하길 원할것이다. 그렇게 하기 위해서는 다음과 같은 과정을 수행해야한다.
다음 이전 차례