官术网_书友最值得收藏!

Listing and attaching to instances

On a server environment, you may have many instances belonging to one DB2 installation or DB2HOME; obviously, you need to know about them and their name. For this purpose, you have the ability to use some specific commands to list them.

You also need to connect to these instances from remote locations to perform administration tasks; this, in the DB2 world, is called attaching.

Getting ready

In this recipe, we'll show how to list instances and attach to local and remote instances. Again, we'll use nodedb21 as server and nodedb22 as client.

How to do it...

Commands related to creating an instance are performed by the root user; listing is no exception and must be performed as root.

Listing instances

  1. The command to list current instances is db2ilist. It lists the instances that belong to one DB2 copy. List instances created in DBCOPY1:
    [root@nodedb21 ~]# /opt/ibm/db2/V9.7/instance/db2ilist db2inst1 db2inst2
    
  2. The same command from multipartitioned DB2HOME or DBCOPY2:
[root@nodedb21 ~]# /opt/ibm//db2/V9.7_part/instance/db2ilist db2instp

Attaching to instances

  1. On nodedb22, catalog db2inst1 both as TCPIP and SSL, on our client instance db2clnt1, created before. Because we set up SSL as a separate communication method for the db2inst1 instance, we have to specify it as the security method when cataloging the node (security SSL) with the SSL dedicated port. Catalog the nodes, as follows:
    [db2clnt1@nodedb22 db2dump]$ db2 "CATALOG TCPIP NODE NODE21_S REMOTE nodedb21 SERVER 50004 SECURITY SSL REMOTE_INSTANCE db2inst1 SYSTEM nodedb21 OSTYPE LINUXX8664" DB20000I The CATALOG TCPIP NODE command completed successfully. DB21056W Directory changes may not be effective until the directory cache is refreshed. [db2clnt1@nodedb22 db2dump]$ db2 "CATALOG TCPIP NODE NODE21_1 REMOTE nodedb21 SERVER 50001 REMOTE_INSTANCE db2inst1 SYSTEM nodedb21 OSTYPE LINUXX8664" DB20000I The CATALOG TCPIP NODE command completed successfully. DB21056W Directory changes may not be effective until the directory cache is refreshed.
    
  2. List the cataloged nodes:
    [db2clnt1@nodedb22 ~]$ db2 "list node directory" Node Directory Number of entries in the directory = 2 Node 1 entry: Node name = NODE21_S Comment = Directory entry type = LOCAL Protocol = TCPIP Hostname = nodedb21 Service name = 50004 Security type = SSL Remote instance name = db2inst1 System = nodedb21 Operating system type = LINUXX8664 Node 2 entry: Node name = NODE21_1 Comment = Directory entry type = LOCAL Protocol = TCPIP Hostname = nodedb21 Service name = 50001 Remote instance name = db2inst1 System = nodedb21 Operating system type = LINUXX8664
    
  3. Attach to instance db2inst1, using first the SSL port, and next the TCP/IP port:
    [db2clnt1@nodedb22 ~]$ db2 "attach to NODE21_S user db2inst1 using db2inst1" Instance Attachment Information Instance server = DB2/LINUXX8664 9.7.4 Authorization ID = DB2INST1 Local instance alias = NODE21_S [db2clnt1@nodedb22 ~]$ db2 " attach to node21_1 user db2inst1 using db2inst1" Instance Attachment Information Instance server = DB2/LINUXX8664 9.7.4 Authorization ID = DB2INST1 Local instance alias = NODE21_1
    
  4. Attaching to an instance with the Control Center:

    In Control Center navigate to instance db2inst1, right-click, and choose Attach.

How it works...

Instances are registered in a file named global register. This file is always updated when an instance is created or dropped.

When you attach to an instance from a client, you can see that the port on the server is changing its status from listening to established:

[root@nodedb21 ~]# netstat -nlpta | grep 5000* tcp 0 0 0.0.0.0:50001 0.0.0.0:* LISTEN 19974/db2sysc 0 tcp 0 0 0.0.0.0:50003 0.0.0.0:* LISTEN 26082/db2sysc 0 tcp 0 0 0.0.0.0:50004 0.0.0.0:* LISTEN 19974/db2sysc 0 tcp 0 0 10.231.56.117:50001 10.231.56.118:49321 TIME_WAIT - tcp 0 0 10.231.56.117:50004 10.231.56.118:48187 ESTABLISHED 19974/db2sysc 0

This appears on nodedb21, after attaching to instance db2inst1, using the SSL port 50004.

There's more...

There is a straightforward method to verify that one instance is listening on its assigned port from a client. For this purpose, you can try to connect with telnet on that port:

[db2inst1@nodedb22 ~]$ telnet nodedb21 50004 Trying 10.231.56.117... Connected to nodedb21. Escape character is ‘^]'.

This means that our port assigned to SSL is listening. To detach from an instance, simply issue the DETACH command.

Another indirect method to list instances on a server is to use the discovery process provided by Configuration Assistant or Control Center locally or remotely.

See also

Chapter 11,Using DB2 Discovery

主站蜘蛛池模板: 友谊县| 土默特左旗| 黄山市| 桦甸市| 盐边县| 壶关县| 深州市| 林口县| 龙泉市| 永吉县| 鄂伦春自治旗| 蓬安县| 青海省| 上犹县| 遂平县| 汝阳县| 鄄城县| 三都| 三河市| 敖汉旗| 和林格尔县| 靖江市| 南安市| 本溪| 双鸭山市| 盘锦市| 乌兰察布市| 民权县| 湾仔区| 商水县| 万全县| 东兰县| 江永县| 清苑县| 祁阳县| 大同县| 江西省| 黔南| 尼木县| 中山市| 沙雅县|