Unit 3 - Demonstration 1: Create a new Db2 instance

Introduction

Creating a new Db2 instance, particularly for educational or training purposes, involves several critical steps. This process not only entails the actual creation of the instance but also requires understanding how to configure, manage, and troubleshoot it effectively. Below is a detailed, step-by-step guide with troubleshooting tips for setting up a Db2 instance on a Linux system:

Step-by-Step Guide to Create a New Db2 Instance

Task 1: Prepare for the Db2 Instance Creation

  1. Log into the Linux System: Begin by logging into your Linux server using a user account with sufficient privileges to switch to root. In this case, log in as inst00 with the password ibm2blue.
    ssh inst00@<hostname>
  2. Open a Terminal Session: Once logged in, access the terminal. This can often be done by right-clicking on the desktop and selecting "Open in Terminal" or by using a terminal application.
  3. Verify Current Db2 Environment:
    db2 get instance
    db2 list db directory
    db2start

These steps help confirm the environment's status before creating a new instance, ensuring there are no conflicts.

Task 2: Create the New Db2 Instance
  1. Switch to Root User: To perform system-level operations such as creating Db2 instances, switch to the root user.
    su - root

    Enter the root password dalvm3 when prompted.

  2. Check Existing Db2 Instances: Verify which Db2 instances are already installed to avoid naming conflicts.
    /opt/ibm/db2/V11.1/instance/db2ilist
  3. Create the New Instance: Use the db2icrt command to create a new Db2 instance named inst23 with a fenced user fenced23.
    /opt/ibm/db2/V11.1/instance/db2icrt -u fenced23 inst23

This command initializes the installation and configures the necessary Db2 instance parameters. The command's output will indicate the progress and confirm successful completion.

Task 3: Verify and Troubleshoot Instance Creation
  1. Check the Creation Log: Review the installation log to ensure there were no errors during the instance creation.
    cat /tmp/db2icrt.log.14455
  2. Test the New Instance: Switch to the new instance owner inst23.
    su - inst23

    Start the Db2 instance to verify it's working correctly.

    db2start

Troubleshooting Common Issues

  • Permission Errors: Ensure the root and instance owner have appropriate permissions. Check user groups and permissions for the directory where Db2 is installed.
  • Instance Start Failures: Review the error codes in the terminal or logs. Common issues might include misconfigurations in network settings or insufficient resources.
  • Log Review: Always check the logs after running Db2 commands. If there are initialization errors, logs may provide specific codes and descriptions that help in troubleshooting.

This structured approach not only facilitates the creation of a new Db2 instance but also incorporates best practices for verification and troubleshooting, ensuring a smooth setup process for educational purposes.

Detailed Setup Guide for Db2 Instance Configuration

Preparation Steps

  1. Verify System Requirements: Ensure the Linux system meets all hardware and software requirements for Db2 installation, such as CPU, memory, and disk space.
  2. Install Db2 Software: If not already installed, install Db2 following the IBM provided installation guide specific to the version and environment. Use root privileges for installation.
    cd /path/to/db2/installation/files
    sudo ./db2_install
  3. Create Required Users and Groups: Ensure that the inst23 user and fenced23 user exist and are configured correctly, along with their respective groups.
    sudo groupadd db2iadm1
    sudo groupadd db2fadm1
    sudo useradd -g db2iadm1 -m inst23
    sudo useradd -g db2fadm1 -m fenced23

Instance Creation and Initial Configuration

  1. Log in as Root and Create Db2 Instance: Switch to root user and create the Db2 instance inst23 with fenced23 as the fenced user.
    su -
    /opt/ibm/db2/V11.1/instance/db2icrt -u fenced23 inst23
  2. Environment Setup for inst23: Log in as inst23 to set environment variables needed for Db2 operations. Add the following commands to .bash_profile for inst23:
    export DB2INSTANCE=inst23
    export PATH=$PATH:/opt/ibm/db2/V11.1/bin
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ibm/db2/V11.1/lib

Configuration for Network and Diagnostic

  1. Configure TCP/IP Network Communication: Set DB2 to use TCP/IP for network communication.
    db2set DB2COMM=tcpip
  2. Set Service Name and Diagnostic Path: Configure the service name and the path for diagnostic logs.
    db2 update dbm cfg using SVCENAME 50000
    mkdir /home/inst23/diag
    db2 update dbm cfg using DIAGPATH /home/inst23/diag

Starting the Instance and Verifying Configuration

  1. Start the Db2 Instance: Start the newly created Db2 instance to ensure all configurations are loaded.
    db2start
  2. Verify Configuration Settings: Check the effective settings of the TCP/IP communication and diagnostic path.
    db2 get dbm cfg | grep SVCENAME
    db2 get dbm cfg | grep DIAGPATH

Error Handling and Troubleshooting

  1. Common Error Checking: If any command fails, check the db2diag.log for detailed error messages and troubleshooting tips.
    less /home/inst23/sqllib/db2dump/db2diag.log
  2. Permission and Access Errors: If encountering permission errors, verify that the inst23 user has the correct permissions for the directories and files involved in the configuration.
    ls -l /home/inst23/
    chmod -R 755 /home/inst23/
  3. Network Configuration Errors: Ensure that the specified service name does not conflict with other services and that TCP/IP is properly configured and operational on the system.

Maintenance and Regular Checks

  1. Backup Configuration Files: Regularly back up configuration files and critical data.
    db2 backup db mydb to /path/to/backup/location
  2. Apply Security Patches and Updates: Regularly update the Db2 software to ensure it is secure and up to date. Check for updates and apply them.
    db2updv11.1