在路上 ……

Linux系统运维与架构

一,安装操作系统,没什么特别的,我装了桌面和开发包,还有老开发包
安装完成后验证下面三个包是否存在
rpm -qa|grep compat-libstdc++

compat-libstdc++-33-3.2.3-47.3.i386.rpm
compat-libstdc++-33-3.2.3-47.3.x86_64.rpm
compat-libstdc++-296-2.96-132.7.2.i386.rpm

二,安装JDK
一定要去下载IBM 1.4.2 for AMD64/EM64T的JDK,下载完,安装
然后可以创建一个link,方便调用
ln -s /opt/IBMJava2-amd64-142 /opt/jdk
三,设置系统环境变量
修改/etc/profile,增加下面的内容

export JAVA_HOME=/opt/jdk
export DB2USELOCALJRE=TRUE
export RPM_FORCE_NPTL=1

四,解压缩安装包到指定目录。我解压到了/DB2_64目录下,自动生成了335_ESE_LNXAMD26_64_NLV目录
进入安装包的目录
cd /DB2_64/335_ESE_LNXAMD26_64_NLV
经过很多次尝试,都无法使用图形界面安装,所以我开始使用命令行安装
安装包自带的JDK有问题,进入db2/linux26目录
mv java java.orig
ln -s /opt/IBMJava2-amd64-142 java
这样使用我们自己安装的64bit的JDK
然后安装数据库软件
[root@test linux26]# ./db2_install -p DB2.ESE

IBM_db2msen81...
Preparing... ##################################################
IBM_db2msen81 ##################################################
IBM_db2cliv81...
Preparing... ##################################################
IBM_db2cliv81 ##################################################
IBM_db2icw81...
Preparing... ##################################################
IBM_db2icw81 ##################################################
IBM_db2ldap81...
Preparing... ##################################################
IBM_db2ldap81 ##################################################
IBM_db2wmsa81...
Preparing... ##################################################
IBM_db2wmsa81 ##################################################
IBM_db2cucs81...
Preparing... ##################################################
IBM_db2cucs81 ##################################################
IBM_db2conv81...
Preparing... ##################################################
IBM_db2conv81 ##################################################
IBM_db2secl81...
Preparing... ##################################################
IBM_db2secl81 ##################################################
IBM_db2sesm81...
Preparing... ##################################################
IBM_db2sesm81 ##################################################
IBM_db2icuc81...
Preparing... ##################################################
IBM_db2icuc81 ##################################################
IBM_db2icut81...
Preparing... ##################################################
IBM_db2icut81 ##################################################
IBM_db2jhen81...
Preparing... ##################################################
IBM_db2jhen81 ##################################################
IBM_db2repl81...
Preparing... ##################################################
IBM_db2repl81 ##################################################
IBM_db2sp81...
Preparing... ##################################################
IBM_db2sp81 ##################################################
IBM_db2chen81...
Preparing... ##################################################
IBM_db2chen81 ##################################################
IBM_db2adt81...
Preparing... ##################################################
IBM_db2adt81 ##################################################
IBM_db2adts81...
Preparing... ##################################################
IBM_db2adts81 ##################################################
IBM_db2xmls81...
Preparing... ##################################################
IBM_db2xmls81 ##################################################
IBM_db2cj81...
Preparing... ##################################################
IBM_db2cj81 ##################################################
IBM_db2dc81...
Preparing... ##################################################
IBM_db2dc81 ##################################################
IBM_db2dwcm81...
Preparing... ##################################################
IBM_db2dwcm81 ##################################################
IBM_db2fs81...
Preparing... ##################################################
IBM_db2fs81 ##################################################
IBM_db2inst81...
Preparing... ##################################################
IBM_db2inst81 ##################################################
IBM_db2wbdb81...
Preparing... ##################################################
IBM_db2wbdb81 ##################################################
IBM_db2xml81...
Preparing... ##################################################
IBM_db2xml81 ##################################################
IBM_db2jdbc81...
Preparing... ##################################################
IBM_db2jdbc81 ##################################################
IBM_db2ca81...
Preparing... ##################################################
IBM_db2ca81 ##################################################
IBM_db2rte81...
Preparing... ##################################################
IBM_db2rte81 ##################################################
IBM_db2conn81...
Preparing... ##################################################
IBM_db2conn81 ##################################################
IBM_db2crte81...
Preparing... ##################################################
IBM_db2crte81 ##################################################
IBM_db2das81...
Preparing... ##################################################
IBM_db2das81 ##################################################
IBM_db2dj81...
Preparing... ##################################################
IBM_db2dj81 ##################################################
IBM_db2engn81...
Preparing... ##################################################
IBM_db2engn81 ##################################################
IBM_db2smpl81...
Preparing... ##################################################
IBM_db2smpl81 ##################################################
IBM_db2djx81...
Preparing... ##################################################
IBM_db2djx81 ##################################################
IBM_db2inx81...
Preparing... ##################################################
IBM_db2inx81 ##################################################
IBM_db2pext81...
Preparing... ##################################################
IBM_db2pext81 ##################################################
IBM_db2essg81...
Preparing... ##################################################
IBM_db2essg81 ##################################################
IBM_db2cc81...
Preparing... ##################################################
IBM_db2cc81 ##################################################
IBM_db2icc81...
Preparing... ##################################################
IBM_db2icc81 ##################################################
IBM_db2icms81...
Preparing... ##################################################
IBM_db2icms81 ##################################################
The installation logfile can be found in /tmp/db2_install_log.5273.
db2_install program completed successfully.

