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

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

主站蜘蛛池模板: 常德市| 清原| 朝阳市| 万安县| 新丰县| 紫阳县| 电白县| 蓬莱市| 辽中县| 宣威市| 平潭县| 正镶白旗| 银川市| 化州市| 武定县| 兴隆县| 扶余县| 临邑县| 旺苍县| 甘洛县| 平南县| 巴东县| 安康市| 吉水县| 成武县| 安顺市| 格尔木市| 红河县| 麻城市| 综艺| 娱乐| 莱芜市| 绥中县| 石台县| 皋兰县| 宜黄县| 彝良县| 泰和县| 当涂县| 盐亭县| 伽师县|