ubuntu/win7 安装db2 v10.x

cyper 2017笔记:适用于ubuntu16.04.1 + db2 10.1.0.2

##
抓紧下载v10.5fp1_linuxx64_expc.tar.gz到~/Downloads/java_soft
cd java_soft
tar xf v10.5fp1_linuxx64_expc.tar.gz
可以看到在当前目录下产生了一个expc目录
cd expc
然后检查一下是否满足了安装条件:
./db2prereqcheck
提示

DBT3514W  The db2prereqcheck utility failed to find the following
   32-bit library file: "/lib/libpam.so*".

按照这里的方案http://askubuntu.com/questions/428072/64-bit-db2-10-5-missing-32-bit-libpam-and-64-bit-libaio-on-ubuntu-12-04
执行了如下命令:

sudo apt-get install libpam0g:i386 libaio1   
ln -s /lib/i386-linux-gnu/libpam.so.0 /lib/libpam.so.0 

解决

另一个错:
DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "libstdc++.so.6".

解决方案

Install the 32-bit libstdc++6 in the terminal command line: sudo apt-get install libstdc++6:i386

and then run the ./db2prerecheck again, you will see all the requirements are matched. 

 

接下来是正式安装:
sudo ./db2_install -b /opt/ibm/db2/v10.5

或者使用sudo ./db2_setup以图形方式安装
方法同 v9.7
在这里罗列一遍:
创建3个用户组和3个用户(并给db2inst1设置密码)

useradd -m db2inst1 #-m表示创建相应的home directory
sudo passwd db2inst1
 
useradd -m db2fenc1
sudo passwd db2fenc1
 
useradd -m db2das1
sudo passwd db2das1



切换成root用户

su - root  #创建das和instance
cd /opt/ibm/db2/v10.5/instance
./dascrt -u db2das
DBI1070I  Program dascrt completed successfully.
./db2icrt -u db2inst1 db2inst1
DBI1070I  Program db2icrt completed successfully.
./db2ilist
db2inst1

