we will configure script. to rsync archive log file from production db to standby db
1. How to Rsync over SSH without a password.
a. Log into the TARGET host (standby db), and generate an RSA (public and private) key pair:
target$ ssh-keygen -t rsa
* Accept the default location for the key files (press [ENTER]).
* Enter and confirm a pass phrase. (empty for no passphrase) (it is not a requirement)
b. Log into the SOURCE host (production db), and confirm the existence of this file
"/home/oracle/.ssh./authorized_keys" , create this file
source$ touch ~/.ssh/authorized_keys
c. Log into the SOURCE host, and get public key from TARGET:
source$ ssh target cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
d. Log into the TARGET host (here is Standby), and try to rsync:
target$ rsync -e ssh -av oracle@source:/ocfs_data/mxdell/arch/ /ocfs_data/mxdell/arch/
------------------------------------------------------------------
改良的脚本,可以判断, 一个linux crontab job在运行,同样的一个如果再次运行会被终止。
#!/bin/bash
pid=`/sbin/pidof rsync`
if [ "$pid" ]
then
echo "Rsync is already running...."
else
echo "Starting rsync `date`"
rsync -e ssh -av oracle@10.13.66.186:/ocfs_data/mxdell/arch/ /ocfs_data/mxdell/arch/
echo "Completed rsync `date`"
fi
exit 0
-----------------------------------------------------------------
#!/bin/bash
pid=`/sbin/pidof rsync`
if [ "$pid" ]
then
echo "Rsync is already running...."
else
echo "Starting rsync `date`"
rsync -e ssh -av oracle@10.13.67.174:/ocfs_data/mxdell/arch/ /ocfs_data/mxdell/arch/
echo "Completed rsync `date`"
fi
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/35489/viewspace-628557/ ,如需转载,请注明出处,否则将追究法律责任。