目的:
10.13.8.186 archived log 中转机器 。 需要从production节点mxrac01,03,04,05(10.13.67.171/172/174/175)上的
任何一台中拷贝所有节点的归档文件, 然后传送到 RAC Standby机器上 (10.13.9.171/173/174 任何一台) 。
步骤:
1, 首先,要在中转机上生成public key
dfms-arc-shipping<*mxdell1*/u01/run>$ cd /home/oracle
dfms-arc-shipping<*mxdell1*/u01/run>$mkdir .ssh
dfms-arc-shipping<*mxdell1*/u01/run>$chmod 700 .ssh
dfms-arc-shipping<*mxdell1*/u01/run>$ cd /home/oracle
dfms-arc-shipping<*mxdell1*/home/oracle>$ ssh-keygen -t rsa
然后可以看到 .ssh 目录下生成有 id_rsa.pub 文件。
2. 然后在production各个节点(其实在一个准备拷贝的节点作业就可以了,这里为了防止有节点出现问题)将中转机的public key传输到
各个节点已经存在 authorized_keys 文件中, 然后通过在中转机上测试 ssh mxrac01 date 等来测试中转机到RAC的连通性。
mxrac01<*mxdell1*/home/oracle/.ssh>$ssh 10.13.8.186 cat /home/oracle/.ssh/id_rsa.pub >>authorized_keys
mxrac03<*mxdell3*/home/oracle/.ssh>$ssh 10.13.8.186 cat /home/oracle/.ssh/id_rsa.pub >>authorized_keys
mxrac04<*mxdell4*/home/oracle/.ssh>$ssh 10.13.8.186 cat /home/oracle/.ssh/id_rsa.pub >>authorized_keys
mxrac05<*mxdell5*/home/oracle/.ssh>$ssh 10.13.8.186 cat /home/oracle/.ssh/id_rsa.pub >>authorized_keys
3. 同样,中转机上的archived log要传输到RAC Standby上, 我们要将中转机的public key 传输到RAC Standby的各个节点的 authorized_keys
中, 由于中转机是主动角色, 所以其他机器的public key 不用传给中转机的 authorized_keys (所以它可以不用生成这个文件) 。 同样测试中转机到RAC
Standby各个节点的联通性。
mxrac01<*mxdell1*/home/oracle/.ssh>$ssh 10.13.8.186 cat /home/oracle/.ssh/id_rsa.pub >>authorized_keys
mxrac03<*mxdell3*/home/oracle/.ssh>$ssh 10.13.8.186 cat /home/oracle/.ssh/id_rsa.pub >>authorized_keys
mxrac04<*mxdell4*/home/oracle/.ssh>$ssh 10.13.8.186 cat /home/oracle/.ssh/id_rsa.pub >>authorized_keys
mxrac05<*mxdell5*/home/oracle/.ssh>$ssh 10.13.8.186 cat /home/oracle/.ssh/id_rsa.pub >>authorized_keys
备注: 目前所有的拷贝工作都是production db及standby db中的节点4 在和中转机进行, 只所有要加入中转机的public key 给所有节点,建立ssh信任关系,
主要是为了防止节点4发生故障后, 只要修改rsync 脚本中的IP即可 。
4. 设置脚本(脚本放在中转机上):
dfms-arc-shipping<*mxdell1*/u01/run>$cat rsync_rac_arc
#!/bin/bash
pid=`/sbin/pidof rsync`
if [ "$pid" ]
then
echo "Rsync is already running...."
else
echo "Starting rsync from production db to middle server `date`"
rsync -e ssh -av oracle@10.13.67.174:/ocfs_data/mxdell/arch/ /ocfs_data/mxdell/arch/
echo "Starting rsync from middle server to standby server `date`"
rsync -e ssh -av /ocfs_data/mxdell/arch/ oracle@10.13.9.174:/ocfs_data/mxdell/arch/
echo "Completed rsync `date`"
fi
exit 0
5. 最后设置crontab (在中转机上):
dfms-arc-shipping<*mxdell1*/u01/run>$crontab -l
*/10 * * * * bash /u01/run/rsync_rac_arc 1>>/u01/run/log/rsync_rac_arc.log 2>>/u01/run/log/rsync_rac_arc.bad