SlideShare a Scribd company logo
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-pgday-fosdem-2013.pdf
Linux System Administration II DataBases - PostgreSQL
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/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
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
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
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
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
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
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
Configuration
authentication (pg hba.conf)
server (postgresql.conf)
storage considerations
Linux System Administration II DataBases - PostgreSQL
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
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
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
Backup and restores
pg dump
pg dumpall
LVM snapshots
Via replication
WAL
Linux System Administration II DataBases - PostgreSQL
Monitoring
EXPLAIN ( Planner Cost Constants )
ps axf. . .
monitoring server
monitoring tables & indexes
Linux System Administration II DataBases - PostgreSQL

More Related Content

ODP
LSA2 - 02 Namespaces
ODP
LSA2 - 02 Control Groups
PDF
Containers and Namespaces in the Linux Kernel
PDF
Linux Containers From Scratch
PDF
Basic of Systemd
PDF
Tech talk Introduction to containers
PDF
2. Vagin. Linux containers. June 01, 2013
PDF
Linux Containers From Scratch: Makfile MicroVPS
LSA2 - 02 Namespaces
LSA2 - 02 Control Groups
Containers and Namespaces in the Linux Kernel
Linux Containers From Scratch
Basic of Systemd
Tech talk Introduction to containers
2. Vagin. Linux containers. June 01, 2013
Linux Containers From Scratch: Makfile MicroVPS

What's hot (20)

PDF
RPM Building
PDF
Introduction to systemd
PPTX
First steps on CentOs7
PDF
Linux containers-namespaces(Dec 2014)
PPTX
Linux container, namespaces & CGroup.
PDF
Advanced Namespaces and cgroups
PDF
PostgreSQL on EXT4, XFS, BTRFS and ZFS
PDF
PDF
redis-benchmark with AMD RYZEN 1800X Intel Kaby Lake (i7-7700K) memo
PDF
Pc bsd-intro
PDF
Linux io-stack-diagram v1.0
PDF
Containers with systemd-nspawn
PPTX
Linux Kernel Init Process
PDF
Linux kernel
PPT
Basic Linux kernel
PDF
Introduction to Linux
PDF
My First BCC
PPTX
Linux Process & CF scheduling
PPTX
Containers are the future of the Cloud
PDF
Backup with Bareos and ZFS - by Christian Reiß
RPM Building
Introduction to systemd
First steps on CentOs7
Linux containers-namespaces(Dec 2014)
Linux container, namespaces & CGroup.
Advanced Namespaces and cgroups
PostgreSQL on EXT4, XFS, BTRFS and ZFS
redis-benchmark with AMD RYZEN 1800X Intel Kaby Lake (i7-7700K) memo
Pc bsd-intro
Linux io-stack-diagram v1.0
Containers with systemd-nspawn
Linux Kernel Init Process
Linux kernel
Basic Linux kernel
Introduction to Linux
My First BCC
Linux Process & CF scheduling
Containers are the future of the Cloud
Backup with Bareos and ZFS - by Christian Reiß
Ad

Similar to LSA2 - PostgreSQL (20)

PDF
Trivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico Caldara
PDF
PostgreSQL Prologue
PPTX
MySQL database
PDF
MySQL for Oracle DBAs
PPTX
How to configure the cluster based on Multi-site (WAN) configuration
PDF
PGConf.ASIA 2019 Bali - AppOS: PostgreSQL Extension for Scalable File I/O - K...
PDF
Postgres 12 Cluster Database operations.
PDF
Mastering PostgreSQL Administration
PDF
Mastering PostgreSQL Administration
 
