Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
IBM DB2 9.7 Advanced Administration Cookbook

You're reading from   IBM DB2 9.7 Advanced Administration Cookbook Over 100 recipes focused on advanced administration tasks to build and configure powerful databases with IBM DB2 book and ebook

Arrow left icon
Product type Paperback
Published in Feb 2012
Publisher Packt
ISBN-13 9781849683326
Length 480 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

Table of Contents (21) Chapters Close

IBM DB2 9.7 Advanced Administration Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. DB2 Instance—Administration and Configuration FREE CHAPTER 2. Administration and Configuration of the DB2 Non-partitioned Database 3. DB2 Multipartitioned Databases—Administration and Configuration 4. Storage—Using DB2 Table Spaces 5. DB2 Buffer Pools 6. Database Objects 7. DB2 Backup and Recovery 8. DB2 High Availability 9. Problem Determination, Event Sources, and Files 10. DB2 Security 11. Connectivity and Networking 12. Monitoring 13. DB2 Tuning and Optimization 14. IBM pureScale Technology and DB2 Index

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

You have been reading a chapter from
IBM DB2 9.7 Advanced Administration Cookbook
Published in: Feb 2012
Publisher: Packt
ISBN-13: 9781849683326
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime