From 5deabda8f482aeb09d1ff24099dfb278836638aa Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 8 Mar 2018 10:38:02 +1100 Subject: [PATCH] Initial release --- Dockerfile | 62 +++++++++++++++++++++++++++ admin.macro | 2 + dsm.sys | 6 +++ dsmserv.opt | 26 ++++++++++++ init | 49 ++++++++++++++++++++++ install-fp.xml | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ install.xml | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ tsmdbmgr.opt | 1 + 8 files changed, 368 insertions(+) create mode 100644 Dockerfile create mode 100644 admin.macro create mode 100644 dsm.sys create mode 100644 dsmserv.opt create mode 100755 init create mode 100644 install-fp.xml create mode 100644 install.xml create mode 100644 tsmdbmgr.opt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7ed834e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,62 @@ +# NAME ibm/spectrumprotect +# VERSION 8.1.1 +# BUILD docker build -t="ibm/spectrumprotect:latest" . +# START docker run -dp 1500:1500 [ -p 1543:1543 ] -v source:/tsm -v source:/data --restart=always --name=spectrum-protect ibm/spectrumprotect + +# Since SP is supported on RHEL and its not available in docker, we'll use CentOS. +FROM centos:7 + +# OS Installation Prerequisites +RUN yum -y install http://yum.leenooks.net/CentOS/7/base/redhat-release-7-6.el7.centos.12.2.x86_64.rpm libaio ksh compat-libstdc++-33 numactl && yum clean all && rm -rf /var/tmp/* + +# Installation +COPY install.xml install-fp.xml /tmp/ + +## New Install - Base level with License +#RUN SOURCE_URL=http://YOUR_SITE_URL_HERE && \ +# mkdir -p /tmp/build && cd /tmp/build && \ +# curl -SL ${SOURCE_URL}/8.1.4 > tsm && df && chmod +x tsm && ./tsm && rm -f tsm && df && \ +# ./install.sh -s -input /tmp/install.xml -acceptLicense && \ +# rm -rf /tmp/build + +# New Upgrade Install - Need to get license from base level +RUN SOURCE_URL=http://YOUR_SITE_URL_HERE && \ + mkdir -p /tmp/build/8.1.0 && cd /tmp/build/8.1.0 && \ + curl -SL ${SOURCE_URL}/8.1.0 > tsm && chmod +x tsm && ./tsm && rm -f tsm && \ + ./install.sh -s -input /tmp/install.xml -acceptLicense && \ + rm -rf /tmp/build/8.1.0 && ls -al /tmp/ && df && \ + mkdir -p /tmp/build/8.1.1 && cd /tmp/build/8.1.1 && \ + curl -SL ${SOURCE_URL}/8.1.1 > tsm && chmod +x tsm && df && ./tsm && df && rm -f tsm && \ + ./install.sh -s -input /tmp/install-fp.xml -acceptLicense && df && \ + rm -rf /tmp/install* /tmp/build/8.1.1 && ls -al /tmp/ && df && find /tmp/ + +# Dont forget to change the user in the init file too +ENV USER=tsm USERDIR=/tsm USERID=201 GROUPID=201 + +# Setup User +RUN groupadd servers -g ${GROUPID} && useradd -d ${USERDIR} -u ${USERID} -g ${GROUPID} -s /bin/bash ${USER} + +# Server options file in place +COPY dsmserv.opt tsmdbmgr.opt ${USERDIR}/ +COPY dsm.sys /opt/tivoli/tsm/server/bin/dbbkapi/ +RUN chmod a+r /opt/tivoli/tsm/server/bin/dbbkapi/dsm.sys + +# Create TSM Instance +# Change the default directory for the database to be the same as the instance directory for the server. +RUN /opt/tivoli/tsm/db2/instance/db2icrt -a server -s ese -u ${USER} ${USER} && \ + mkdir -m 750 /database && chown ${USER}:servers /database /tsm/dsmserv.opt /tsm/tsmdbmgr.opt && \ + su ${USER} -lc "db2 update dbm cfg using dftdbpath ${USERDIR} && db2set -i ${USER} DB2NOEXITLIST=ON" + +# Setup sqllib/userprofile +RUN su ${USER} -lc "echo setenv LD_LIBRARY_PATH /opt/tivoli/tsm/server/bin/dbbkapi:/usr/local/ibm/gsk8_64/lib64:\\\$LD_LIBRARY_PATH >> sqllib/usercshrc && echo export LD_LIBRARY_PATH=/opt/tivoli/tsm/server/bin/dbbkapi:/usr/local/ibm/gsk8_64/lib64:\\\$LD_LIBRARY_PATH >> sqllib/userprofile && echo export DSMI_CONFIG=${USERDIR}/tsmdbmgr.opt >> sqllib/userprofile && echo export DSMI_DIR=/opt/tivoli/tsm/server/bin/dbbkapi >> sqllib/userprofile && echo export DSMI_LOG=${USERDIR} >> sqllib/userprofile" + +# An admin macro to create the admin user +COPY admin.macro /tsm/ +# init is how we start our container, it supports a "setup" mode for new installs +COPY init /sbin/ + +# Our final docker parameters +EXPOSE 1500 1543 +VOLUME [ "${USERDIR}","/database","/data" ] +ENTRYPOINT [ "/sbin/init" ] +CMD [ "start" ] diff --git a/admin.macro b/admin.macro new file mode 100644 index 0000000..8b0cab7 --- /dev/null +++ b/admin.macro @@ -0,0 +1,2 @@ +REG A admin password PASSE=30 FORCEPW=Y +GR AUTH admin CL=SY diff --git a/dsm.sys b/dsm.sys new file mode 100644 index 0000000..0a71deb --- /dev/null +++ b/dsm.sys @@ -0,0 +1,6 @@ +SERVERName TSMDBMGR_TSM +COMMMETHod TCPIP +TCPSERVERAddr localhost +TCPPort 1500 +ERRORLogname /tsm/tsmdbmgr.log +NODEName $$_TSMDBMGR_$$ diff --git a/dsmserv.opt b/dsmserv.opt new file mode 100644 index 0000000..01f8050 --- /dev/null +++ b/dsmserv.opt @@ -0,0 +1,26 @@ +COMMmethod TCPIP +TCPWindowsize 0 +DATEformat 2 +EXPInterval 0 +VOLUMEHistory /tsm/VOLHIST.TXT +DEVCONFig /tsm/DEVCONFIG.TXT + +DEDUPREQUIRESBACKUP NO + +SSLTCPPORT 1543 +ALLOWREORGINDEX YES +REORGBEGINTIME 08:00 +REORGDURATION 12 + +THROUGHPUTDATATHRESHOLD 5 +THROUGHPUTTIMETHRESHOLD 30 + +ARCHLOGCOMP YES +DISABLEREORGTable +DISABLEREORGIndex BF_AGGREGATED_BITFILES,BF_BITFILE_EXTENTS,BACKUP_OBJECTS,ARCHIVE_OBJECTS +DISABLEREORGCleanupindex +ACTIVELOGSize 2048 +MIRRORLOGDirectory /database/mirrorlog +ARCHFAILOVERLOGDirectory /database/archfaillog +ACTIVELOGDirectory /database/activelog +ARCHLOGDirectory /database/archlog diff --git a/init b/init new file mode 100755 index 0000000..5492368 --- /dev/null +++ b/init @@ -0,0 +1,49 @@ +#!/bin/bash +set -e + +NAME="SP" + +function stop { + echo "Stopping ${NAME}" + echo "PLEASE connect with a client and issue HALT" && sleep 60 +} + +trap 'stop' SIGTERM + +[ -z "${USER}" ] && echo "The USER environment variable is not set - this script wont work without it." && exit 1 + +if [ "$1" == "start" ]; then + # @TODO: this assumes -v is used, but we have exposed the VOLUMES, so -v doesnt have to be used. + [ ! -f /tsm/.INIT -o ! -f /database/.INIT ] && echo "Please use -v :/tsm.init and :/database.init and run init1" && exit 1 + + [ -x /opt/tivoli/tsm/server/bin/dsmserv ] && su ${USER} -lc /opt/tivoli/tsm/server/bin/dsmserv & + + wait + +# Init one needs to copy some data from the install /tsm directory to our persistent storage volume - so that volume should be mounted under /tsm.init +elif [ "$1" == "init1" ]; then + [ ! -d /tsm.init -o ! -d /database.init ] && echo "ERROR: /tsm.init or /database.init doesnt exist" && exit 1 + + chown ${USER}:servers /database.init /tsm.init + cp -a /tsm/.[a-z]* /tsm/* /tsm.init/ + su ${USER} -lc "mkdir /database.init/tsmdb /database.init/activelog /database.init/archlog /database.init/archfaillog /database.init/mirrorlog" + +# Init two creates our database, and runs our admin marco. +elif [ "$1" == "init2" ]; then + su ${USER} -lc "sed -i \"s/\$(cat sqllib/db2nodes.cfg |awk '{print \$2}')/$(hostname)/\" sqllib/db2nodes.cfg" + su ${USER} -lc "dsmserv format dbdir=/database/tsmdb activelogsize=2048 activelogdirectory=/database/activelog archlogdirectory=/database/archlog archfailoverlogdirectory=/database/archfaillog mirrorlogdirectory=/database/mirrorlog" + [ -f $(eval echo ~${USER}/admin.macro) ] && su ${USER} -lc "dsmserv runfile admin.macro" + + touch /database/.INIT + touch /tsm/.INIT + +elif [ "$1" == "upgrade" ]; then + [ ! -f /tsm/.INIT -o ! -f /database/.INIT ] && echo "Please use -v :/tsm.init and :/database.init and re-run upgrade" && exit 1 + /opt/tivoli/tsm/db2/instance/db2iupdt -d ${USER} + +elif [ "$1" == "restore" ]; then + su ${USER} -lc "dsmserv restore db ${2:+password=$2} restorekeys=yes on=DBDIRS.TXT" + +else + exec $@ +fi diff --git a/install-fp.xml b/install-fp.xml new file mode 100644 index 0000000..c2059ea --- /dev/null +++ b/install-fp.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/install.xml b/install.xml new file mode 100644 index 0000000..0fd6965 --- /dev/null +++ b/install.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tsmdbmgr.opt b/tsmdbmgr.opt new file mode 100644 index 0000000..f653977 --- /dev/null +++ b/tsmdbmgr.opt @@ -0,0 +1 @@ +SERVERNAME TSMDBMGR_TSM