Skip to content

Instantly share code, notes, and snippets.

@fabianoflorentino
Created June 17, 2021 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabianoflorentino/b5152394c9861f89da79ff7e1e9cd21f to your computer and use it in GitHub Desktop.
Save fabianoflorentino/b5152394c9861f89da79ff7e1e9cd21f to your computer and use it in GitHub Desktop.

Install and Configure IBM DB2 on Redhat Family

Requirements

  • 1 server

    • Any Operation System
    • Free SSH Access on Port 22
    • Root Full Access
    • Python 2.7+
    • Pip
    • Ansible
  • 2 servers

    • Operation System Redhat Family
    • IBM DB2 Package for Linux (v11.5_linuxx64_dec.tar.gz)
    • 2 Disks - 50GB
      • sda
      • sdb
    • 2 Gi of Ram
    • 2 vCPU's

Pre Tasks

  • 1. Copy the package

After clone this repository you need download IBM DB2 Package for Linux (v11.5_linuxx64_dec.tar.gz) and put into folder "./roles/db2_default_installation/files/"

  • 2. Inventory

You must configure the inventory file with the hosts that you will be configuring and installing IBM DB2 for.

Ex.

[all]
# hostname ansible_host=1.2.3.4
db2-primary ansible_host=192.168.7.143
db2-standby ansible_host=192.168.7.162

[disk_configuration]
db2-primary
db2-standby

[default_installation]
db2-primary
db2-standby

[hadr]
db2-primary
db2-standby

Configure SSH Access

Configure the SSH key for the ansible user. That user will be responsible for perform all configuration management.

ansible-playbook -i inventory/inventory.ini -u root -e ansible_ssh_user = root db2-ssh.yaml

The first run must be done with the root user and password.

The tasks performed in this process are:

  • Create group of service
  • Create user of service
  • Make group of service parts sudoers
  • Set authorized key taken from file

Prepare Disk for Database

Create filesystem separately on a disk apart from the operating system.

As a best practice, it is recommended to install the program and database on a disk the part of the operating system, increasing the resilience of the database.

ansible-playbook -i inventory/inventory.ini -u ansible -b -e ansible_ssh_user = ansible db2-setup-disks.yaml

The tasks performed in this process are:

  • Enable LVM 2
  • Create new Volume Group
  • Create new Logical Volume
  • Create a filesystem
  • Directory to mount
  • Mount new directory
  • Sets ACL for sre on "/opt/ibm/db2"

Prepare System

Prepare servers for basic prerequisites for installation within good practice.

ansible-playbook -i inventory/inventory.ini -u ansible.cfg -b -e ansible_ssh_user = ansible db2-prepare.yaml

The tasks performed in this process are:

  • Configure Hosts
  • Remove old configuration of network
  • Configure the network
  • Set PATH environment varible
  • Update System
  • Install Essentials Packages
  • Systemd Enabled
  • Systemd Disabled
  • Selinux Disable
  • Configure NTP service
  • Update Host Hostname

Install IBM DB2

Standard installation of IBM DB2 on Linux operating systems of the Redhat family.

ansible-playbook -i inventory/inventory.ini -u ansible -b -e ansible_ssh_user = ansible db2-default-installat
ion.yaml

The tasks performed in this process are:

  • Copy IBM DB2 install to Server
  • Copy Response File
  • Check if db2prereqcheck ran
  • Verify Pre Requisit to IBM DB2
  • Check if IBM DB2 is installed
  • Install IBM DB2
  • Check if IBM DB2 is started
  • Start IBM DB2
  • Installation IBM DB2 Status

Enable HADR on Database

Creating high availability environment with the IBM DB2 HADR function.

ansible-playbook -i inventory/inventory.ini -u ansible -b -e ansible_ssh_user = ansible db2-hadr.yaml

Primary Database

Configuration of the primary IBM DB2 database server.

The tasks performed in this process are:

  • Check if IBM DB2 is started
  • Verify if Database exists
  • Create database using the db2sampl command
  • Enable it for log archiving.
  • Status log archiving
  • Path to store backup
  • Directory of Backup
  • Backup Database
  • Status Backup Database
  • File backup Name
  • Fetch Public SSH Key
  • Copy SSH Public Key from Standby
  • Copy backup file from Primary to Standby
  • Status Sync Backup

Standby Database

Configuration of the IBM DB2 database standby server.

The tasks performed in this process are:

  • Verify file backup name
  • File Backup Name
  • Set owner to db2inst1
  • Verify if Database exists
  • Restore Backup from Primary
  • Status restore database

Enabling HADR

Enabling the HADR function of IBM DB2.

The tasks performed in this process are:

  • Verify if HADR is Up and Running on Standby - Before
  • Verify if HADR is Up and Running on Primary - Before
  • Enable HADR on Standby
  • Enable HADR on Primary
  • Verify if HADR is Up and Running on Primary - After
  • Verify if HADR is Up and Running on Standby - After
  • HADR primary status
  • HADR standby status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment