Tuesday, May 3, 2016

OGG Auto Startup Script in Linux


source : https://setijoagus.wordpress.com/2010/09/04/auto-start-goldengate-on-linux-centos-release-5-2-final/

1)

[oracle@pbltest ggs]$ cat startGoldenGate
start manager

start extract *
--start replicat *

exit


2)
[oracle@pbltest ggs]$ cat startgoldengate
#!/bin/sh
# Start the oracle listener
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=PRIMPBL
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export GGATE=/u02/oracle/ggs
export PATH=$ORACLE_HOME/bin:$PATH:$GGATE
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/u02/oracle/ggs
$GGATE/ggsci PARAMFILE  /u02/oracle/ggs/startGoldenGate




-------
chmod a+x /u02/oracle/ggs/startgoldengate
--------------------------------------------


3)

 vi /u02/oracle/ggs/stopGoldenGate

stop extract *
--stop replicat *

STOP MANAGER !
exit

------




testing :

 ./ggsci  PARAMFILE /u02/oracle/ggs/stopGoldenGate



4)  vi /u02/oracle/ggs/stopgoldengate

#!/bin/sh
# Start the oracle listener
#!/bin/sh
# Start the oracle listener
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=PRIMPBL
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export GGATE=/u02/oracle/ggs
export PATH=$ORACLE_HOME/bin:$PATH:$GGATE
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/u02/oracle/ggs

$GGATE/ggsci PARAMFILE /u02/oracle/ggs/stopGoldenGate



----

chmod a+x /u02/oracle/ggs/stopgoldengate
--



5) vi /u02/oracle/ggs/xgoldengate
[root@pbltest init.d]# cat /u02/oracle/ggs/xgoldengate
#!/bin/sh
#
# chkconfig: 345 51 49
# description: startup and shutdown the Oracle 11g goldengate
#
echo "Goldengate start/stop"
ORA_OWNER=oracle
GG_HOME=/u02/oracle/ggs

case "$1" in
'start')
# Start the goldengate
echo -n "Starting the goldengate : "
su - $ORA_OWNER -c $GG_HOME/startgoldengate
echo
;;

'stop')
# Stop the goldengate
echo -n "Shutting down goldengate : "
su - $ORA_OWNER -c $GG_HOME/stopgoldengate
echo
;;

"restart")
# Restart the Oracle databases:
echo -n "Restarting goldengate : "
$0 stop
$0 start
echo
;;

*)
echo "Usage: xgoldengate [ start | stop | restart }"
exit 1

esac
exit 0



6) Script automatic startup & shutdown goldengate


      cp /u02/oracle/ggs/xgoldengate /etc/rc.d/init.d/

      cd /etc/rc.d/init.d/

      chmod 750 /etc/rc.d/init.d/xgoldengate



7) Finally Add with chkconfig :


[root@pbltest init.d]# chkconfig --add xgoldengate


[root@pbltest init.d]# chkconfig --list xgoldengate
xgoldengate     0:off   1:off   2:off   3:on    4:on    5:on    6:off

[root@pbltest init.d]# chkconfig xgoldengate on



=====================================================================

[root@pbltest ~]# cat /etc/rc.local
#!/bin/sh
sh /home/oracle/ggs_start.sh


[root@pbltest ~]# cat /home/oracle/ggs_start.sh
#!/bin/bash
su - oracle -c /u02/oracle/ggs/ggsci << !
start mgr
exit;

===============================================
[oracle@db02 ggs]$ crontab -e
#OGG start
#30 20 * * *  sh  /u03/oracle/ggs/startgoldengate >>/dev/null 2>&1
#OGG stop
#30 07 * * *  sh  /u03/oracle/ggs/stopgoldengate >>/dev/null 2>&1


No comments: