본문 바로가기

DBMS/DB2

CentOS에 DB2 설치하기

-설치전 준비사항-


DB2를 설치하기 전에 설치파일을 다운로드 받는다


-설치파일 다운로드-


다운로드 경로 : https://www-01.ibm.com/marketing/iwm/iwm/web/pick.do?source=swg-db2expressc&lang=ko_KR&S_CMP=ECDDWW01&S_TACT=AC_04_KO


테스트용 서버를 설치하기 위해 IBM DB2 Express-C 설치파일을 받아 진행하고자한다.

4번. Linux x86-64용 DB2 Express-C 선택 후 간단한 정보를 입력하면 설치파일을 받을 수 있다.


db2_v101_linuxx64_expc.tar.gz 파일을 받아 준비한다.


-설치 시작-


1. 유저생성 및 패스워드 지정


DB2를 사용할 유저와 패스워드를 지정한다.


[root@server1 ~]# groupadd dba

[root@server1 ~]# useradd -d /db2 -g dba db2

[root@server1 ~]# passwd db2


2. 파일 업로드 및 압축 해제


다운로드받은 설치파일을 업로드 한 뒤 압축을 해제하여준다.


[root@server1 ~]# su - db2

[db2@server1 ~]$ ls

db2_v101_linuxx64_expc.tar.gz

[db2@server1 ~]$ gunzip db2_v101_linuxx64_expc.tar.gz 

[db2@server1 ~]$ tar -xvf db2_v101_linuxx64_expc.tar 


    3. 환경변수 설정 및 Install 실행


환경변수를 한글로 변경하고 압축을 해제한 폴더에서 db2_install 을 실행한다.


[db2@server1 ~]$ export LANG=ko

[db2@server1 ~]$ cd expc

[db2@server1 expc]$ ./db2_install 

DBI1324W  db2_install 명령이 지원되지 않습니다. 자세한 정

      보는 DB2 정보 센터를 참조하십시오.



DBI1244I  DB2의 루트가 아닌 사용자 설치 디렉토리 - /db2/sqllib



DBI1160I  루트가 아닌 사용자 설치가 수행 중입니다.



DB2 설치가 초기화되고 있습니다.


 수행할 총 태스크 수: 33 

수행할 모든 태스크에 대해 계산된 총 시간: 1480초 


태스크 #1 시작

설명: 라이센스 계약 승인 검사 

계산된 시간 1초 

태스크 #1 종료 


태스크 #2 시작

설명: 루트 권한이 없는 설치를 위한 기본 클라이언트 지원 

계산된 시간 3초 

태스크 #2 종료 


.....


실행이 완료되었습니다.


자세한 정보는 "/tmp/db2_install_db2.log"에서 DB2 설치 로그를 참조하십시오.


DBI1272I  DB2 인스턴스 db2을(를) 사용하여 시작하

      려면 sqllib 디렉토리에서 db2profile 또는 db2cshrc를 사용하여 DB2 

      인스턴스 환경을 설정하거나 DB2 인스턴스 사용자의 새 로그인 창을 열

      수 있습니다.


설명: 


db2profile(Bourne 또는 Korn 쉘 사용자의 경우) 또는 db2cshrc(C 쉘 사용자

의 경우)를 사용하기 전에는 DB2 인스턴스를 사용할 수 없습니다.


사용자 응답: 


DB2 인스턴스 환경을 설정하려면 DB2 인스턴스를 소유하는 ID에서 새 로그인 

창을 열거나 DB2 인스턴스를 소유하는 ID에서 해당하는 다음 명령을 실행하여

DB2 인스턴스 환경을 설정할 수 있습니다. 


. $HOME/sqllib/db2profile


source $HOME/sqllib/db2cshrc


 여기서 $HOME은 DB2 인스턴스를 소유하는 사용자 ID의 홈 디렉토리를 나타

냅니다.


설치가 완료되면 환경변수 등록을 진행한다.


[db2@server1 expc]$ cd ~

[db2@server1 ~]$ echo ". $HOME/sqllib/db2profile" >> .bash_profile

[db2@server1 ~]$ source .bash_profile  


4. db2 접속


db2 접속을 수행해본다.


[db2@server1 ~]$ db2

(c) Copyright IBM Corporation 1993,2007

Command Line Processor for DB2 Client 10.1.0


You can issue database manager commands and SQL statements from the command 

prompt. For example:

    db2 => connect to sample

    db2 => bind sample.bnd


For general help, type: ?.

For command help, type: ? command, where command can be

the first few keywords of a database manager command. For example:

 ? CATALOG DATABASE for help on the CATALOG DATABASE command

 ? CATALOG          for help on all of the CATALOG commands.


To exit db2 interactive mode, type QUIT at the command prompt. Outside 

interactive mode, all commands must be prefixed with 'db2'.

To list the current command option settings, type LIST COMMAND OPTIONS.


For more detailed help, refer to the Online Reference Manual. 


5. 데이터베이스 생성


testdb라는 데이터베이스를 생성한 뒤 접속을 시도해본다.


db2 => create database testdb

DB20000I  The CREATE DATABASE command completed successfully.

db2 => connect to testdb


   Database Connection Information


 Database server        = DB2/LINUXX8664 10.1.0

 SQL authorization ID   = DB2

 Local database alias   = TESTDB


6. 테이블스페이스 확인 및 테이블 확인


list tablespaces , list tables 명령어로 테이블스페이스 및 테이블 목록을 확인 할 수 있다.


db2 => list tablespaces


           Tablespaces for Current Database


 Tablespace ID                        = 0

 Name                                 = SYSCATSPACE

 Type                                 = Database managed space

 Contents                             = All permanent data. Regular table space.

 State                                = 0x0000

   Detailed explanation:

     Normal


 Tablespace ID                        = 1

 Name                                 = TEMPSPACE1

 Type                                 = System managed space

 Contents                             = System Temporary data

 State                                = 0x0000

   Detailed explanation:

     Normal


 Tablespace ID                        = 2

 Name                                 = USERSPACE1

 Type                                 = Database managed space

 Contents                             = All permanent data. Large table space.

 State                                = 0x0000

   Detailed explanation:

     Normal


db2 => list tables


Table/View                      Schema          Type  Creation time             

------------------------------- --------------- ----- --------------------------


  0 record(s) selected. 



7. 기동 및 중지


db2 기동 및 중지 테스트를 진행해본다.


[db2@server1 ~]$ db2

(c) Copyright IBM Corporation 1993,2007

Command Line Processor for DB2 Client 10.1.0


You can issue database manager commands and SQL statements from the command 

prompt. For example:

    db2 => connect to sample

    db2 => bind sample.bnd


For general help, type: ?.

For command help, type: ? command, where command can be

the first few keywords of a database manager command. For example:

 ? CATALOG DATABASE for help on the CATALOG DATABASE command

 ? CATALOG          for help on all of the CATALOG commands.


To exit db2 interactive mode, type QUIT at the command prompt. Outside 

interactive mode, all commands must be prefixed with 'db2'.

To list the current command option settings, type LIST COMMAND OPTIONS.


For more detailed help, refer to the Online Reference Manual.


db2 => db2stop

DB20000I  The DB2STOP command completed successfully. 


db2 => db2start

DB20000I  The DB2START command completed successfully.