Linux上安裝DB2 V10

woshishui11211發表於2015-03-16

Linux上安裝DB2 V10

 

 

一、    環境描述

主機:192.168.205.56 Redhat 5.8 X64

軟體: DB2 V10.1

 

二、    上傳安裝檔案

將安裝檔案db2_v101_linuxx64_expc.tar.gz上傳到伺服器上

 

三、    檢查包

# rpm -qa|grepcompat-libstdc

 

四、    配置 Linux 核心引數

#vi /etc/sysctl.conf檔案,新增核心引數

kernel.msgmni =1024

kernel.sem = 250 256000  32 1024

使更改啟用:sysctlp

 

五、    安裝

# tar -zxvf db2_v101_linuxx64_expc.tar.gz

# cdexpc

# ./db2_install

DBI1324W  Support of the db2_install command is deprecated. For

more information, see the DB2 Information Center.

 

 

 

Default directory for installation of products - /opt/ibm/db2/V10.1

 

***********************************************************

Install into default directory (/opt/ibm/db2/V10.1) ? [yes/no]

Yes

………………..省略

 

The execution completed successfully.

 

For more information see the DB2 installation log at

 

六、    建立使用者組和使用者名稱

[root@oracleexpc]# groupadd -g 2000 db2iadm1

[root@oracleexpc]# groupadd -g 2001 db2fadm1

[root@oracleexpc]# useradd -m -g db2iadm1 -d /home/db2inst1 db2inst1

[root@oracleexpc]# useradd -m -g db2fadm1 -d /home/db2fenc1 db2fenc1

[root@oracleexpc]# passwd db2inst1

Changing password for user db2inst1.

New UNIX password:

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

[root@oracleexpc]# passwd db2fenc1

Changing password for user db2fenc1.

New UNIX password:

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

密碼設定成和使用者名稱一樣

 

七、    安裝License(產品許可證)

# cd /opt/ibm/db2/V10.1/adm/

# chmod -R 775 *

# ./db2licm -a /tmp/expc/db2/license/db2expc_uw.lic

 

LIC1402I  License added successfully.

 

LIC1426I  This product is now licensed for use as outlined in your License Agreement.  USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF THE TERMS OF THE IBM LICENSE AGREEMENT, LOCATED IN THE FOLLOWING DIRECTORY: "/opt/ibm/db2/V10.1/license/en_US.iso88591"

 

八、    建立例項和樣本資料庫

因為要建立資料庫就要先建立例項,資料庫執行在例項之上

DASDatabase Administrator Server)是一個特殊型別的例項,主要執行遠端管理任務

例項和資料庫區別:例項本質上由一組後臺程式和共享記憶體組成,資料庫是物理的,表、索引存放在資料庫中要佔物理儲存,例項是邏輯的,是共享記憶體、程式、一些配置檔案(例項目錄)的集合,例項停止時,共享記憶體釋放,程式停止。

可以建多個例項

 

使用db2icrt建立例項

 

# cd /opt/ibm/db2/V10.1/instance/

# chmod -R 775 *

# ./db2icrt -p 50000 -u db2fenc1 db2inst1

過程略

The execution completed successfully.

 

# su - db2inst1

$ db2sampl

 

  Starting the DB2 instance...

  Creating database "SAMPLE"...

  Connecting to database "SAMPLE"...

  Creating tables and data in schema "DB2INST1"...

  Creating tables with XML columns and XML data in schema "DB2INST1"...

  Stopping the DB2 instance...

 

  'db2sampl' processing complete.

 

$ db2start

SQL1063N  DB2START processing was successful.

 

$ db2 connect to sample

 

   Database Connection Information

 

 Database server        = DB2/LINUXX8664 10.1.0

 SQL authorization ID   = DB2INST1

 Local database alias   = SAMPLE

 

$ db2 "select * from staff"

 

