DB2 学习--(1)--安装教程
db2 linux 安装部署
1 解压文件
tar -zxvf db2_v101_linuxx64_expc.tar.gz
2 切换路径
cd expc/
3 启动安装程序
./db2_install
然后它会询问用户是否将软件安装在 /opt/ibm/db2/V10.1 目录,选择 yes
4 创建用户名和用户组
groupadd db2iadm1 groupadd db2fadm1 useradd -m -g db2iadm1 db2inst1 useradd -m -g db2fadm1 db2fenc1
5 修改用户密码
passwd db2inst1 passwd db2fenc1
6 安装 license (产品许可)
cd /opt/ibm/db2/V10.1/adm/ chmod -R 755 *
# 后面的路径为 db2 安装时的解压目录
./db2licm -a /root/software/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"
6 创建数据库实例
cd /opt/ibm/db2/V10.1/instance/ chmod 755 -R * ./db2icrt -p 50000 -u db2fenc1 db2inst1
执行成功后,会显示如下信息
The execution completed successfully. For more information see the DB2 installation log at "/tmp/db2icrt.log.82277". DBI1070I Program db2icrt completed successfully.
7 创建样本数据库
su - db2inst1 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.
继续执行命令
db2start db2 connect to sample 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.
参考博客:
https://my.oschina.net/cwdong8/blog/132953
再进击