Skip to content

Commit

Permalink
freeip
Browse files Browse the repository at this point in the history
  • Loading branch information
junsulee75 committed Nov 7, 2024
1 parent d471c12 commit d22c9be
Show file tree
Hide file tree
Showing 18 changed files with 464 additions and 89 deletions.
1 change: 1 addition & 0 deletions 0_osenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ setProfile(){
swCmdChkAllHost "xterm"
setProfile
pyChk ## install python on the 1st host only. To run setup script, python is needed.
goChk

disp_msglvl1 "Copying frequently used commands to /usr/local/bin"
for f in menu.py
Expand Down
8 changes: 6 additions & 2 deletions 1_prereq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
source config.ini # use /bin/bash for reading from the current directory
source jscommon.sh

## Not related to pacemaker, but I need this
## Some of those are not prereq for pacemaker ( ex. 1st two linse ) .That's more for TSA.
## But let's keep for complete Db2 installation without glitch and sharing the code with TSA scenario

installPrereq(){

for HOST in $ALLHOST
do
disp_msglvl2 "Installing prereq for pacemaker on $HOST..."
disp_msglvl2 "Installing prereq for pacemaker on $HOST..."
ssh $SSH_NO_BANNER $HOST yum -y install libstdc++ sg3_utils libstdc++.so.6 perl-Sys-Syslog patch binutils cpp gcc-c++ ksh python2 perl-Sys-Syslog perl dnf mksh ## added mksh due to installation prereq check
ssh $SSH_NO_BANNER $HOST dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

# https://www.ibm.com/docs/en/db2/11.5?topic=pacemaker-prerequisites-integrated-solution-using
ssh $SSH_NO_BANNER $HOST yum -y install python3-dnf-plugin-versionlock ## necessary only on Linux

ssh $SSH_NO_BANNER $HOST yum -y install compat-openssl10 # db2start: error while loading shared libraries: libcrypto.so.10
Expand Down
8 changes: 5 additions & 3 deletions 2_db2_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source config.ini # use /bin/bash for reading from the current directory
source jscommon.sh


DB2VER_INPUT=$1
DB2VER_INPUT=$1 # Not mandatory. If there is the parameter.
#DB2VER_TWO=${DBVER_INPUT:0:2} # not working
#echo "|$DB2VER_INPUT| |$DB2VER_TWO|"
EXTRACT_PATH="server_dec" # Db2 installation image extracted relative path
Expand Down Expand Up @@ -79,11 +79,13 @@ extractImage(){
installDB2(){
for HOST in $ALLHOST
do

TSA_LEVEL=`grep tsa_level /root/$EXTRACT_PATH/db2/spec` # TSA version in the installation image

# in pacemaker repo, most likely it won't take this logic, to share logic with tsa repo, let's keep it.
if [ "$DB2VER_INPUT" == "1157" ] || [ "$DB2VER_INPUT" == "1158" ] || [ "$DB2VER_INPUT" == "1159" ] ; then
echo "This is DB2 $DB2VER_INPUT installation"
if [ "$VERSION_ID" == "8.8" ] ; then
echo "This is $ID $VERSION_ID . It's OK to install with TSA : $TSA_LEVEL "
echo "This is $ID $VERSION_ID . It's OK to install with TSA : $TSA_LEVEL " # This may not be necessary
ssh $SSH_NO_BANNER $HOST "/root/$EXTRACT_PATH/db2_install -y -b $DB2_INSTALL_PATH -p $PKG_NAME -n" # for single
else
echo "Check the compatibility with DB2 $DB2VER_INPUT and $ID $VERSION_ID. Exiting ... "
Expand Down
27 changes: 26 additions & 1 deletion 5_pacemaker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,37 @@ createDBResource(){
}
createVIP(){

if [ "$VIP" = "123.123.123.123" ] || [ -z "$VIP" ] ; then # not changed or not set

# If fyre provisioned, I know what to do
hostname | grep fyre >/dev/null
if [ $? -eq 0 ] ; then # This is for IBM fyre provisioned system. It will grab "eth0" for internal ip address. From tests, no need to specify iface. flannel will use it automatically.
ipaddr=$(ip addr | grep "inet 10.*dynamic" | awk '{print $2}' | sed 's/\/.*//' )
subnetMask=$(ip addr | grep "inet 10.*dynamic" | awk '{print $2}' | sed 's/.*\///' )
print2 "GOLANG(freeip) : Running other program to find an available IP address under the same subnet of IP $ipaddr/$subnetMask"
OUTPUT=$(./freeip/freeip_$(uname -p) "$ipaddr" "$subnetMask")
if [ $? -eq 0 ]; then
VIP="$OUTPUT"
echo "OK. Found the available IP address $VIP . Will use it as VIP\n\n"
else
echo "Failed to find an available IP address for VIP. Find and try again manually later. SKipping VIP configuration...\n\n"
return 1
fi
else
echo "You haven't set the correct VIP in config.ini. Find and try again manually later. SKipping VIP configuration...\n\n"
return 1
fi

fi



disp_msglvl1 "creating VIP resource..."
$USER_HOME/sqllib/bin/db2cm -create -primaryVIP $VIP -db $DBNAME -instance $INST_USER -remote_cmd "ssh $SSH_NO_BANNER"
## TODO : fix error Error: the VIP address 10.11.71.150 is not within the same subnet as host with IP 10.11.100.236
## In this case, the IP 10.11.100.50 worked.
crm status
disp_msglvl2 "IP information...check secondary VIP is added to the network resource"
disp_msglvl2 "IP information...check secondary VIP $VIP is added to the network resource"
ip addr

}
Expand Down
76 changes: 0 additions & 76 deletions README.md

This file was deleted.

84 changes: 84 additions & 0 deletions REAEME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Db2 hadr on pacemaker automatic configurator

Fully automated scripts for creating DB2 HADR / pacemaker environment.

## Contents

- [Db2 hadr on pacemaker automatic configurator](#db2-hadr-on-pacemaker-automatic-configurator)
- [Contents](#contents)
- [Objectives](#objectives)
- [Steps](#steps)
- [Reference](#reference)


## Objectives

The scripts assume the following things in advance.
- Passwordless ssh root user login is set between hosts.
(IBM Fyre provisioned system has set already.)
- For automated Db2 installation images download by `curl`, I configured my own web server containing donwloaded Db2 images.
You may use the same way with your own web server or just change config.ini and 2_db2_install.sh to set file path manually.

- You know which VIP address to use. (Need to figure out an unused IP by yourself)

[Go to content](#contents)


## Steps

1. Prepare 3 Redhat hosts.

Example)
- Redhat 8.8 or 8.10
- Size : Any
- Quantity : 3

Following Db2 version will be installed by default. (Tested combination)

DB2 V11.5.9.0 on Redhat 8.10
DB2 V11.5.8.0 on Redhat 8.8

If you want to install other versions, edit config.ini

> IBMers can use internal fyre [quickburn](https://fyre.svl.ibm.com/quick).
2. Download the script.

Log into the 1st host and download the scripts

By root user
```
git clone https://<ibm github user id>:<ibm github token>@github.ibm.com/junsulee/hadr_pacemaker_on_fyre
# example : git clone https://junsulee:[email protected]/junsulee/hadr_pacemaker_on_fyre
```

3. Edit the following line with the your hostnames and preferred VIP on `config.ini` file.

```
##########################################################
## Must set area ! Only thing you need to configure manually in most cases
##########################################################
# Set virtual IP address to use. It should an unused IP within the same subnet and set. If not specified, script will try to get a random free IP address
VIP="123.123.123.123" ## Virtual IP address to use. Again !! please change this with an appropriate one. Otherwise, it will skip creating VIP resource.
....
```

> NOTE : Check the current IP addresses/subnet and specify VIP in the same subnet.
> Also read config.ini and customize parameters as you preferred.
4. Execute script

```
cd hadr_pacemaker_on_fyre
./install.sh
```

See the [terminal screen output](screen_output.md) how it looks like.

[contents](#contents)

## Reference

[Pacemaker versions shipped in Db2 version 11.5](https://www.ibm.com/docs/en/db2/11.5?topic=manager-supported-software-hardware-pacemaker)
7 changes: 5 additions & 2 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
## Must set area ! Only thing you need to configure manually in most cases
##########################################################

VIP=10.11.102.200 ## Virtual IP address to use. find an unused IP and set.

# Set virtual IP address to use. It should an unused IP within the same subnet and set. If not specified, script will try to get a random free IP address
VIP="123.123.123.123" ## Virtual IP address to use. Again !! please change this with an appropriate one. Otherwise, it will skip creating VIP resource.

##########################################################
##### Optional changes if you like
Expand Down Expand Up @@ -101,6 +101,9 @@ if [ -f /etc/os-release ]; then
elif [[ "$ID" == "rhel" && "$VERSION_ID" == "8.8" ]]; then ## ## default v11.5.8 for Redhat 8.8
DB2_IMAGE_FILE_NAME=$V1158_IMAGE
DB2_INSTALL_PATH=$V1158_INSTALL_PATH
elif [[ "$ID" == "rhel" && "$VERSION_ID" == "8.10" ]]; then ## ## default v11.5.8 for Redhat 8.8
DB2_IMAGE_FILE_NAME=$V1159_IMAGE
DB2_INSTALL_PATH=$V1159_INSTALL_PATH
else
echo "The current OS or version is not compatible for this script or not tested yet. Exiting ... "
exit 1
Expand Down
3 changes: 3 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Configuration outputs

## Files

Db2 resource agent scripts are located at /usr/lib/ocf/resource.d/heartbeat

## DBM CFG
```
Expand Down
25 changes: 25 additions & 0 deletions docs/pacemaker_operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,31 @@ systemctl start pacemaker
systemctl start corosync
systemctl start corosync-qdevice
```

Pacemaker consists of 7 deamons below.

```
[root@jspcmk1 pcmk]# systemctl status pacemaker
● pacemaker.service - Pacemaker High Availability Cluster Manager
Loaded: loaded (/usr/lib/systemd/system/pacemaker.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2024-09-22 18:18:13 PDT; 1 weeks 3 days ago
Docs: man:pacemakerd
https://clusterlabs.org/pacemaker/doc/
Process: 3162771 ExecStartPre=/usr/bin/killall -TERM pacemaker-attrd pacemaker-based pacemaker-controld pacemaker-execd pacemaker-fenced pacemaker-schedulerd (code=exited, status=1/FAILURE)
Process: 3162769 ExecStartPre=/bin/sleep 2 (code=exited, status=0/SUCCESS)
Main PID: 3162773 (pacemakerd)
Tasks: 7
Memory: 79.0M
CGroup: /system.slice/pacemaker.service
├─3162773 /usr/sbin/pacemakerd -f
├─3162775 /usr/libexec/pacemaker/pacemaker-based
├─3162776 /usr/libexec/pacemaker/pacemaker-fenced
├─3162777 /usr/libexec/pacemaker/pacemaker-execd
├─3162778 /usr/libexec/pacemaker/pacemaker-attrd
├─3162779 /usr/libexec/pacemaker/pacemaker-schedulerd
└─3162780 /usr/libexec/pacemaker/pacemaker-controld
```

- [Go to content](#contents)


Expand Down
31 changes: 31 additions & 0 deletions docs/pacemaker_pd.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- [collection](#collection)
- [db2cm -dump](#db2cm--dump)
- [Commands](#commands)
- [files](#files)
- [monitoring scripts](#monitoring-scripts)
- [MISC](#misc)
- [db2cm error (?)](#db2cm-error-)
- [db2 code : db2cm.C](#db2-code--db2cmc)
Expand Down Expand Up @@ -48,6 +50,35 @@ db2pd -pdcollection index=corosync_conf
$ db2pd -pdcollection index=crm_configure_show
```

[content](#contents)

## files

### monitoring scripts


```
INSTALL_PATH=/opt/ibm/db2/V11.5_mod8
ls $INSTALL_PATH/ha/pcmk
# file $INSTALL_PATH/ha/pcmk/*
/opt/ibm/db2/V11.5_mod8/ha/pcmk/db2ethmon: POSIX shell script, UTF-8 Unicode text executable, with very long lines
/opt/ibm/db2/V11.5_mod8/ha/pcmk/db2fs: POSIX shell script, ASCII text executable
/opt/ibm/db2/V11.5_mod8/ha/pcmk/db2hadr: POSIX shell script, ASCII text executable
/opt/ibm/db2/V11.5_mod8/ha/pcmk/db2inst: POSIX shell script, ASCII text executable, with very long lines
/opt/ibm/db2/V11.5_mod8/ha/pcmk/db2partition: Bourne-Again shell script, ASCII text executable
```

The files are copied into the path.

```
# ls /usr/lib/ocf/resource.d/heartbeat/db2*
/usr/lib/ocf/resource.d/heartbeat/db2 /usr/lib/ocf/resource.d/heartbeat/db2fs /usr/lib/ocf/resource.d/heartbeat/db2inst
/usr/lib/ocf/resource.d/heartbeat/db2ethmon /usr/lib/ocf/resource.d/heartbeat/db2hadr /usr/lib/ocf/resource.d/heartbeat/db2partition
```

[content](#contents)


## MISC
### db2cm error (?)
```
Expand Down
1 change: 1 addition & 0 deletions freeip/freeip
Binary file added freeip/freeip_arm
Binary file not shown.
Binary file added freeip/freeip_ppcle
Binary file not shown.
Binary file added freeip/freeip_x86_64
Binary file not shown.
5 changes: 5 additions & 0 deletions freeip/gobld
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rm -f freeip*
GOOS=darwin GOARCH=arm64 go build -o freeip_arm main.go
GOOS=linux GOARCH=amd64 go build -o freeip_x86_64 main.go
GOOS=linux GOARCH=ppc64le go build -o freeip_ppcle main.go
ln -s freeip_x86_64 freeip # will use for Linux x86 only for a while
Loading

0 comments on commit d22c9be

Please sign in to comment.