Creating and configuring an instance for multipartitioned environments
The IBM DB2 database multipartitioned feature offers the ability to distribute a large database onto different physical servers or the same SMP server, balancing the workload onto multiple databases that are working as one, offering a very scalable way of data processing. We may have all the database partitions reside on the same server, this method of database partitioning is called logical partitioning. There is another scenario when the database partitions are spanned on different physical servers; this partitioning method is called physical partitioning.
An instance in a multipartitioned configuration is not very different by a non-partitioned instance, if it is running on a logical partitioning scheme. To use only physical partitioning, or physical partitioning combined with logical partitioning, an instance must be configured as shared across all the database partitions. In this recipe, we will use the last scenario.
The instance is created once on one node; on the other participant nodes, you have to create just the instance owner user with the same user ID (UID) and GIDs and the same home directory as on the instance owner node. In the following recipe, we will configure
servers for the purpose of multipartitioning and will create a new instance named db2instp
.
Notice that in this recipe we will use node and partition termsinterchangeably
To install a multipartitioned instance, we need to prepare a suitable environment. For this recipe, we will use the two Linux servers named nodedb21
and nodedb22
, mentioned before. nodedb21
will contain the instance home and will export it through NFS to the nodedb22
system. We will also use a new disk partition, defined on nodedb21
, for instance home /db2partinst
, which, in our case, is a Linux LVM partition. We will create users on both servers with the same UID, and will install IBM DB2 ESE in a new location or DB2HOME—/opt/ibm/db2/V9.7_part
on nodedb21
with the create a response file option. On nodedb22
, we'll also install IBM DB2 ESE, in the location /opt/ibm/db2/V9.7_part
, using the response file created during installation on nodedb21
.
Because this is not a Linux book, we do not cover how to install NFS or how to create a new Linux partition. As a preliminary task, you should check if you have NFS and portmap installed and running on both servers.
As user root
, execute the following commands on both servers:
To check if we have NFS and portmap on nodedb21
:
To check their current status on nodedb21
:
Set up NFS for sharing the instance home
To automatically export /db2partinst
on system boot, add your hostnames or the corresponding IP numbers to the /etc/exports
file. On nodedb21
, add the following line in /etc/exports
:
To export the partition immediately, execute the following command:
On nodedb22
, as user root
, create a directory /db2partinst
, used as mount point for /db2partinst
, exported from nodedb21
:
In /etc/fstab
on nodedb22
, to mount /db2partinst
on system boot, add the following line:
To mount the partition immediately on nodedb22
, issue the following command:
Creating the instance owner and fenced user
On nodedb21
, create the instance owner db2instp
and the fenced user db2fencp
. Instance home will be located in /db2partinst/db2instp
:
Repeat step 1 on nodedb22
and ignore any warnings.
Set up SSH for client authentication
In a physical multipartitioned environment, any instance owner user has to be able to execute commands on any participant node. To ensure this, we need to establish user equivalence or host equivalence between nodes. Actually, we have two methods: one is with RSH, which is less secure and the other is using SSH, which is secure. With SSH, there are two methods: one is host-based authentication and the other is client-based authentication. Next, we will implement client-based authentication; this method fits better with a small number of partitions, as in our example.
As user db2instp
on nodedb21
, execute the following commands:
As user db2instp
on nodedb22
, execute the following commands:
Go back on nodedb21
and issue the following commands to set up a host trust relationship:
Verify that the client authentication is working; on nodedb21
, issue ssh nodedb22 date
(do it the other way around—now it should work without asking for a password):
Install DB2 ESE software with a response file option
A response file is a text file containing installation and configuration information such as paths, installation options etc. It can be created and recorded using interactive installation and replayed by other installations to perform the same steps.
Launch db2setup
, and, at step 4 of the installation wizard (Install action), check the Install DB2 Enterprise Server Edition on this computer and save my setting in a response file option. Provide the complete path to the response file.
At step 5, specify /opt/ibm/db2/V9.7_part
for Installation directory.
At step 7 (Partitioning option), check Multiple partition instance.
Next, for DB2 instance owner, choose db2instp
and, for fenced user, choose db2fencp
. On the next screen, choose Do not create tools catalog. At the end of installation, we will find (in the directory chosen at step 4 of installation wizard) two files with .rsp
extension; you need to copy just db2ese_addpart.rsp
to nodedb22
and issue on nodedb22
, from the installation directory:
Configuring communication for inter-partition command execution
The communication method of inter-partition command execution is controlled by DB2RSCHCM registry variable. Because our choice is SSH for inter-partition command execution, you must next set the DB2RSHCMD
variable to point to SSH executable DB2RSHCMD=/usr/bin/ssh
. If this variable is not set, the rsh
method is used by default:
To verify the current DB2 registry variables, issue the following command:
In the db2nodes.cfg
file, database partition configuration file, located in $INSTANCEHOME/sqllib
, set the participant nodes. Define three nodes—two on nodedb21
, partion number 0
with logical port 0
and partition number 2
with logical port 1
and one on nodedb22
, partition 1
with logical port 0
. After adding the nodes we should have the following structure:
Instance db2instp
knows about the current nodes by reading their definition from db2nodes
.cfg database partition configuration file. The logical ports and number of maximum partitions per server are limited by the range defined within /etc/services
file as follows:
The structure of db2nodes.cfg
, in some cases, can be further elaborated with optional information such as resourcenames
or netnames
; in our case being a simple setup used for demonstration purpose we have defined only the nodes, hostnames, and the logical ports.
Under Unix and Linux, db2nodes
has the following complete format:
Under MS Windows, db2nodes
has the following complete format:
DB2 has two utilities to verify that communication between nodes is working: db2_all
and rah. You can also issue practically any administrative command (backup, restore, setting parameters, and so on) across the database partitions with these utilities.
An example of using db2_all
for verification:
The same using rah
:
Obviously, there is also a possibility of using a shared disk, formatted with a concurrent file system, such as, IBM's GPFS or Red Hat GFS, for instance home, and used for sharing across the nodes instead of using NFS exports.
On Windows, it is not recommended to edit the db2nodes.cfg file manually; use the
The following commands instead:
db2nlist
—to list database partitions
db2ncrt
—to add a database partition server to an instance
db2ndrop
—to drop a database partition server to an instance
db2nchg
—to modify a database partition server configuration
The Converting a non-partitioned database to a multipartitioned database on MS Windows recipe in Chapter 3, DB2 Multipartitioned Databases—Administration and Configuration