Oracle GoldenGate微服务架构的/etc/init.d下的OracleGoldenGate服务Shell脚本:
#!/bin/sh # # Oracle GoldenGate Service Manager # # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. # # chkconfig: 2345 99 95 # description: The Oracle GoldenGate Service Manager is # responsible for managing all other Oracle # GoldenGate services. # processname: ServiceManager ### BEGIN INIT INFO # Provides: OracleGoldenGate # Required-Start: $syslog $remote_fs $network $named $time # Default-Start: 2 3 5 # Default-Stop: 0 1 4 6 # Short-Description: Oracle GoldenGate Service Manager # Description: The Oracle GoldenGate Service Manager is responsible for # managing all other Oracle GoldenGate services. ### END INIT INFO PROGRAM="ServiceManager" USER=oggma OGG_HOME=/home/oggma/app/oggma OGG_VAR_HOME=/home/oggma/app/oggsm/var isProgramRunning() { pid=$(cat ${OGG_VAR_HOME}/run/${PROGRAM}.pid 2>/dev/null) [[ ! -z ${pid} ]] && ps xaw | grep -q "^ *${pid}[ ].*${OGG_HOME}/bin/${PROGRAM}" } startService() { if ( isProgramRunning ); then echo "Oracle GoldenGate ${PROGRAM} already running" exit 1 fi echo "Starting Oracle GoldenGate..." su - ${USER} -c "/bin/bash -c 'nohup ${OGG_HOME}/bin/${PROGRAM} &>/dev/null'" & RETVAL=$? [ ${RETVAL} -eq 0 ] && echo "Success" || echo "Failed" } stopService() { pid=$(cat ${OGG_VAR_HOME}/run/${PROGRAM}.pid 2>/dev/null) if ( ! isProgramRunning ); then echo "Oracle GoldenGate ${PROGRAM} not running" exit 1 fi echo "Stopping Oracle GoldenGate..." kill ${pid} RETVAL=$? [ ${RETVAL} -eq 0 ] && echo "Success" || echo "Failed" sleep 2 } status() { if ( ! isProgramRunning ); then echo "Oracle GoldenGate ${PROGRAM} not running" exit 1 fi echo "Oracle GoldenGate ${PROGRAM} running" RETVAL=0 } case "$1" in start) startService ;; stop) stopService ;; restart) stopService startService ;; status) status ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac exit ${RETVAL}