刚开始为了练习db2搭了好几个环境,中间各组件调用都会出现好多状况,最后搞了一个跟公司生产一样的环境版本,本次记录db2安装过程,以便后期安装查找。
环境情况: SUSE Linux Enterprise Server 11 SP3 (x86_64)
DB2 Express-C 10.5
1.创建用户:创建用户组、用户,并且指定用户目录,设置密码;
groupadd -g 999 db2inst
useradd -u 999 -g 999 -m -d /db2home/db2inst db2inst
passwd db2inst
2.解压安装tar包,执行命令行安装操作:./db2_install
Default directory for installation of products - /opt/ibm/db2/V10.5
***********************************************************
Install into default directory (/opt/ibm/db2/V10.5) ? [yes/no]
根据自己需要是否更改默认安装路径进行选择
选择yes后直接安装,这中间没有出现不良状况,最终出现
The execution completedsuccessfully.
For more information see the DB2 installation log at3.安装license
进入安装后的db2目录:cd /opt/ibm/db2/V10.5/adm
执行命令: db2licm -a ./db2licm -a /home/soft/expc/db2/license/db2expc_uw.lic (-a后的路径为license文件地址,文件名不一定相同,选择后缀名为.lic即可)
出现LIC1402I License added successfully. 表示安装license成功。
4.创建实例、样本数据库
进到目录: cd /opt/ibm/db2/V10.5/instance
执行命令:./db2icrt -p 60000 -u db2inst (-p 表示指定端口号,-u 指定实例名)
这里出现问题:
DB2 installation is being initialized.
The host name "iZrk14j7ljiw1xZ" is invalid. Specify a valid host name.
A major error occurred during the execution that caused this program to
terminate prematurely. If the problem persists, contact your technical service
representative.
原因是hosts中的主机名为自动修改,手动修改即可;vi /etc/hosts ,添加自己执行hostname命令显示的主机名。
再次执行 /db2icrt -p 60000 -u db2inst,最终显示
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2icrt.log.3995".
DBI1070I Program db2icrt completed successfully.
切换到实例用户:su - db2inst
查看端口号:db2 get dbm cfg|grep SVCENAME
显示:
CP/IP Service name (SVCENAME) = 60000
SSL service name (SSL_SVCENAME) =
如果想更改端口号为50000,可执行:db2 update dbm cfg using svcename 50000
数据库方面可激活官方库SAMPLE,执行db2sampl命令,出现如下表示创建成功
Creating database "SAMPLE"...
Connecting to database "SAMPLE"...
Creating tables and data in schema "DB2INST"...
Creating tables with XML columns and XML data in schema "DB2INST"...
'db2sampl' processing complete.
可对其他用户赋权操作sample,比如给wu_db用户赋权:db2 "grant dbadm on database to user wu_db"
5.创建新数据库
创建新数据edw可以执行create语句:db2 "create database edw automatic storage yes using codeset UTF-8 territory cn collate using system pagesize 32768"
建表空间什么的由于暂时不需要就没有创建,如需要后续执行create tablespace即可。
6.本次DB2记录就到这里,后续安装DataStage,如果遇到问题较多就总结记录下过程。