[root@seagull /]# mkdir /db2home
[root@seagull /]# mkdir /db2home/db2inst1
[root@seagull /]# mkdir /db2home/db2fenc1
[root@seagull /]# groupadd -g 999 db2iadm1
[root@seagull /]# groupadd -g 998 db2fadm1
[root@seagull /]# useradd -u 1003 -g db2fadm1 -d /db2home/db2fenc1 db2fenc1
passwd db2fenc1
su - db2fenc1 --根据提示,重新设置密码,使得密码生效
su - db2inst1 --切换用户
su - db2inst1 --根据提示,重新设置密码,使得密码生效
[root@seagull seagull]# cd /tmp/seagull/db2v9/
[root@seagull db2v9]# ls
db2 db2_install db2setup installFixPack
#注解:IBM工程师建议用文字界面安装,而不要用图形界面安装,即用db2_install,不要用db2setup
Default directory for installation of products - /opt/ibm/db2/V9.1
Do you want to choose a different directory to install [yes/no] ?
no
separated by spaces, to install DB2 products.
RTCL
ESE
Enter "help" to redisplay product names.
ESE
DB2 installation is being initialized.
Total estimated time for all tasks to be performed: 802
Description: Checking license agreement acceptance
Estimated time 1 second(s)
Task #1 end
Description: GSKit support
Estimated time 19 second(s)
Task #2 end
Description: Product Messages - English
Estimated time 10 second(s)
Task #3 end
Description: Base client support
Estimated time 67 second(s)
Task #4 end
Description: IBM Software Development Kit (SDK) for Java(TM)
Estimated time 101 second(s)
Description: Java Help (HTML) - English
Estimated time 7 second(s)
Task #6 end
Description: Replication with MQ Server
Estimated time 22 second(s)
Task #7 end
Description: Run-time Environment
Estimated time 78 second(s)
Description: Java support
Estimated time 6 second(s)
Task #9 end
Description: SQL procedures
Estimated time 3 second(s)
Task #10 end
Description: ICU Utilities
Estimated time 39 second(s)
Task #11 end
Description: SQL Replication Support
Estimated time 19 second(s)
Task #12 end
Description: Java Common files
Estimated time 20 second(s)
Task #13 end
Description: Base server support
Estimated time 47 second(s)
Task #14 end
Description: Control Center Help (HTML) - English
Estimated time 13 second(s)
Task #15 end
Description: Connect support
Estimated time 3 second(s)
Task #16 end
Description: Configuration Assistant
Estimated time 4 second(s)
Task #17 end
Description: Spatial Extender client
Estimated time 6 second(s)
Task #18 end
Description: Base application development tools
Estimated time 11 second(s)
Task #19 end
Description: Administration Server
Estimated time 7 second(s)
Task #20 end
Description: Communication support - TCP/IP
Estimated time 3 second(s)
Task #21 end
Description: Control Center
Estimated time 38 second(s)
Task #22 end
Description: Parallel Extension
Estimated time 3 second(s)
Task #23 end
Description: Replication tools
Estimated time 12 second(s)
Task #24 end
Description: Relational wrappers common
Estimated time 3 second(s)
Task #25 end
Description: DB2 data source support
Estimated time 4 second(s)
Task #26 end
Description: DB2 LDAP support
Estimated time 3 second(s)
Task #27 end
Description: DB2 Instance Setup wizard
Estimated time 4 second(s)
Task #28 end
Description: XML Extender
Estimated time 11 second(s)
Task #29 end
Description: First Steps
Estimated time 3 second(s)
Task #30 end
Description: DB2 Web Tools
Estimated time 12 second(s)
Task #31 end
Description: Product Signature for DB2 Enterprise Server Edition
Estimated time 5 second(s)
Task #32 end
Description: XML Extender samples
Estimated time 3 second(s)
Task #33 end
Description: ADT sample programs
Estimated time 20 second(s)
Task #34 end
Description: Sample database source
Estimated time 4 second(s)
Task #35 end
Description: Spatial Extender samples
Estimated time 3 second(s)
Task #36 end
Description: Informix data source support
Estimated time 3 second(s)
Task #37 end
Description: Setting DB2 library path
Estimated time 120 second(s)
Description: Executing control tasks
Estimated time 20 second(s)
Task #39 end
Description: Updating global registry
Estimated time 20 second(s)
Task #40 end
Description: Starting DB2 Fault Monitor
Estimated time 10 second(s)
Task #41 end
Description: Updating the db2ls link
Estimated time 1 second(s)
Task #42 end
Description: Registering DB2 licenses
Estimated time 5 second(s)
Task #43 end
Description: Setting default global profile registry variables
Estimated time 1 second(s)
Task #44 end
Description: Initializing instance list
Estimated time 5 second(s)
Task #45 end
Description: Updating global profile registry
Estimated time 3 second(s)
Task #46 end
"/tmp/db2_install.log.7134".
[root@seagull db2v9]#
[root@seagull bin]# cd /opt/ibm/db2/V9.1/adm/
[root@seagull adm]# ./db2licm -a /tmp/seagull/db2v9/license/db2ese_c.lic
LIC1426I This product is now licensed for use as specified in the License Agreement and License Information documents pertaining to the licensed copy of this product. USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF THE TERMS OF THE IBM LICENSE AGREEMENT AND LICENSE INFORMATION DOCUMENTS, LOCATED IN THE FOLLOWING DIRECTORY: "/opt/ibm/db2/V9.1/license/en_US.iso88591"
[root@seagull adm]# ./db2licm -a /tmp/seagull/db2v9/license/db2dpf.lic
LIC1426I This product is now licensed for use as specified in the License Agreement and License Information documents pertaining to the licensed copy of this product. USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF THE TERMS OF THE IBM LICENSE AGREEMENT AND LICENSE INFORMATION DOCUMENTS, LOCATED IN THE FOLLOWING DIRECTORY: "/opt/ibm/db2/V9.1/license/en_US.iso88591"
[root@seagull adm]# ./db2licm -a /tmp/seagull/db2v9/license/db2xmlese.lic
LIC1426I This product is now licensed for use as specified in the License Agreement and License Information documents pertaining to the licensed copy of this product. USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF THE TERMS OF THE IBM LICENSE AGREEMENT AND LICENSE INFORMATION DOCUMENTS, LOCATED IN THE FOLLOWING DIRECTORY: "/opt/ibm/db2/V9.1/license/en_US.iso88591"
[root@seagull adm]#
[root@seagull V9.1]# cd /opt/ibm/db2/V9.1/instance
[root@seagull instance]# ./db2icrt -p 50000 -u db2fenc1 db2inst1
DBI1070I Program db2icrt completed successfully.
# Local services
DB2_db2inst1_1 60001/tcp
DB2_db2inst1_2 60002/tcp
DB2_db2inst1_END 60003/tcp
[root@seagull ~]# su - db2inst1
[db2inst1@seagull ~]$
[db2inst1@seagull ~]$ db2sampl
Creating database "SAMPLE"...
Connecting to database "SAMPLE"...
Creating tables and data in schema "DB2INST1"...
Stopping the DB2 instance...
[db2inst1@seagull sqllib]$ db2start
11/28/2007 16:49:04 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
[db2inst1@seagull sqllib]$ db2 connect to sample
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
------ --------- ------ ----- ------ --------- ---------
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
[root@seagull ~]# mkdir /db2home/db2as
[root@seagull ~]# useradd -u 1002 -g db2asgrp -d /db2home/db2as db2as
TCP/IP Service name (SVCENAME) = 50000
Product name: "DB2 Enterprise Server Edition"
License type: "CPU"
Expiry date: "Permanent"
Product identifier: "db2ese"
Version information: "9.1"
Annotation: "-3;(_c)"
Features:
DB2 Database Partitioning: "Licensed"
DB2 Performance Optimization ESE: "Not licensed"
DB2 Storage Optimization: "Not licensed"
DB2 Advanced Access Control: "Not licensed"
DB2 Geodetic Data Management: "Not licensed"
Homogeneous Federation for DB2: "Not licensed"
DB2 Pure XML ESE: "Licensed"
C:/>db2 catalog tcpip node vmdb2v9 remote 10.10.10.100 server 50000
DB20000I CATALOG TCPIP NODE命令成功完成。
DB21056W 只有在刷新目录高速缓存以后,目录更改才会生效。
DB21056W 只有在刷新目录高速缓存以后,目录更改才会生效。
DB21085I Instance "db2inst1" uses "32" bits and DB2 code release "SQL09010"
with level identifier "02010107".
Informational tokens are "DB2 v9.1.0.0", "s060629", "LINUXIA32", and Fix Pack
"0".
Product is installed at "/opt/ibm/db2/V9.1".
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
------------------------------- --------------- ----- --------------------------
ACT DB2INST1 T 2007-11-28-16.48.12.138286
------------------------------- --------------- ----- --------------------------
ADEFUSR DB2INST1 S 2007-11-28-16.48.16.196999
Name = SYSCATSPACE
Type = Database managed space
Contents = All permanent data. Regular table space.
State = 0x0000
Detailed explanation:
Normal
Name = TEMPSPACE1
Type = System managed space
Contents = System Temporary data
State = 0x0000
Detailed explanation:
Normal
Name = USERSPACE1
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailed explanation:
Normal
Name = IBMDB2SAMPLEREL
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailed explanation:
Normal
Name = /db2home/db2inst1/db2inst1/NODE0000/SAMPLE/T0000001/C0000000.TMP
Type = Path
name schema name Length Scale Nulls
------------------------------ --------- ------------------ -------- ----- ------
ID SYSIBM SMALLINT 2 0 No
NAME SYSIBM VARCHAR 9 0 Yes
DEPT SYSIBM SMALLINT 2 0 Yes
JOB SYSIBM CHARACTER 5 0 Yes
YEARS SYSIBM SMALLINT 2 0 Yes
SALARY SYSIBM DECIMAL 7 2 Yes
COMM SYSIBM DECIMAL 7 2 Yes
DB20000I The SQL command completed successfully.
[db2inst1@seagull ~]$ db2 "insert into t1 values(1,'seagull')"
DB20000I The SQL command completed successfully.
[db2inst1@seagull ~]$ db2 "insert into t1 values(2,'lgh')"
DB20000I The SQL command completed successfully.
[db2inst1@seagull ~]$ db2 "insert into t1 values(2,'海鸥')"
DB20000I The SQL command completed successfully.
[db2inst1@seagull ~]$ db2 commit
DB20000I The SQL command completed successfully.
[db2inst1@seagull ~]$ db2 "select * from t1"
------ ----------
1 seagull
2 lgh
2 海鸥
Database code page = 1208
Database code set = UTF-8
Database country/region code = 1
[db2inst1@seagull ~]$
su - db2inst1
db2set db2codepage=1386 #为了能创建gbk字符集数据库
exit #退一次为了使得设置生效
su - db2inst1
db2 create db GZDC using codeset GBK territory CN
connect to gzdc
db2 grant dbadm on database to db2admin
db2 "create bufferpool BP_8K size -1 pagesize 8192 not extended storage"
db2 "alter bufferpool IBMDEFAULTBP immediate size 50000"
CREATE system temporary TABLESPACE TS_SYSTEMP_04 PAGESIZE 4096 MANAGED BY DATABASE USING (FILE '/db2data/db2data01/stmp4k1.dbf' 1024M , FILE '/db2data/db2data02/stmp4k2.dbf' 1024M ) EXTENTSIZE 32 PREFETCHSIZE 64
CREATE system temporary TABLESPACE TS_SYSTEMP_08 PAGESIZE 8192 MANAGED BY DATABASE USING (FILE '/db2data/db2data01/stmp8k1.dbf' 5G , FILE '/db2data/db2data02/stmp8k2.dbf' 5G ) EXTENTSIZE 192 PREFETCHSIZE 384 BUFFERPOOL BP_8K
CREATE LARGE TABLESPACE HOSPITALSPACE PAGESIZE 8192 MANAGED BY DATABASE USING
(FILE '/db2data/db2data01/HOSPITAL_01.dbf' 50G ,
FILE '/db2data/db2data02/HOSPITAL_02.dbf' 50G ,
FILE '/db2data/db2data01/HOSPITAL_03.dbf' 50G ,
FILE '/db2data/db2data02/HOSPITAL_04.dbf' 50G ,
FILE '/db2data/db2data01/HOSPITAL_05.dbf' 50G ,
FILE '/db2data/db2data02/HOSPITAL_06.dbf' 50G ,
FILE '/db2data/db2data01/HOSPITAL_07.dbf' 50G ,
FILE '/db2data/db2data02/HOSPITAL_08.dbf' 50G ,
FILE '/db2data/db2data01/HOSPITAL_09.dbf' 50G ,
FILE '/db2data/db2data02/HOSPITAL_10.dbf' 50G )
EXTENTSIZE 192 PREFETCHSIZE 384 BUFFERPOOL BP_8K;
CREATE LARGE TABLESPACE MANAGERSPACE PAGESIZE 8192 MANAGED BY DATABASE USING (FILE '/db2data/db2data01/MANAGER_01.dbf' 25G ) EXTENTSIZE 192 PREFETCHSIZE 384 BUFFERPOOL BP_8K
alter tablespace managerspace add (file '/db2data/db2data02/MANAGER_02.dbf' 25G )