Top Banner
Monitoring Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12
40

Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

May 24, 2018

Download

Documents

trinhnguyet
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Monitoring Ozone Levels with Postgresql

Alex Lai, Marty BrandonMay 2012

Thursday, May 17, 12

Page 2: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Overview

• Background (Marty)

• Ingestion & Processing (Alex)

• Challenges (Alex)

• Ongoing Development (Marty)

Thursday, May 17, 12

Page 3: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Background

Thursday, May 17, 12

Page 4: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

A-Train

Thursday, May 17, 12

Page 5: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Aura

Thursday, May 17, 12

Page 6: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Data Downloading

Thursday, May 17, 12

Page 7: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Earth Science Data Types

• Interface between the raw science data and the data management system

• > 900

Raw Dataground-station processing

ESDT

Thursday, May 17, 12

Page 8: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Thursday, May 17, 12

Page 9: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Ingestion & Processing

Thursday, May 17, 12

Page 10: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Science Data Processing System

Users&

Operators

DataProcessing

SystemData

ProvidersData

Receivers

Thursday, May 17, 12

Page 11: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Ingestion Processing

Auto Ingest

Legacy Ingest

Process

OMI Operators

Ingest Planner

PostgresLegacy

Metadata Server

PostgresMDS

Metadata Server

Sync DatabaseProcess

ARCHIVE SERVER

Archive Node

Archive Node

Archive Node

MDS Ingest Process

Thursday, May 17, 12

Page 12: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Challenges

Thursday, May 17, 12

Page 13: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Slave ServerMaster Server

Legacy/MDSDatabase

Legacy/MDSDatabase

20 days dumps

20 days dumps

20 days dumps

scp/rsync

TLCF sreverADNET srever

Backup and Asynchronous ReplicationGSFC/NASA

OFF-SITE ADNET’S SERVER GSFC/NASA

TLCF CLUSTER

Monitor/Remove

Applied Wal files

Wal filesArchive Disk

pg_dump

Thursday, May 17, 12

Page 14: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Monitor WAL is the key to ensure the replication is in good status?

•The cause of WAL not properly apply to Slave•Network unavailable•WAL files were deleted•While COPY took too long to finish that cause the apply WAL file in wait status (set Max_standby_streaming_delay = -1)• Slave hangs for any reasons

Thursday, May 17, 12

Page 15: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Monitor WAL is the key to ensure the replication is in good status?

Slave unable to connect and copy wal file from replication archive disk

ps aux shows waiting status in slavePg log also show waiting no recovery

state for a long period of time

Thursday, May 17, 12

Page 16: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Monitor WAL is the key to ensure the replication is in good status?

Query using functions pg_current_xlog_location() (master only)

Pg_last_xlog_receive_location(),Pg_last_xlog_replay_location()

When slave hangs for any reasons, an monitoring script will trigger an alert email to DBA

Thursday, May 17, 12

Page 17: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

•What and how to monitor the WAL files?•Monitor the disk space available for WAL archive•Monitor the last applied WAL file in Slave•Monitor number of purging old applied WAL file•Monitor any wait states•Monitor dead lock situation

Monitor WAL is the key to ensure the replication is in good status?

Thursday, May 17, 12

Page 18: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

•Email Notification to DBA for•Disk storage down to warning level•The last applied WAL file not changed longer than the statement_timeout in SLAVE•Network unavailable between master and slave• Log the long queries that exceed a long time like 20 minutes

Monitor WAL is the key to ensure the replication is in good status?

Thursday, May 17, 12

Page 19: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

•Too many processes in wait state•When Database has slow performance for a period of time

Monitor WAL is the key to ensure the replication is in good status?

Thursday, May 17, 12

Page 20: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Our current database implementation includes 10 clusters, each running Postgres 9.0.6 and divided into three production levels: development, testing, and operations. On average about 200 commits per second The largest table contains over 160 millions rows Total data increase from 40 - 60 % in the last three years.

HOW much data do we have?

Thursday, May 17, 12

Page 21: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Number of records (Legacy)m

illio

ns

Thursday, May 17, 12

Page 22: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Number of records (MDS)m

illio

ns

Thursday, May 17, 12

Page 23: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Synchronization between Legacy and MDS

PostgresLegacy

Metadata Server

PostgresMDS

Metadata Server

Sync DatabaseProcess

MDS - Always has long delayAlso has to resolve record locking

Thursday, May 17, 12

Page 24: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

OMI LEGACY DATABASE SCHEMA

Thursday, May 17, 12

Page 25: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

OMI MDS DATABASE SCHEMA

Thursday, May 17, 12

Page 26: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Variables MASTER SLAVEwal_level(enable read-only queries on a standby server)

hot_standby hot_standby

hot_standby off(master MUST be off)

on(enable read-only queries on a standby server)

wal_keep_segment 32 32

wal_max_senders 5 5

Setting of Postgresql.conf

Thursday, May 17, 12

Page 27: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Variables MASTER SLAVEarchive_mode on offArchive_timeout 30s 30sarchive_command ‘cp %p /your_path/%f’ ‘cp %p /your_path/%f’

Max_standby_archive_delay

300s 1200s

Max_standby_streaming_delay

300s -1Wait for any queries before apply for the WAL fileThis avoid pg_dump COPY fail.

Setting of Postgresql.conf

Thursday, May 17, 12

Page 28: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Variables SLAVE

standby_mode ‘on’

primary_conninfo ‘host=ip_of_Master port=5432 user=user_has_all_access_to_all_databasepw=user_password’

trigger_file ‘/path/to/trigger’

restore_command ‘cp /path/to/archive_files/%f “%p”’

Setting of Recovery.conf on Slave

Thursday, May 17, 12

Page 29: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Ongoing Work

Thursday, May 17, 12

Page 30: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Component X

Decentralization

Component Y

Component Z

REST

Thursday, May 17, 12

Page 31: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

•Web Framework

•ORM

•Database Patches

Thursday, May 17, 12

Page 32: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Web FrameworkComponent X

Controller

ModelView

GET /person/(*key)POST /personDELETE /person/(*key)

Thursday, May 17, 12

Page 33: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

ORMComponent X

Server Start: - read config file - register database - generate CRUD methods

Thursday, May 17, 12

Page 34: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

HTTP Request

Object Method

Database

Thursday, May 17, 12

Page 35: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Database PatchesComponent X

Git Repo - Component X

code schema.sql patch1.sql

Instance - Component X

patch2.sql

Thursday, May 17, 12

Page 36: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Database Patch DetailsComponent X

Git Repo

base.sql patches_applied.txt patch1.sql patch2.sql . . .

Instance

patches_applied

base.sql =schema dump

+new patches

Thursday, May 17, 12

Page 37: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Perl Modules

•Mojolicious

•Rose::DB

•Module::Build

Thursday, May 17, 12

Page 38: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Monitoring

Thursday, May 17, 12

Page 39: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Thursday, May 17, 12

Page 40: Monitoring Ozone Levels with Postgresql - PGCon Ozone Levels with Postgresql Alex Lai, Marty Brandon May 2012 Thursday, May 17, 12. Overview ... •Mojolicious

Questions?

Thursday, May 17, 12