1.参数设置
[db2inst1@centos6 ~]$ db2set -all #查看
[i] DB2PROCESSORS=0
[i] DB2COMM=tcpip #TCPIP方式
[g] DB2SYSTEM=centos6
[g] DB2INSTDEF=db2inst1 #DB2实例名
[g] DB2ADMINSERVER=dasusr1
[db2inst1@centos6 ~]$ db2set -null DB2COMM #设置成 null
[db2inst1@centos6 ~]$ db2set -all
[i] DB2PROCESSORS=0
[i] DB2COMM=NULL
[g] DB2SYSTEM=centos6
[g] DB2INSTDEF=db2inst1
[g] DB2ADMINSERVER=dasusr1
[db2inst1@centos6 ~]$ db2stop
SQL1064N DB2STOP processing was successful.
[db2inst1@centos6 ~]$ db2start
SQL1063N DB2START processing was successful.
2.效果验证
此时在本地登录
db2 => connect to sample user db2inst1
Enter current password for db2inst1:
Database Connection Information
Database server = DB2/LINUXX8664 9.7.1
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
db2 =>
在远程登录报错
db2 => connect to db23416 user db2inst1 using schina
SQL30081N A communication error has been detected. Communication protocol
being used: "TCP/IP". Communication API being used: "SOCKETS". Location
where the error was detected: "192.168.234.16". Communication function
detecting the error: "connect". Protocol specific error code(s): "111", "*",
"*". SQLSTATE=08001
db2 =>
[db2inst1@centos6 ~]$ db2set db2comm=tcpip #开启TCPIP链接
[db2inst1@centos6 ~]$ db2stop
SQL1064N DB2STOP processing was successful.
[db2inst1@centos6 ~]$ db2start
SQL1063N DB2START processing was successful.
在远程客户端再次登录
db2 => connect to db23416 user db2inst1 using schina
Database Connection Information
Database server = DB2/LINUXX8664 9.7.1
SQL authorization ID = DB2INST1
Local database alias = DB23416
db2 =>
3. 附加 命令行设置远程数据库映射到本地
1.确认DB2COMM为TCPIP
[db2inst1@centos6 ~]$ db2set -all #查看
[i] DB2PROCESSORS=0
[i] DB2COMM=tcpip #TCPIP方式
[g] DB2SYSTEM=centos6
[g] DB2INSTDEF=db2inst1 #DB2实例名
[g] DB2ADMINSERVER=dasusr1
2.确认全局环境变量SVCENAME
把查找到的服务名,更新到dbm中
db2 update dbm cfg using svcenameserviceName(相应的服务名)
[db2inst1@centos6 ~]$ db2 get dbm cfg |grep "SVCENAME"
TCP/IP Service name (SVCENAME) = DB2_db2inst1
SSL service name (SSL_SVCENAME) =
[db2inst1@centos6 ~]$ cat /etc/services |grep db2
DB2_db2inst1 50000/tcp
ibm-db2 523/tcp # IBM-DB2
ibm-db2 523/udp # IBM-DB2
questdb2-lnchr 5677/tcp # Quest Central DB2 Launchr
questdb2-lnchr 5677/udp # Quest Central DB2 Launchr
qdb2service 45825/tcp # Qpuncture Data Access Service
qdb2service 45825/udp # Qpuncture Data Access Service
[db2inst1@centos6 ~]$
--注册节点
catalog tcpip node testnode remote 192.168.234.16 server 50000
--注册数据库
CATALOG DATABASE SAMPLE(远程数据库名) AS db23416(远程库在本地的别名) AT NODE testnode;
--删除注册节点
uncatalog node testnode;
--删除注册数据库
uncatalog database db23416;
--连接测试
db2 => connect to db23416 user db2inst1 using schina
Database Connection Information
Database server = DB2/LINUXX8664 9.7.1
SQL authorization ID = DB2INST1
Local database alias = DB23416
db2 =>
4.常见报错
4.1
问题现象
db2stop时报错
SQL1025N The database manager was not stopped because databases are still active.
解决方案
使用db2stop force命令