数据库
首页 > 数据库> > Oracle dataguard 主备同步检测脚本

Oracle dataguard 主备同步检测脚本

作者:互联网

#!/bin/bash

for SID in $(ps -fu oracle | grep pmon | grep -v grep | cut -d_ -f3- | sort); do
export ORACLE_SID=$SID

source ~/.bash_profile

row=`sqlplus -silent '/ as sysdba' << EOSQL
set pagesize 0 feedback off verify off heading off echo off
select count(*) from v\\$dataguard_stats where name in ('transport lag','apply lag') and value is not null;
EOSQL`

if [ $row -eq 2 ];
then
t_lag=`sqlplus -silent '/ as sysdba' << EOSQL
set pagesize 0 feedback off verify off heading off echo off
select to_number(substr(value,2,2))*1440+to_number(substr(value,5,2))*60+to_number(substr(value,8,2)) from v\\$dataguard_stats where name ='transport lag';
EOSQL`

a_lag=`sqlplus -silent '/ as sysdba' << EOSQL
set pagesize 0 feedback off verify off heading off echo off
select to_number(substr(value,2,2))*1440+to_number(substr(value,5,2))*60+to_number(substr(value,8,2)) fro

标签:sort,f3,grep,主备,dataguard,SID,Oracle,export,bash
来源: https://blog.csdn.net/hkyw000/article/details/111769593