ITeye博客

DB2远程连接配置总结

xiaosu_521 · 2008-03-12 23:49 · Database · CSS · Windows · DB2 · Unix · Linux · Markdown

<meta content="text/html; charset=utf-8" http-equiv="CONTENT-TYPE"> <meta name="GENERATOR" content="OpenOffice.org 2.0 (Linux)"> <meta name="AUTHOR" content="sl"> <meta name="CREATED" content="20080312;15020000"> <meta name="CHANGEDBY" content="sl"> <meta name="CHANGED" content="20080312;17230000"> <style type="text/css"> </style> <p style='margin-bottom: 0cm;'><font size='3'>实现:在客户端远程连接服务器端的</font><font size='3'>db2</font><font size='3'>(</font><font size='3'>db2</font><font size='3'>之间的互连)</font></p> <p style='margin-bottom: 0cm;'><font size='3'><br/></font> </p> <p style='margin-bottom: 0cm;'><font size='3'>本文假定如下:</font></p> <p style='margin-bottom: 0cm;'><font size='3'>客户端为</font><font size='3'>windows/linux/unix</font><font size='3'>,客户端也已经安装了</font><font size='3'>db2</font><font size='3'>或者客户端</font></p> <p style='margin-bottom: 0cm;'><font size='3'>服务器端为</font><font size='3'>windows/linux/unix</font></p> <p style='margin-bottom: 0cm;'><font size='3'>客户端</font><font size='3'>ip</font><font size='3'>:</font><font size='3'>192.168.42.147</font><font size='3'>,服务器端</font><font size='3'>ip</font><font size='3'>为</font><font size='3'>192.168.42.102</font></p> <p style='margin-bottom: 0cm;'><font size='3'><br/></font> </p> <p style='margin-bottom: 0cm;'><font size='3'>步骤:</font></p> <ol> <li> <p style='margin-bottom: 0cm;'><font size='3'>在客户端建立服务器端数据库的节点</font></p> </li> </ol> <p style='margin-bottom: 0cm;'><font size='3'>在客户端命令行执行</font></p> <p style='margin-bottom: 0cm;'><font size='3'>Db2 catalog tcpip node test remote 192.168.42.102 server 50000</font></p> <p style='margin-bottom: 0cm;'><font size='3'>注:</font><font size='3'>test</font><font size='3'>为在客户端定义的节点,名字可以任意</font></p> <p style='text-indent: 0.77cm; margin-bottom: 0cm;'><font size='3'>192.168.42.102</font><font size='3'>为客户端的</font><font size='3'>ip</font></p> <p style='text-indent: 0.77cm; margin-bottom: 0cm;'><font size='3'>50000</font><font size='3'>为</font><font size='3'>DB2</font><font size='3'>使用的端口</font></p> <p style='text-indent: 0.77cm; margin-bottom: 0cm;'><font size='3'>查找服务器端</font><font size='3'>DB2</font><font size='3'>使用的端口,</font></p> <p style='text-indent: 0.77cm; margin-bottom: 0cm;'><font size='3'>如果服务器端为</font><font size='3'>linux</font><font size='3'>,可以访问</font><font size='3'>/etc/services</font><font size='3'>文件,如果你的实例名为</font><font size='3'>db2inst1</font><font size='3'>,找到如下行</font></p> <p style='text-indent: 0.77cm; margin-bottom: 0cm;'><font size='3'>db2inst1 50000/tcp</font></p> <p style='text-indent: 0.77cm; margin-bottom: 0cm;'><font size='3'>如果服务器端为</font><font size='3'>windows</font><font size='3'>,查看</font><font size='3'>X:\WINNT\System32\drivers\etc\services</font></p> <p style='text-indent: 0.77cm; margin-bottom: 0cm;'><font size='3'><br/></font> </p> <ol start='2'> <li> <p style='margin-bottom: 0cm;'><font size='3'>绑定节点和客户端的数据库</font></p> </li> </ol> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'>执行下面的命令</font><font size='3'>db2 catalog db coshine at node test</font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'>注:</font><font size='3'>coshine</font><font size='3'>为服务器端中你想要连接的数据库名</font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'> <font size='3'>Test</font><font size='3'>就是步骤一种定义的节点</font></p> <ol start='3'> <li> <p style='margin-bottom: 0cm;'><font size='3'>使绑定生效</font></p> </li> </ol> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'>执行</font><font size='3'>db2 terminate</font></p> <ol start='4'> <li> <p style='margin-bottom: 0cm;'><font size='3' color='#000000'>设定客户端<font>db2codepage(</font></font><font size='3' color='#000000'>代码页设置<font>)</font></font><font size='3' color='#000000'>即字符编码</font></p> </li> </ol> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'>先在服务器端查询<font>db2codepage</font></font><font size='3' color='#000000'>,执行<font>db2set –all</font></font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'><font>[i] DB2_EXTENDED_OPTIMIZATION=ON</font></font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'><font>[i] DB2_DISABLE_FLUSH_LOG=ON</font></font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'><font>[i] AUTOSTART=YES</font></font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'><font>[i] DB2_STRIPED_CONTAINERS=ON</font></font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'><font color='#000000'>[i] DB2_HASH_JOIN=Y</font></font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'><font>[i] DB2COMM=tcpip</font></font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'><font>[i] DB2CODEPAGE=819</font></font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'><font>[i] DB2_PARALLEL_IO=*</font></font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'>可以看到服务器端的<font>DB2CODEPAGE</font></font><font size='3' color='#000000'>为<font>819</font></font><font size='3' color='#000000'>,所以客户端也必须设置为这个数字</font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3' color='#000000'>执行<font>db2set db2codepage=819</font></font></p> <ol start='5'> <li> <p style='margin-bottom: 0cm;'><font size='3'>进行连接</font></p> </li> </ol> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'>执行</font><font size='3'>db2 connect to coshine user user_name using password</font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'><br/></font> </p> <p style='margin-bottom: 0cm;'><font size='3'>注释</font></p> <p style='margin-bottom: 0cm;'><font size='3'>Db2codepage</font><font size='3'>:即</font><font size='3'>db2</font><font size='3'>数据库的编码方式</font></p> <p style='margin-bottom: 0cm;'><font size='3' color='#000000'><font>db2codepage=1386(</font>简体中文<font>)<br/> db2country=86(</font>中国<font>)</font></font></p> <p style='margin-bottom: 0cm;'><font size='3' style='font-size: 9pt;'>一个数据库一旦建立,他的代码页就没有办法改,   </font><font size='3'><font style='font-size: 9pt;'><font><br/>    <br/>  db2set   DB2CODEPAGE=1386</font></font></font><font size='3' style='font-size: 9pt;'>只能改变代码页环境,不能改变数据库的代码页</font><font size='3'><font><font color='#000000'><br/>    </font></font></font><font size='3'>如果不能连接:检查如下是否正确</font></p> <ol> <li> <p style='margin-bottom: 0cm;'><font size='3'>确保可以</font><font size='3'>ping</font><font size='3'>通服务器端:</font><font size='3'>ping 192.168.42.102</font></p> </li> <li> <p style='margin-bottom: 0cm;'><font size='3'>确保服务器端的</font><font size='3'>db2</font><font size='3'>已经启动:</font><font size='3'>db2start</font></p> </li> <li> <p style='margin-bottom: 0cm;'><font size='3'>确保客户端</font><font size='3'><font style='font-size: 9pt;'><font><font color='#000000'>DB2COMM</font></font></font></font><font size='3' style='font-size: 9pt;'><font color='#000000'>设置为</font></font><font size='3'><font style='font-size: 9pt;'><font><font color='#000000'>tcpip</font></font></font></font></p> </li> </ol> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'>先查看</font><font size='3'>db2comm</font><font size='3'>设置:</font><font size='3'>db2set –all</font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'>如果没有设置这个注册表,执行</font><font size='3'>db2set db2comm=tcpip</font></p> <ol start='4'> <li> <p style='margin-bottom: 0cm;'><font size='3'>将</font><font size='3'>SVCENAME</font><font size='3'>设置成</font><font size='3'>/etc/services</font><font size='3'>中的端口号或者服务名了吗?</font></p> </li> </ol> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'>执行</font><font size='3'>db2 get dbm cfg</font><font size='3'>查看,找到</font><font size='3'>SVCENAME</font><font size='3'>,如果当前值不是服务器端的端口号或者服务名,进行更新设置</font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'>执行:</font><font size='3'>db2 update dbm cfg SVCENAME db2inst1</font></p> <p style='text-indent: 0.77cm; margin-bottom: 0cm;'><font size='3'>注:</font><font size='3'>db2inst1</font><font size='3'>为服务名,这个在</font><font size='3'>/etc/services</font><font size='3'>文件中</font><font size='3'>db2inst1 50000/tcp</font></p> <p style='margin-left: 0.64cm; margin-bottom: 0cm;'><font size='3'>一致</font></p> <font size='3'> </font>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。