1、 解压安装包
[root@linuxclient ~]# tar -xvzf /mnt/hgfs/data/ibm/db2/v10.1_linuxx64_server.tar.gz
[root@linuxclient ~]# ls server/
db2 db2ckupgrade db2_deinstall db2_install db2ls db2prereqcheck db2setup installFixPack
2、 安装
[root@linuxclient ~]# cd server/
[root@linuxclient server]# ./db2_install -b /opt/ibm/db2/V10.1 -p ESE
3、 创建用户和组
[root@linuxclient server]# groupadd -g 901 db2iadm1
[root@linuxclient server]# groupadd -g 902 db2fadm1
[root@linuxclient server]# groupadd -g 903 dasadm1
[root@linuxclient ~]# useradd -g db2iadm1 -u 801 -s /bin/bash db2inst1
[root@linuxclient ~]# useradd -g db2fadm1 -u 802 -s /bin/bash db2fenc1
[root@linuxclient ~]# useradd -g dasadm1 -u 803 -s /bin/bash dasusr1
[root@linuxclient ~]# echo "123456" | passwd --stdin db2inst1
Changing password for user db2inst1.
passwd: all authentication tokens updated successfully.
[root@linuxclient ~]# echo "123456" | passwd --stdin db2fenc1
Changing password for user db2fenc1.
passwd: all authentication tokens updated successfully.
[root@linuxclient ~]# echo "123456" | passwd --stdin dasusr1
Changing password for user dasusr1.
passwd: all authentication tokens updated successfully.
4、 创建实例
创建管理服务器
[root@linuxclient instance]# ./dascrt -u dasusr1
DBI1070I Program dascrt completed successfully.
创建实例
[root@linuxclient instance]# ./db2icrt -u db2fenc1 db2inst1
DBI1446I The db2icrt command is running, please wait.
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.45873".
DBI1070I Program db2icrt completed successfully.
5、 启动DB2
启动管理服务器
[root@linuxclient instance]# su - dasusr1
[dasusr1@linuxclient ~]$ db2admin start
SQL4409W The DB2 Administration Server is already active.
启动实例
[dasusr1@linuxclient ~]$ su - db2inst1
Password:
[db2inst1@linuxclient ~]$ db2start
07/03/2015 17:40:41 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
6、 配置DB2
设置开机自动启动
[db2inst1@linuxclient ~]$ su -
Password:
[root@linuxclient ~]# cd /opt/ibm/db2/V10.1/instance/
[root@linuxclient instance]# ./db2iauto -on db2inst1
配置网络
[root@linuxclient instance]# su - db2inst1
[db2inst1@linuxclient ~]$ db2 update dbm cfg using SVCENAME 60000
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
[db2inst1@linuxclient ~]$ db2set DB2COMM=TCPIP
7、 访问数据库
启动实例
[db2inst1@linuxclient ~]$ db2start
07/03/2015 17:48:31 0 0 SQL1026N The database manager is already active.
SQL1026N The database manager is already active.
创建数据库
[db2inst1@linuxclient ~]$ db2 create database sample using codeset utf-8 territory CN
DB20000I The CREATE DATABASE command completed successfully.
连接到数据库
[db2inst1@linuxclient ~]$ db2 connect to sample
Database Connection Information
Database server = DB2/LINUXX8664 10.1.0
SQL authorization ID = DB2INST1
Local database alias = SAMPLE