docker打包informix映象
阿新 • • 發佈:2018-12-26
informix 11.5的安裝指令碼有點問題,有時能裝,有時不能。反而11.7裝的非常順利。
目錄如下:
下載個informix 11.7的安裝包
dockerfile
# HOW TO BUILD THIS IMAGE # ----------------------- # download :iif.11.70.FC8DE.linux-x86_64.tar # Run: # $ docker build -t informix/database:11.7 . # Pull base image FROM centos:7 # Environment variables ENV INSTALL_FILE=iif.11.70.FC8DE.linux-x86_64.tar\ INSTALL_SCRIPT=install.sh\ LD_LIBRARY_PATH=/lib64\ INFORMIXSERVER=IFM\ INFORMIXDIR=/informix\ INFORMIXCHK=/informix/chk\ INFORMIXSQLHOSTS=/informix/etc/sqlhosts\ ONCONFIG=onconfig\ ONSOCPORT=9998\ DRSOCPORT=9999\ RUN_FILE=run.sh ENV PATH=$INFORMIXDIR/bin:$PATH # Copy file COPY $INSTALL_FILE $INSTALL_SCRIPT $RUN_FILE $INFORMIXDIR/ # Install informix RUN chmod u+x $INFORMIXDIR/$INSTALL_SCRIPT && \ . $INFORMIXDIR/$INSTALL_SCRIPT # volume VOLUME [$INFORMIXCHK] # expose port EXPOSE $ONSOCPORT $DRSOCPORT # start database CMD sh $INFORMIXDIR/$RUN_FILE
安裝指令碼install.sh
#!/bin/bash # add user and group groupadd informix useradd informix -g informix echo 'informix' | passwd informix --stdin # yum install require package yum install -y bc # tar packages and install DISK=disk mkdir $INFORMIXDIR/$DISK $INFORMIXCHK tar -xvf $INFORMIXDIR/$INSTALL_FILE -C $INFORMIXDIR/$DISK rm -f $INSTALL_FILE sh $INFORMIXDIR/$DISK/ids_install -i silent -DLICENSE_ACCEPTED=TRUE rm -rf $INFORMIXDIR/$DISK # set env cat >/home/informix/setenv <<EOF export INFORMIXSERVER=$INFORMIXSERVER export INFORMIXDIR=$INFORMIXDIR export INFORMIXSQLHOSTS=$INFORMIXSQLHOSTS export ONCONFIG=$ONCONFIG export RUN_FILE=$RUN_FILE export PATH=$PATH EOF echo '. ~/setenv' >> /home/informix/.bash_profile # create chk touch $INFORMIXCHK/rootchk chmod 660 $INFORMIXCHK/* chown -R informix:informix $INFORMIXCHK # create config cp $INFORMIXDIR/etc/onconfig.std $INFORMIXDIR/etc/onconfig sed -i 's?ROOTPATH $INFORMIXDIR\/tmp\/demo_on.rootdbs?ROOTPATH '$INFORMIXCHK'\/rootchk?g' $INFORMIXDIR/etc/onconfig sed -i 's?DBSERVERNAME?DBSERVERNAME '$INFORMIXSERVER'?g' $INFORMIXDIR/etc/onconfig sed -i 's?DBSERVERALIASES?DBSERVERALIASES '$INFORMIXSERVER'_DR?g' $INFORMIXDIR/etc/onconfig chown -R informix:informix $INFORMIXDIR/etc/onconfig # create sqlhost INFORMIXSERVER_DR=$INFORMIXSERVER'_DR' cat >$INFORMIXSQLHOSTS <<EOF $INFORMIXSERVER onsoctcp localhost $ONSOCPORT $INFORMIXSERVER_DR drsoctcp localhost $DRSOCPORT EOF chmod 660 $INFORMIXSQLHOSTS chown -R informix:informix $INFORMIXSQLHOSTS
啟動指令碼run.sh
build 以下映象#!/bin/bash ########### SIGTERM handler ############ function _term() { echo "Stopping container." echo "SIGTERM received, shutting down database!" onmode -sy onmode -ky } ########### SIGKILL handler ############ function _kill() { echo "SIGKILL received, shutting down database!" onmode -ky } # Set SIGTERM handler trap _term SIGTERM # Set SIGKILL handler trap _kill SIGKILL # config path CONFIG_PATH=$INFORMIXDIR/etc/oncfg_$INFORMIXSERVER.0 # start database if [ ! -f $CONFIG_PATH ]; then echo "initial informix!" oninit -ivy else echo "open informix!" oninit -vy fi tail -f $INFORMIXDIR/tmp/online.log & childPID=$! wait $childPID
啟動映象