文章目录
</br>` > 3. 将JDK安装文件复制到`/opt/bcdl` > `cp jdk*.sh /opt/bcdl` > 4. 进入/opt/bcdl目录,为JDK安装文件增加执行权限 > `cd /opt/bcdl chmod +x jdk*.sh` > 5. 将JDK安装文件赋予bcdl用户 > `chown bcdl:bcdl jdk*.sh
</br>` > 6. 切换到bcdl用户 > `su – bcdl` > 7. 执行以下命令安装JDK > `cd /opt/bcdl ./jdk-6u7-solaris-sparc.sh` > 8. 按多次空格确认协议,直至出现以下界面,输入yes并回车 > ![](https://i0.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211641/120415_0430_14_nx8k6t.png?w=720&ssl=1) > 9. 安装开始后出现以下信息表示安装结束 > ![](https://i0.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211640/120415_0430_15_pl5ww4.png?w=720&ssl=1) > > ## 2.部署验证 {#2} > > 1. 进入JDK安装目录 > > cd /opt/bcdl/jdk1.6.0_07/bin > > > 1. 输入以下命令 > > ./java -version > > > 显示以下信息 > > ![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211639/120415_0430_16_wkdvzm.png?w=720&ssl=1) > > ## 3.程序卸载(非必要) {#3} > > jdk程序的卸载只要删除安装目录下的所有文件即可. > > 命令如下: > > # cd /opt/bcdl //进入bcdl文件夹 > # rm -Rf jdk1.6.0_07 //删除JDK > > > # 六、DB2数据库安装配置 {#db2} > > ## 1. DB2数据库安装 {#1db2} > > 1. 启动Xmanager连接solaris主机,以root用户登录 > 2. 右键点击桌面,在菜单中选择Hosts 》 Terminal Console打开命令行窗口 > 3. 进入DB2安装文件所在目录`/opt/software` > `cd /opt/software
</br>` > 4. 解压DB2压缩包 > `tar xvf db2_v95_sun64_server.tar
</br>` > 5. 解压后进入server目录 > `cd server
</br>` > 6. 启动DB2安装程序(**务必用root用户启动安装程序**) > `./db2setup` > 7. 选择”安装新产品(p)”,如下图 > ![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211639/120415_0430_17_owdyma.png?w=720&ssl=1) > 选择安装”DB2 Enterprise Server Edition Version 9.5″版本 > 8. 进入安装向导,点击”下一步”; > ![](https://i0.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211638/120415_0430_18_vnfkzt.png?w=720&ssl=1) > 9. 接受软件许可证协议,点击”下一步”; > ![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211637/120415_0430_19_awfkd3.png?w=720&ssl=1) > 10. 选择典型安装类型(Typical),点击”下一步”; > ![](https://i2.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211635/120415_0430_20_o5poib.png?w=720&ssl=1) > 11. 选择”在此计算机安装DB2企业服务器版本9.5并将设置保存在响应文件中”,点击”下一步”; > ![](https://i2.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211634/120415_0430_21_zhwms9.png?w=720&ssl=1) > 12. 选择安装的路径,安装目录统一定为`/opt/IBM/db2/V9.5`; > ![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211631/120415_0430_22_jjlapy.png?w=720&ssl=1) > 13. 设定DB2管理服务器的用户:取消`Use default UID`和`Use default GID`前的选择,修改`UID`和`GID`为`301`,设置`dasusr1`密码,选择”下一步”(指定`UID`和GID`是为了对DB2作集群,DB2集群时需要保证各机器上相同用户及组拥有相同的`UID`和`GID\`,对15步和16步的操作原因与此相同)。 > ![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211633/120415_0430_23_xzbsd4.png?w=720&ssl=1) > 14. 选择”创建DB2实例”,选择下一步; > ![](https://i2.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211632/120415_0430_24_xlgkts.png?w=720&ssl=1) > 15. 设定DB2实例的用户:取消`Use default UID`和`Use default GID`前的选择,给db2实例的用户设置密码,设置`UID`和`GID`为`302`,点击”下一步” > ![](https://i2.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211630/120415_0430_25_oahep1.png?w=720&ssl=1) > 16. 设定DB2用户自定义函数的用户:取消`Use default UID`和`Use default GID`前的选择,设置`UID`和`GID`为`303`,点击”下一步” > ![](https://i0.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211629/120415_0430_26_ufc3ek.png?w=720&ssl=1) > 17. 选择”在此计算机上不准备DB2工具目录”,点击”下一步” > ![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211628/120415_0430_27_nd2ips.png?w=720&ssl=1) > 18. 选择”不将DB2服务器设置为此时发送通知”,点击”下一步” > ![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211542/120415_0617_DB228_kcnhju.png?w=720&ssl=1) > 19. 总结信息,确认各项参数是否正确(用户、UID、GID等)。点击”完成” > ![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211542/120415_0617_DB229_knabxx.png?w=720&ssl=1) > 20. 安装进度提示 > ![](https://i2.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211541/120415_0617_DB230_cyjjl5.png?w=720&ssl=1) > 21. DB2软件安装完成,将”Log File”文本框内容进行备份,以备后续使用。 > ![](https://i2.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211539/120415_0617_DB231_sn1yk4.png?w=720&ssl=1)![](https://i0.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211539/120415_0617_DB232_w1kqtj.png?w=720&ssl=1) > 22. 为便于后续操作,将db2inst1用户的语言环境设为中文 > > `/opt/software` > > 将光标移动到文件最后,增加以下内容,保存并退出vi > > `/opt/software` > > ## 2. 操作系统参数调整 {#2} > > **此步骤请务必慎重操作!** > > 1. 以root用户登录 > 2. 输入以下命令获取DB2建议的操作系统参数值cd /opt/IBM/db2/V9.5/bin ./db2osconf > 3. 执行命令后会显示建议参数值(实际环境参数值可能与图中有差异,以实际环境显示为准) ![](https://i0.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211538/120415_0617_DB233_ojmd6f.png?w=720&ssl=1) > 4. 编辑系统参数文件 > vi /etc/system将光标移动到文件最后,将上图中set开头的行复制到文件中(实际环境参数值可能与图中有差异,以实际环境显示为准)![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211537/120415_0617_DB234_zi7w40.png?w=720&ssl=1)保存并退出vi > 5. 重新启动操作系统 > > `cd /opt/software
</br>` > > ## 3. 启动数据库相关服务 {#3} > > 1. 以root用户登录 > 2. 启动DB2管理服务器 > `. /export/home/dasusr1/das/dasprofile db2admin start`看到以下信息表示DB2管理服务器启动成功![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211536/120415_0617_DB235_jcq05m.png?w=720&ssl=1)如看到以下信息表示DB2管理服务器已经在运行中![](https://i2.wp.com/www.bestzhou.org/wp-content/uploads/2015/12/db2%E6%95%B0%E6%8D%AE%E5%BA%93%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97-1449706604-3.png?w=720&ssl=1) > 3. 切换到db2inst1 > > `/opt/bcdl` > > 启动db2数据库实例 > > `cp jdk*.sh /opt/bcdl` > > 看到以下信息表示DB2数据库实例启动成功![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211535/120415_0617_DB237_fdg0ft.png?w=720&ssl=1)如看到以下信息表示DB2数据库实例已经在运行中![](https://i2.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211533/120415_0617_DB238_xojxxj.png?w=720&ssl=1) > > ## 4. 备份数据库 {#4} > > `cd /opt/bcdl chmod +x jdk*.sh` > > ## 5. 还原数据库 {#5} > > 用UE编辑`creatab.sql`,修改”数据库连接名称”、”表的schame”等信息。另外,还需要编辑`DB2MOVE`文件夹下的`db2move.lst`文件,修改”表的schame”等信息。 > > 将修改过的这两个文件上传至新服务器: > > `chown bcdl:bcdl jdk*.sh
</br>` > > ## 6. 更新license {#6license} > > 1. 以root用户登录系统 > 2. 准备好db2 license文件,执行以下命令导入license > > `su – bcdl` > > 执行后如无异常,会显示以下结果![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211326/120415_0617_DB239_dqpykf.png?w=720&ssl=1) > > 1. 显示当前部署的license信息 > > `cd /opt/bcdl ./jdk-6u7-solaris-sparc.sh` > > 如下图所示,请确认license类型和过期时间![](https://i1.wp.com/res.cloudinary.com/the-backyard-of-stanley/image/upload/v1449211324/sdfasd1_bnofsx.png?w=720&ssl=1) > > ## 7. 部署验证 {#7} > > 1. 测试是否可以成功连接bcdl数据库,用db2inst1用户登录solaris,执行以下命令: > `$ db2 connect to bcdl user cmbbcd using cmbbcd` > 2. 查询用户表,测试是否可以查出记录 > `$ db2 select * from cmcs3_user` > > ## 8. 程序卸载 {#8} > > 1. 以root用户登录 > 2. 初始化环境变量 > `. /export/home/dasusr1/das/dasprofile` > 3. 停止db2管理服务器 > `db2admin stop` > 4. 删除db2管理服务器 > `/opt/IBM/db2/V9.5/instance/dasdrop`看到以下信息表示删除成功> DBI1070I Program dasdrop completed successfully. > 5. 切换到db2inst1用户 > `su – db2inst1`停止db2服务 > `$ db2stop force $ db2 terminate`退回root用户 `$ exit` > 6. 删除db2实例 > `/opt/IBM/db2/V9.5/instance/db2idrop db2inst1`看到以下信息表示删除成功> DBI1070I Program db2idrop completed successfully. > 7. 删除db2应用 > `/opt/IBM/db2/V9.5/install/db2_deinstall -a`看到以下信息表示成功> The execution completed successfully. > 8. 删除db2相关用户 > cd /opt/bcdl/jdk1.6.0_07/bin > > > groupdel dasadm1 > </br> > groupdel db2iadm1 > </br> > groupdel db2fadm1 > </br>“\`</li> </ol> > > ## 9. 常见问题 {#9} > > 1. 检查实例的诊断文件`db2diag.log`文件(默认放在DB2安装目录下),可定位错误。 > 2. 查DB2联机帮助,系统会给出基本解决方法。 > `$ db2 ? sql0001` > 3. 查看IBM的信息中心 > <http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=/com.ibm.db2.luw.admin.config.doc/doc/r0006012.html> 请下载各操作系统下DB2V9.5的补丁,可用补丁直接安装,不用原安装文件。 下载:[DB2 Server Fix Pack](http://www-1.ibm.com/support/docview.wss?rs=71&uid=swg21288088)