ID     NAME      DEPT   JOB   YEARS  SALARY    COMM    

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

    10 Sanders       20 Mgr7  98357.50         -

    20 Pernal        20 Sales      8  78171.25    612.45

    30 Marenghi      38 Mgr5  77506.75         -

    40 O'Brien       38 Sales      6  78006.00    846.55

    50 Hanes         15 Mgr10  80659.80         -

    60 Quigley       38 Sales      -  66808.30    650.25

    70 Rothman       15 Sales      7  76502.83   1152.00

    80 James         20 Clerk      -  43504.60    128.20

    90 Koonitz       42 Sales      6  38001.75   1386.70

   100 Plotz         42 Mgr7  78352.80         -

   110 Ngan          15 Clerk      5  42508.20    206.60

   120 Naughton      38 Clerk      -  42954.75    180.00

   130 Yamaguchi     42 Clerk      6  40505.90     75.60

   140 Fraye         51 Mgr6  91150.00         -

   150 Williams      51 Sales      6  79456.50    637.65

   160 Molinare      10 Mgr7  82959.20         -

   170 Kermisch      15 Clerk      4  42258.50    110.10

   180 Abrahams      38 Clerk      3  37009.75    236.50

   190 Sneider       20 Clerk      8  34252.75    126.50

   200 Scoutten      42 Clerk      -  41508.60     84.20

   210 Lu            10 Mgr10  90010.00         -

   220 Smith         51 Sales      7  87654.50    992.80

   230 Lundquist     51 Clerk      3  83369.80    189.65

   240 Daniels       10 Mgr5  79260.25         -

   250 Wheeler       51 Clerk      6  74460.00    513.30

   260 Jones         10 Mgr12  81234.00         -

   270 Lea           66 Mgr9  88555.50         -

   280 Wilson        66 Sales      9  78674.50    811.50

   290 Quill         84 Mgr10  89818.00         -

   300 Davis         84 Sales      5  65454.50    806.10

   310 Graham        66 Sales     13  71000.00    200.30

   320 Gonzales      66 Sales      4  76858.20    844.00

   330 Burke         66 Clerk      1  49988.00     55.50

   340 Edwards       84 Sales      7  67844.00   1285.00

   350 Gafney        84 Clerk      5  43030.50    188.00

 

  35 record(s) selected.

 

九、    建立das管理伺服器

 

為了遠端客戶端能夠用控制中心來控制資料庫伺服器,需要在資料庫伺服器上安裝 das,當然,如果只是遠端連線而不是遠端管理,可以不用裝

# groupadd -g 2002 db2asgrp

# useradd -m -g db2asgrp -d /home/db2as db2as

# passwd db2as

Changing password for user db2as.

New UNIX password:

BAD PASSWORD: it is too short

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

密碼設定成和使用者名稱一樣

 

 [root@oracle instance]# cd /opt/ibm/db2/V10.1/instance/

[root@oracle instance]# ./dascrt -u db2as

DBI1070I  Programdascrt completed successfully.

 

 

[root@oracle instance]# su - db2as

[db2as@oracle ~]$ db2admin start

SQL4409W  The DB2 Administration Server is already active.

[db2as@oracle ~]$ su - db2inst1

Password:

 

$ db2 get dbmcfg|grep SVCENAME

 TCP/IP Service name                          (SVCENAME) =

 SSL service name                         (SSL_SVCENAME) =

 

[db2inst1@oracle ~]$ db2 update dbmcfg using SVCENAME 50000

DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed

successfully.

 

db2set DB2COMM=tcpip

 

[db2inst1@oracle ~]$ db2 get dbmcfg|grep SVCENAME

 TCP/IP Service name                          (SVCENAME) = 50000

 SSL service name                         (SSL_SVCENAME) =

 

重啟資料庫

$ db2stop

$ db2start

SQL1063N  DB2START processing was successful.

[db2inst1@oracle ~]$ netstat -nat|grep 50000

tcp        0      0 0.0.0.0:50000               0.0.0.0:*                   LISTEN 

 

$ db2licm –l//看一下License的情況,svcename在客戶端連線時需要用到

Product name:                     "DB2 Express-C"

License type:                     "Unwarranted"

Expiry date:                      "Permanent"

Product identifier:               "db2expc"

Version information:              "10.1"

Max number of CPUs:               "2"

Max amount of memory (GB):        "4"

Enforcement policy:               "Soft Stop"

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26217983/viewspace-1461703/,如需轉載,請註明出處,否則將追究法律責任。

相關文章