DBAtlas · 데이터베이스 운영 아틀라스

로그 전달(log shipping) 상태와 지연 모니터링

SQL ServerAlways On 및 HA

명령어

-- Summary (on the primary, secondary or monitor server):
EXEC master.sys.sp_help_log_shipping_monitor;

-- PRIMARY: when the last log backup was taken:
SELECT p.primary_server, p.primary_database,
       p.last_backup_date, p.last_backup_file,
       DATEDIFF(MINUTE, p.last_backup_date, GETDATE()) AS backup_age_min,
       p.backup_threshold                              AS threshold_min
FROM   msdb.dbo.log_shipping_monitor_primary p;

-- SECONDARY: copy and restore latency:
SELECT s.secondary_server, s.secondary_database, s.primary_server,
       s.last_copied_date, s.last_copied_file,
       s.last_restored_date, s.last_restored_file,
       s.last_restored_latency                           AS restore_latency_min,
       DATEDIFF(MINUTE, s.last_restored_date, GETDATE()) AS since_last_restore_min,
       s.restore_threshold                               AS threshold_min
FROM   msdb.dbo.log_shipping_monitor_secondary s;

-- Errors in the last 24 hours:
SELECT e.database_name, e.agent_type, e.log_time, e.message
FROM   msdb.dbo.log_shipping_monitor_error_detail e
WHERE  e.log_time >= DATEADD(HOUR, -24, GETDATE())
ORDER BY e.log_time DESC;

-- Secondary DB mode (RESTORING = NORECOVERY, is_in_standby = STANDBY):
SELECT name, state_desc, is_in_standby FROM sys.databases WHERE name = N'Musteri';

하는 일

primary의 마지막 로그 백업 경과 시간, secondary의 마지막 복사/복원 파일 및 복원 지연을 임계값과 함께 보여 주고, 최근 24시간의 백업/복사/복원 작업 오류를 보여 준다.

사용 시점

log shipping 알림 작업이 실행될 때(오류 14420/14421), DR 테스트 전, 또는 secondary가 얼마나 뒤처졌는지 보고할 때.

주의

모니터 테이블에는 서버가 보는 쪽만 있다: primary 테이블은 primary/monitor에, secondary 테이블은 secondary/monitor에 채워진다. 수동(log shipping이 아닌) 로그 백업은 체인을 끊어 복원 작업이 계속 실패하므로 임시 로그 백업에는 COPY_ONLY를 사용한다. STANDBY 모드에서는 각 복원 전에 사용자 연결이 끊긴다. 읽기 전용 쿼리이며 안전함.

DBAtlas에서 열기 →

관련 항목