安装了一堆的RPM后,软件就安装好了
五,下面开始安装后的数据库手工配置
1,建立用户和组
groupadd db2grp1
groupadd db2fgrp1
groupadd dasadm1
useradd -g db2grp1 -m -d /home/db2inst1 -p “” db2inst1
useradd -g db2fgrp1 -m -d /home/db2fenc1 -p ““ db2fenc1
useradd -g dasadm1 -m -d /home/dasusr1 -p “” dasusr1
注:以上三个用户密码均为空,用su命令切换到相应用户下时,用passwd命令设置即可

2,创建实例
首先我们使用以下命令创建管理服务器实例
/opt/IBM/db2/V8.1/instance/dascrt -u dasusr1

SQL4406W The DB2 Administration Server was started successfully.
DBI1070I Program dascrt completed successfully.

接着使用以下命令创建数据库实例 db2inst1
/opt/IBM/db2/V8.1/instance/db2icrt -u db2fenc1 db2inst1

DBI1070I Program db2icrt completed successfully.

3,创建共享库链接
/opt/IBM/db2/V8.1/cfg/db2ln

4,设置DB2 实例环境变量
用su命令切换到db2实例所用者用户终端
su - db2inst1
db2set DB2_EXTENDED_OPTIMIZATION=ON
db2set DB2_DISABLE_FLUSH_LOG=ON
db2set AUTOSTART=YES
db2set DB2_STRIPED_CONTAINERS=ON
db2set DB2_HASH_JOIN=Y
db2set DB2COMM=tcpip
db2set DB2_PARALLEL_IO=*
db2set DB2CODEPAGE=1386

5,设置服务端口
[db2inst1@review root]$ db2
然后在DB2的提示符下输入
update database manager configuration using svcename server1
设置服务名为server1
然后get database manager configuration,检查一下参数
其中让我比较郁闷的就是JDK_PATH参数,居然设的不对,搞得数据库安装好后图形化管理工具无法使用
下面是我机器上执行的结果,以供参考!

