- 论坛徽章:
- 0
|
产品:DB2 UDB
平台:AIX,Solaris,HP-UX,Linux,Windows
版本:V8 V9.1V9.5
问题描述:
出于各种各样的原因,在DB2服务器使用过程中,用户有可能需要修改DB2数据库服务器的主机名,那么DB2需要做哪些相应的修改呢?
问题解答:
为了修改DB2服务器的主机名,我们可以在DB2数据库服务器上执行以下步骤来实现:
1) 停止DB2管理服务器(DAS)?/SPAN>DB2实例
a)db2admin stop
在Windows上,您可以直接执行命令来停止DAS,在Linux和UNIX上,您可以执行命令来获取DAS实例的名称,然后再停止DAS,如
db2set -all |grep DB2ADMINSERVER
[g] DB2ADMINSERVER=das91
然后su – das91后执行命令“db2admin stop”
b) db2stop
如果有多个实例,需要全部停止。可以用db2ilist命令列出该主机上所有的实例,然后一一停止
如果是Windows系统,您可以
set DB2INSTANCE=INST1
db2stop
这样来停止实例
如果是Linux或UNIX系统,您可以分别登录实例用户来执行”db2stop”
2)修改服务器主机名(各种操作系统如何修改主机名,请参阅相关操作系统文档)
3)以DB2实例用户登录后,执行
db2set -g DB2SYSTEM=<new hostname>
db2 terminate
上述命令,在Windows上,应该不会遇到问题,但是如果您的操作系统是Linux或者是UNIX的话,有可能此时遇到错误,如:
如果是V8、V9.1,您将遇到如下错误信息:
$ db2set –g DB2SYSTEM=pirates
DB2SET processing complete, rc = -2029059830, SQLCODE = 0
如果是V9.5,您将遇到如下错误信息:
$ db2set -g DB2SYSTEM=privates
DBI1309E System error.
Explanation:
The tool encountered an operating system error.
User response:
A system error was encountered during registry access. Ensure that there
is enough space on the file system where the registry is located, and
that there is a valid LAN connection if the registry is remote.
上述错误的原因是因为全局变量的操作涉及到系统级别的文件,实例用户并无相应权限来修改文件,而是需要root权限。我们可以用以下方法来完成该命令的执行:
$ su root
root's Password:
$ db2set -g db2system=privates
$ db2 terminate
注意:上述su命令用不带- 的,使得root具有实例用户的环境变量
如果有多个实例,上述命令只需执行一次
用实例用户检查修改情况,可以确认已经修改完成。
$ db2set –all |grep DB2SYSTEM |
|