PDF
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
ODP
PDF
Collaborate 2012 - Administering MySQL for Oracle DBAs
ODP
PDF
PPTX
PDF
Wheeler w 0450_linux_file_systems1
PDF
Wheeler w 0450_linux_file_systems1
PDF
Tuning Linux for Databases.
PDF
Алексей Лесовский "Тюнинг Linux для баз данных. "
PPT
Big Data Engineering - MAP REDUCE - Unit-II.ppt
Trivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico Caldara
PostgreSQL Prologue
MySQL database
MySQL for Oracle DBAs
How to configure the cluster based on Multi-site (WAN) configuration
PGConf.ASIA 2019 Bali - AppOS: PostgreSQL Extension for Scalable File I/O - K...
Postgres 12 Cluster Database operations.
Mastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
Collaborate 2012 - Administering MySQL for Oracle DBAs
Wheeler w 0450_linux_file_systems1
Wheeler w 0450_linux_file_systems1
Tuning Linux for Databases.
Алексей Лесовский "Тюнинг Linux для баз данных. "
Big Data Engineering - MAP REDUCE - Unit-II.ppt
Ad

More from Marian Marinov (20)

PDF
How to start and then move forward in IT
PDF
Thinking about highly-available systems and their setup
PDF
Understanding your memory usage under Linux
PDF
How to implement PassKeys in your application
PDF
Dev.bg DevOps March 2024 Monitoring & Logging
PDF
Basic presentation of cryptography mechanisms
PDF
Microservices: Benefits, drawbacks and are they for me?
PDF
Introduction and replication to DragonflyDB
PDF
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
PDF
How to successfully migrate to DevOps .pdf
PDF
How to survive in the work from home era
PDF
Managing sysadmins
PDF
Improve your storage with bcachefs
PDF
Control your service resources with systemd
PDF
Comparison of-foss-distributed-storage
PDF
Защо и как да обогатяваме знанията си?
PDF
Securing your MySQL server
PDF
Sysadmin vs. dev ops
PDF
DoS and DDoS mitigations with eBPF, XDP and DPDK
PDF
Challenges with high density networks
How to start and then move forward in IT
Thinking about highly-available systems and their setup
Understanding your memory usage under Linux
How to implement PassKeys in your application
Dev.bg DevOps March 2024 Monitoring & Logging
Basic presentation of cryptography mechanisms
Microservices: Benefits, drawbacks and are they for me?
Introduction and replication to DragonflyDB
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
How to successfully migrate to DevOps .pdf
How to survive in the work from home era
Managing sysadmins
Improve your storage with bcachefs
Control your service resources with systemd
Comparison of-foss-distributed-storage
Защо и как да обогатяваме знанията си?
Securing your MySQL server
Sysadmin vs. dev ops
DoS and DDoS mitigations with eBPF, XDP and DPDK
Challenges with high density networks

Recently uploaded (20)

PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
IGGE1 Understanding the Self1234567891011
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
History, Philosophy and sociology of education (1).pptx
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Introduction to Building Materials
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Empowerment Technology for Senior High School Guide
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
1_English_Language_Set_2.pdf probationary
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Computing-Curriculum for Schools in Ghana
PDF
RMMM.pdf make it easy to upload and study
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Weekly quiz Compilation Jan -July 25.pdf
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
IGGE1 Understanding the Self1234567891011
Hazard Identification & Risk Assessment .pdf
Cell Types and Its function , kingdom of life
Final Presentation General Medicine 03-08-2024.pptx
History, Philosophy and sociology of education (1).pptx
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Introduction to Building Materials
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
A systematic review of self-coping strategies used by university students to ...
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Empowerment Technology for Senior High School Guide
What if we spent less time fighting change, and more time building what’s rig...
1_English_Language_Set_2.pdf probationary
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Computing-Curriculum for Schools in Ghana
RMMM.pdf make it easy to upload and study

LSA2 - PostgreSQL

  • 1. DataBases - PostgreSQL Linux System Administration II Marian Marinov Linux System Administration II DataBases - PostgreSQL
  • 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
  • 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. 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. 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. 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. 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. 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. 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. Configuration authentication (pg hba.conf) server (postgresql.conf) storage considerations Linux System Administration II DataBases - PostgreSQL
  • 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. 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. 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. Backup and restores pg dump pg dumpall LVM snapshots Via replication WAL Linux System Administration II DataBases - PostgreSQL
  • 16. Monitoring EXPLAIN ( Planner Cost Constants ) ps axf. . . monitoring server monitoring tables & indexes Linux System Administration II DataBases - PostgreSQL