(c) Copyright IBM Corporation 1993,2002
Command Line Processor for DB2 SDK 8.2.2
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 => update database manager configuration using svcename server1
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed 
successfully.
db2 => get database manager configuration
Database Manager Configuration
Node type = Enterprise Server Edition with local and remote clients
Database manager configuration release level = 0x0a00
CPU speed (millisec/instruction) (CPUSPEED) = 3.070238e-07
Communications bandwidth (MB/sec) (COMM_BANDWIDTH) = 1.000000e+02
Max number of concurrently active databases (NUMDB) = 8
Data Links support (DATALINKS) = NO
Federated Database System Support (FEDERATED) = NO
Transaction processor monitor name (TP_MON_NAME) =
Default charge-back account (DFT_ACCOUNT_STR) =
Java Development Kit installation path (JDK_PATH) = /opt/IBMJava2-142
Diagnostic error capture level (DIAGLEVEL) = 3
Notify Level (NOTIFYLEVEL) = 3
Diagnostic data directory path (DIAGPATH) = /home/db2inst1/sqllib/db2dump
Default database monitor switches
Buffer pool (DFT_MON_BUFPOOL) = OFF
Lock (DFT_MON_LOCK) = OFF
Sort (DFT_MON_SORT) = OFF
Statement (DFT_MON_STMT) = OFF
Table (DFT_MON_TABLE) = OFF
Timestamp (DFT_MON_TIMESTAMP) = ON
Unit of work (DFT_MON_UOW) = OFF
Monitor health of instance and databases (HEALTH_MON) = ON
SYSADM group name (SYSADM_GROUP) = DB2GRP1 
SYSCTRL group name (SYSCTRL_GROUP) = 
SYSMAINT group name (SYSMAINT_GROUP) = 
SYSMON group name (SYSMON_GROUP) =
Client Userid-Password Plugin (CLNT_PW_PLUGIN) = 
Client Kerberos Plugin (CLNT_KRB_PLUGIN) = 
Group Plugin (GROUP_PLUGIN) = 
GSS Plugin for Local Authorization (LOCAL_GSSPLUGIN) = 
Server Plugin Mode (SRV_PLUGIN_MODE) = UNFENCED
Server List of GSS Plugins (SRVCON_GSSPLUGIN_LIST) = 
Server Userid-Password Plugin (SRVCON_PW_PLUGIN) = 
Server Connection Authentication (SRVCON_AUTH) = NOT_SPECIFIED
Database manager authentication (AUTHENTICATION) = SERVER
Cataloging allowed without authority (CATALOG_NOAUTH) = NO
Trust all clients (TRUST_ALLCLNTS) = YES
Trusted client authentication (TRUST_CLNTAUTH) = CLIENT
Bypass federated authentication (FED_NOAUTH) = NO
Default database path (DFTDBPATH) = /home/db2inst1
Database monitor heap size (4KB) (MON_HEAP_SZ) = 90
Java Virtual Machine heap size (4KB) (JAVA_HEAP_SZ) = 2048
Audit buffer size (4KB) (AUDIT_BUF_SZ) = 0
Size of instance shared memory (4KB) (INSTANCE_MEMORY) = AUTOMATIC
Backup buffer default size (4KB) (BACKBUFSZ) = 1024
Restore buffer default size (4KB) (RESTBUFSZ) = 1024
Sort heap threshold (4KB) (SHEAPTHRES) = 20000
Directory cache support (DIR_CACHE) = YES
Application support layer heap size (4KB) (ASLHEAPSZ) = 15
Max requester I/O block size (bytes) (RQRIOBLK) = 32767
Query heap size (4KB) (QUERY_HEAP_SZ) = 1000
Workload impact by throttled utilities(UTIL_IMPACT_LIM) = 10
Priority of agents (AGENTPRI) = SYSTEM
Max number of existing agents (MAXAGENTS) = 400
Agent pool size (NUM_POOLAGENTS) = 200(calculated)
Initial number of agents in pool (NUM_INITAGENTS) = 0
Max number of coordinating agents (MAX_COORDAGENTS) = (MAXAGENTS - NUM_INITAGENTS)
Max no. of concurrent coordinating agents (MAXCAGENTS) = MAX_COORDAGENTS
Max number of client connections (MAX_CONNECTIONS) = MAX_COORDAGENTS
Keep fenced process (KEEPFENCED) = YES
Number of pooled fenced processes (FENCED_POOL) = MAX_COORDAGENTS
Initial number of fenced processes (NUM_INITFENCED) = 0
Index re-creation time and redo index build (INDEXREC) = RESTART
Transaction manager database name (TM_DATABASE) = 1ST_CONN
Transaction resync interval (sec) (RESYNC_INTERVAL) = 180
SPM name (SPM_NAME) = 
SPM log size (SPM_LOG_FILE_SZ) = 256
SPM resync agent limit (SPM_MAX_RESYNC) = 20
SPM log path (SPM_LOG_PATH) =
TCP/IP Service name (SVCENAME) = server1
Discovery mode (DISCOVER) = SEARCH
Discover server instance (DISCOVER_INST) = ENABLE
Maximum query degree of parallelism (MAX_QUERYDEGREE) = ANY
Enable intra-partition parallelism (INTRA_PARALLEL) = NO
No. of int. communication buffers(4KB)(FCM_NUM_BUFFERS) = 4096
Number of FCM request blocks (FCM_NUM_RQB) = AUTOMATIC
Number of FCM connection entries (FCM_NUM_CONNECT) = AUTOMATIC
Number of FCM message anchors (FCM_NUM_ANCHORS) = AUTOMATIC
Node connection elapse time (sec) (CONN_ELAPSE) = 10
Max number of node connection retries (MAX_CONNRETRIES) = 5
Max time difference between nodes (min) (MAX_TIME_DIFF) = 60
db2start/db2stop timeout (min) (START_STOP_TIME) = 10

6,编辑/etc/services文件,增加服务端口

DB2_db2inst1 60000/tcp
DB2_db2inst1_1 60001/tcp
DB2_db2inst1_2 60002/tcp
DB2_db2inst1_END 60003/tcp
server1 50000/tcp # DB2 connection service port

这里增加的server1这一行就是刚才设置的服务名

7,修改DBM参数
db2 update dbm cfg using SVCENAME server1

8,现在可以启动DB2了
[db2inst1@review ~]$ db2start

05/24/2006 21:48:56 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.

9,创建数据库
进入DB2的命令行

db2 => create database TEST
DB20000I The CREATE DATABASE command completed successfully.

10,基本上差不多了,最好重起一下
先把DB2停了了
db2stop
回到root用户,重起系统
shutdown -r now


Typecho 强力驱动