安裝DB2
[[email protected] opt]# tar -zxvf db2_v1012_linuxia32_expc.tar.gz
[[email protected] opt]# ls
db2_v1012_linuxia32_expc.tar.gz expc lost+found rh
[[email protected] opt]# cd expc/
[[email protected] expc]# ls
db2 db2ckupgrade db2_deinstall db2_install db2ls db2prereqcheck db2setup doc
[[email protected] expc]# ./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
DB2 installation is being initialized.
Total number of tasks to be performed: 35
Total estimated time for all tasks to be performed: 990 second(s)
。。。。。。。。。。
。。。。。。
。。。
Task #37 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #37 end
The execution completed successfully.
For more information see the DB2 installation log at
"/tmp/db2_install.log.2705".
建立使用者
組(使用者名)
db2iadm1(db2inst1)
db2fadm1( db2fenc1)
[[email protected] expc]# groupadd -g 2000 db2iadm1
[[email protected] expc]# groupadd -g 2001 db2fadm1
[[email protected] expc]# useradd -m -g db2iadm1 -d /home/db2inst1 db2inst1
[[email protected] expc]# useradd -m -g db2fadm1 -d /home/db2fenc1 db2fenc1
[[email protected] expc]# passwd db2inst1
[[email protected] expc]# passwd db2fenc1
安裝 license (産品許可證)
[[email protected] adm]# pwd
/opt/ibm/db2/V10.1/adm
[[email protected] adm]# chmod -R 775 *
[[email protected] adm]$ ./db2licm -a /tmp/seagull/db2v10/license/db2ese_c.lic
建立執行個體和樣本資料庫
[[email protected] instance]# pwd
/opt/ibm/db2/V10.1/instance
[[email protected] instance]# chmod -R 775 *
[r[email protected] instance]# ./db2icrt -p 50000 -u db2fenc1 db2inst1
DBI1446I The db2icrt command is running.
DB2 installation is being initialized.
Total number of tasks to be performed: 4
Total estimated time for all tasks to be performed: 309 second(s)
Task #1 start
Description: Setting default global profile registry variables
Estimated time 1 second(s)
Task #1 end
Task #2 start
Description: Initializing instance list
Estimated time 5 second(s)
Task #2 end
Task #3 start
Description: Configuring DB2 instances
Estimated time 300 second(s)
Task #3 end
Task #4 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #4 end
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2icrt.log.2571".
Required: Review the following log file also for warnings or errors:
"/tmp/db2icrt_local.log.*"
DBI1070I Program db2icrt completed successfully.
[[email protected] instance]# su - db2inst1
[[email protected] ~]$ db2sampl
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"...
'db2sampl' processing complete.
[[email protected] ~]$ db2start
SQL1026N The database manager is already active.
[[email protected] ~]$ db2 connect to sample
Database Connection Information
Database server = DB2/LINUX 10.1.2
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
[[email protected] ~]$ db2 "select * from staff"
ID NAME DEPT JOB YEARS SALARY COMM
------ --------- ------ ----- ------ --------- ---------
10 Sanders 20 Mgr 7 98357.50 -
20 Pernal 20 Sales 8 78171.25 612.45
30 Marenghi 38 Mgr 5 77506.75 -
40 O'Brien 38 Sales 6 78006.00 846.55
50 Hanes 15 Mgr 10 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 Mgr 7 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 Mgr 6 91150.00 -
150 Williams 51 Sales 6 79456.50 637.65
160 Molinare 10 Mgr 7 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 Mgr 10 90010.00 -
220 Smith 51 Sales 7 87654.50 992.80
230 Lundquist 51 Clerk 3 83369.80 189.65
240 Daniels 10 Mgr 5 79260.25 -
250 Wheeler 51 Clerk 6 74460.00 513.30
260 Jones 10 Mgr 12 81234.00 -
270 Lea 66 Mgr 9 88555.50 -
280 Wilson 66 Sales 9 78674.50 811.50
290 Quill 84 Mgr 10 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,當然,如果隻是遠端連接配接而不是遠端管理,可以不用裝,這裡我安裝了一下。
[[email protected] expc]# groupadd -g 2002 db2asgrp
[[email protected] expc]# useradd -m -g db2asgrp -d /home/db2as db2as
[[email protected] expc]# passwd db2as
[[email protected] ~]$ su - db2as
Password:
[[email protected] ~]$ su -
Password:
[[email protected] ~]# cd /opt/ibm/db2/V10.1/instance/
[[email protected] instance]# ./dascrt -u db2as
DBI1070I Program dascrt completed successfully.
[[email protected] instance]# su - db2as
[[email protected] ~]$ db2admin start
SQL4409W The DB2 Administration Server is already active.
确認一下 db2inst1 執行個體的服務名
[[email protected] ~]$ su - db2inst1
Password:
[[email protected] ~]$ db2 get dbm cfg|grep SVCENAME
TCP/IP Service name (SVCENAME) =
SSL service name (SSL_SVCENAME) =
[[email protected] ~]$ db2 update dbm cfg using SVCENAME 50000
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
Successfully.
[[email protected] ~]$ db2 get dbm cfg|grep SVCENAME
TCP/IP Service name (SVCENAME) = 50000
SSL service name (SSL_SVCENAME) =
#注解:svcename 在用戶端連接配接時需要用到
看一下 license 情況
[[email protected] ~]$ db2licm -l