切换成das用户(因为给das分配的shell是sh而不是bash,我们进入了原始时代(不能tab补全了,当前路径pwd才能知道)

root@zerorun:/opt/ibm/db2/v10.5/instance# su - db2das
$ pwd
/home/db2das
$ ls das/
adm  conv      dasprofile  java  metadata  usercshrc
bin  ctrl      dump       lib     msg       userprofile
cfg  dascshrc  function    log     tmp
$ . das/dasprofile (注意这里的点命令,点号后面必须有空格,点相当于source命令)
$ echo $PATH
。。home/db2das/das/bin:/home/db2das/das/adm
$ which db2admin
/home/db2das/das/bin/db2admin
$ db2admin start
SQL4409W  The DB2 Administration Server is already active.

切换成db2inst1用户

$ su - db2inst1
Password:
db2inst1@zerorun:~$ pwd
/home/db2inst1
db2inst1@zerorun:~$ ls
examples.desktop  sqllib
db2inst1@zerorun:~$ . sqllib/db2profile
db2inst1@zerorun:~$ echo $PATH
。。:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc:/home/db2inst1/sqllib/db2tss/bin
db2inst1@zerorun:~$ which db2start
/home/db2inst1/sqllib/adm/db2start
db2inst1@zerorun:~$ db2start
SQL1063N  DB2START processing was successful.

如果db2start报错 error while loading shared libraries: libnuma.so.1,解决"
sudo apt-get install numactl

关闭db2自动运行(先确认一下)
db2inst1@zerorun:~$ db2set
DB2AUTOSTART=YES
db2inst1@zerorun:~$ db2iauto -off db2inst1
db2inst1@zerorun:~$ db2set

创建数据库

db2inst1@zerorun:~$ db2 "create database tpch USING CODESET UTF-8 TERRITORY CN pagesize 32 k"
DB20000I  The CREATE DATABASE command completed successfully.

 

这一步非常慢,硬盘灯狂闪,需要10分钟

设置远程可以访问DB:
db2inst1@zerorun:~$ db2set
db2inst1@zerorun:~$ db2set DB2COMM=TCPIP
db2inst1@zerorun:~$ db2set
DB2COMM=TCPIP
db2inst1@zerorun:~$ db2 get dbm cfg |grep SVCENAME
 TCP/IP Service name                          (SVCENAME) =
 SSL service name                         (SSL_SVCENAME) =

修改默认的端口号为60000
db2inst1@zerorun:~$ db2 update dbm cfg using SVCENAME 60000
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
SQL1362W  One or more of the parameters submitted for immediate modification
were not changed dynamically. Client changes will not be effective until the
next time the application is started or the TERMINATE command has been issued.
Server changes will not be effective until the next DB2START command.
db2inst1@zerorun:~$ db2 get dbm cfg |grep SVCENAME
 TCP/IP Service name                          (SVCENAME) = 60000
 SSL service name                         (SSL_SVCENAME) =
db2inst1@zerorun:~$

(这个命令是如此之长, 注意SVCENAME是端口号的意思,咋不用PORT呢!)
db2inst1@zerorun:~$ clpplus -nw db2inst1/db2@localhost:60000/tpch
CLPPlus: Version 1.6
Copyright (c) 2009, 2011, IBM CORPORATION.  All rights reserved.


Database Connection Information :
---------------------------------
Hostname = localhost
Database server = DB2/LINUXX8664  SQL10051
SQL authorization ID = db2inst1
Local database alias = TPCH
Port = 60000

SQL> set timi on (这一步是让DB2显示SQL语句的执行时间,同set timing on)
SQL> select sysdate from dual;
ERROR near line 1:
SQL0204N  "DB2INST1.DUAL" is an undefined name.
SQL> select sysdate from SYSIBM.dual;

1                    
---------------------
2014-12-21 23:36:44  
Elapsed time: 28 millisecond(s)
SQL>

 

Win7下的安装

抓紧下载C:\Users\IBM_ADMIN\DownloadDirector\v10.5fp1_winx64_expc.exe

双击自解压.
然后双击setup.exe
安装产品>安装新产品>下一步 >同意(此步有BUG!)
>选择自定义安装,不要选择典型安装(装出来命令行全是中文,很不方便) > 下一步


>下一步(把简体中文从右边移除!!!!!!!!!!)
>若干下一步
>取消设置通知!
>取消启用操作系统安全性
>完成

装好后, 打开开始菜单 > IBM DB2 DB2COPY1> DB2命令窗口 - Adminstrator
注意在这个菜单上面shift右键, 然后选择run as different user,输入db2admin/adb2admin登录后
然后

db2sampl.exe创建sample数据库, 
或者db2sampl.exe -force(如果db已经存在)

C:\IBM\SQLLIB\BIN>db2sampl.exe -force

  Creating database "SAMPLE"...
  Existing "SAMPLE" database found...
  Dropping and recreating database "SAMPLE"...
  Connecting to database "SAMPLE"...
  Creating tables and data in schema "DB2ADMIN"...
  Creating tables with XML columns and XML data in schema "DB2ADMIN"...

  'db2sampl' processing complete.


C:\IBM\SQLLIB\BIN>

校验:
db2
connect to sample
select * from staff


否则默认创建的数据库的schema是操作系统的用户,使用起来很不方便.

 

参考:
http://askubuntu.com/questions/428072/64-bit-db2-10-5-missing-32-bit-libpam-and-64-bit-libaio-on-ubuntu-12-04
http://www.tuicool.com/articles/FbaYbm

转载于:https://my.oschina.net/uniquejava/blog/283485

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段命令的作用是: 1. 执行 `source /etc/profile` 命令,使得之前添加的 Go 语言环境变量生效; 2. 执行 `mkdir -p /home/ubuntu/gopath/src/github.com/hyperledger` 命令,创建一个目录用于存放 Hyperledger Fabric 的源代码; 3. 执行 `cd /home/ubuntu/gopath/src/github.com/hyperledger` 命令,切换到 Hyperledger Fabric 代码存放的目录; 4. 执行 `cp /resource/docker-compose /usr/local/bin` 命令,将预设好的 `docker-compose` 文件拷贝到 `/usr/local/bin` 目录下; 5. 执行 `chmod +x /usr/local/bin/docker-compose` 命令,添加可执行权限; 6. 执行 `cp /resource/fabric-samples.tar.gz /home/ubuntu/gopath/src/github.com/hyperledger` 命令,将预设好的 Hyperledger Fabric 样例程序压缩包拷贝到 `github.com/hyperledger` 目录下; 7. 执行 `cd /home/ubuntu/gopath/src/github.com/hyperledger` 命令,切换到 Hyperledger Fabric 样例程序所在的目录; 8. 执行 `tar -xf ./fabric-samples.tar.gz` 命令,解压 Hyperledger Fabric 样例程序压缩包; 9. 执行 `source /etc/profile` 命令,重新加载 Go 语言环境变量; 10. 执行 `cd /home/ubuntu/gopath/src/github.com/hyperledger/fabric-samples/scripts` 命令,切换到 Hyperledger Fabric 样例程序的脚本目录; 11. 执行 `./bootstrap.sh 1.4.0 1.4.0 0.4.14` 命令,安装 Hyperledger Fabric 所需的依赖组件; 12. 执行 `cd /home/ubuntu/gopath/src/github.com/hyperledger/fabric-samples/first-network` 命令,切换到 Hyperledger Fabric 样例程序的第一个网络目录; 13. 执行 `./byfn.sh up -s couchdb` 命令,启动第一个网络,并使用 CouchDB 作为状态数据库; 14. 执行 `docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml -f docker-compose-kafka.yaml start` 命令,启动 Fabric 网络中的 Docker 容器; 15. 执行 `../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx channel-artifacts/test.tx -channelID test` 命令,使用 configtxgen 工具生成通道交易配置文件和创世块配置文件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值