DataBases - PostgreSQL
Linux System Administration II
Marian Marinov
Linux System Administration II DataBases - PostgreSQL
Important links
http://www.postgresql.org
PostgreSQL 9.3 Documentation
PostgreSQL Wiki
pgFoundry projects
pg-as-nosql-pgda...
Installation
Source
RPM/DEB
Linux System Administration II DataBases - PostgreSQL
Directory structure
basic
/var/lib/pgsql/data/*
Debian based
/etc/postgresql-common/
/etc/postgresql/9.3/main/
/var/lib/po...
Structure of PostgreSQL
server
prefork (shared memory)
client handling (client library)
query parser
query analyzer
query ...
On disk data structure

|
|- PG_VERSION
|- base per-database subdirectories
|- global cluster-wide tables, such as pg_data...
On disk data structure
base -
|- 1
|- 11510
|- 11511
|- 16384
- 24576
template1=# SELECT datname,datlastsysoid FROM pg_dat...
On disk data structure
base -
|- 11510 -
| |- 24765
os# SELECT relname,relfilenode,reltablespace FROM pg_class
WHERE relfi...
On disk data structure
Table and Indexes are stored in separate files
Tables bigger then 1GB are split into different files:
...
DataBase Design
DBNAME SCHME OBJECTS
database - (table/view/sequence/domain)
|- public
|- scheme1 -----
| |- table1
| |- t...
Configuration
authentication (pg hba.conf)
server (postgresql.conf)
storage considerations
Linux System Administration II D...
Working with PgSQL (psql and phpPgAdmin)
start/stop/restart/reload the server
server resouce limits(ulimits)
kernel tunnin...
Working with PgSQL (psql and phpPgAdmin)
storage types
standard types
XML/JSON
Network datatypes
PostGIS
ARRAYs
User define...
Working with PgSQL (psql and phpPgAdmin)
creating/destroying constrains
creating/destroying indexes
creating/destroying se...
Backup and restores
pg dump
pg dumpall
LVM snapshots
Via replication
WAL
Linux System Administration II DataBases - Postgr...
Monitoring
EXPLAIN ( Planner Cost Constants )
ps axf. . .
monitoring server
monitoring tables & indexes
Linux System Admin...
Upcoming SlideShare
Loading in...5
×

LSA2 - PostgreSQL

2,257

Published on

Published in: Education, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,257
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

LSA2 - PostgreSQL

  1. 1. DataBases - PostgreSQL Linux System Administration II Marian Marinov Linux System Administration II DataBases - PostgreSQL
  2. 2. Important links http://www.postgresql.org PostgreSQL 9.3 Documentation PostgreSQL Wiki pgFoundry projects pg-as-nosql-pgday-fosdem-2013.pdf Linux System Administration II DataBases - PostgreSQL
  3. 3. Installation Source RPM/DEB Linux System Administration II DataBases - PostgreSQL
  4. 4. Directory structure basic /var/lib/pgsql/data/* Debian based /etc/postgresql-common/ /etc/postgresql/9.3/main/ /var/lib/postgresql/9.3/main/ RedHat based old versions /var/lib/pgsql/data/* newer versions /var/lib/pgsql/9.3/data/* Linux System Administration II DataBases - PostgreSQL
  5. 5. Structure of PostgreSQL server prefork (shared memory) client handling (client library) query parser query analyzer query planner plug-in modules storage engine maintenance processes client client library parser autocomplete Linux System Administration II DataBases - PostgreSQL
  6. 6. On disk data structure | |- PG_VERSION |- base per-database subdirectories |- global cluster-wide tables, such as pg_database |- pg_clog transaction commit status data |- pg_multixact multitransaction status data |- pg_stat_tmp temporary files for the statistics subsyste |- pg_subtrans subtransaction status data |- pg_tblspc symbolic links to tablespaces |- pg_twophase state files for prepared transactions |- pg_xlog WAL (Write Ahead Log) files |... Linux System Administration II DataBases - PostgreSQL
  7. 7. On disk data structure base - |- 1 |- 11510 |- 11511 |- 16384 - 24576 template1=# SELECT datname,datlastsysoid FROM pg_database; datname | datlastsysoid -------------+---------------- template1 | 11510 template0 | 11510 postgres | 11510 os | 11510 (5 rows) Linux System Administration II DataBases - PostgreSQL
  8. 8. On disk data structure base - |- 11510 - | |- 24765 os# SELECT relname,relfilenode,reltablespace FROM pg_class WHERE relfilenode=24765; Relname | relfilenode | reltablespace ------------+---------------+--------------- disk_io | 24765 | 0 (1 row) Linux System Administration II DataBases - PostgreSQL
  9. 9. On disk data structure Table and Indexes are stored in separate files Tables bigger then 1GB are split into different files: filenode.1, filenode.2, . . . , filenode.N The 1GB limit can be changed during build using –with-segsize configure option. Linux System Administration II DataBases - PostgreSQL
  10. 10. DataBase Design DBNAME SCHME OBJECTS database - (table/view/sequence/domain) |- public |- scheme1 ----- | |- table1 | |- table2 | |- view1 | |- view2 | |- seq1 | - seq2 - scheme2 Linux System Administration II DataBases - PostgreSQL
  11. 11. Configuration authentication (pg hba.conf) server (postgresql.conf) storage considerations Linux System Administration II DataBases - PostgreSQL
  12. 12. Working with PgSQL (psql and phpPgAdmin) start/stop/restart/reload the server server resouce limits(ulimits) kernel tunning for PgSQL Linux System Administration II DataBases - PostgreSQL
  13. 13. Working with PgSQL (psql and phpPgAdmin) storage types standard types XML/JSON Network datatypes PostGIS ARRAYs User defined types (UDT) tablespaces list databases list users grant/revoke privileges creating/destroying users creating/destroying databases creating/destroying schemas creating/destroying tables Linux System Administration II DataBases - PostgreSQL
  14. 14. Working with PgSQL (psql and phpPgAdmin) creating/destroying constrains creating/destroying indexes creating/destroying sequences VACUUM/AUTOVACUUM VACUUM vs. ANALYZE built-in functions writing user functions adding a language to a database supported languages (SQL, pl/pgSQL, PL/Python, PL/Perl, PL/TCL, pl/V8, PL/R, PL/LUA, C) adding an extension to a database Foreign data wrappers Linux System Administration II DataBases - PostgreSQL
  15. 15. Backup and restores pg dump pg dumpall LVM snapshots Via replication WAL Linux System Administration II DataBases - PostgreSQL
  16. 16. Monitoring EXPLAIN ( Planner Cost Constants ) ps axf. . . monitoring server monitoring tables & indexes Linux System Administration II DataBases - PostgreSQL
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×