PostgreSQL
Agenda
Mind Migration
Some terminology
Architecture
Security
17.2.2016
PostgreSQL
The world's most advanced
open source database.
Understand differences
Migration guide
Commons in behavior
RDBMS ranking
Displeasure prevention
Feature matrix
17.2.2016
Mind Migration
PostgreSQL
The world's most advanced
open source database.
17.2.2016
PostgreSQL
Terminology
Architecture/concepts
Logical
Role
User
Database
Schema
Tablespace
Cluster
Instance
Architectural Fundamentals
Documentation index
17.2.2016
PostgreSQL
The world's most advanced
open source database.
Oracle SW installation
ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/db
Oracle SW installation
ORACLE_HOME
/u01/app/oracle/product/12.1.0.2/db
Oracle instance
ORACLE_SID
SALES
Oracle instance
ORACLE_SID
EMPLOYEE
Oracle instance
ORACLE_SID
DWH
Oracle instance
ORACLE_SID
INWEB
Database
SALES
Database
EMPLOYEE
Database
DWH
Database
INWEB
17.2.2016
PostgreSQL
The world's most advanced
open source database.
PostgreSQL instance
Running postgres process
PGDATA
/var/lib/pgsql/9.4/data
Database
template0
17.2.2016
Database
template1
PostgreSQL instance
Running postgres process
PGDATA
/var/lib/pgsql/9.4/data2
Database
postgres
Database
INWEB
Internal
Internalpurpose,
purpose,meta
metadata
datacatalog
catalog
Database
DWH
Database
SALES
Applications
Applicationsdatabases
databases
PostgreSQL
The world's most advanced
open source database.
Oracle SW installation
ORACLE_HOME
/u01/app/oracle/product/12.1.0.2/db
PostgreSQL instance
Running postgres process
PGDATA
/var/lib/pgsql/9.4/data
template0 template1
17.2.2016
postgres
INWEB
DWH
Oracle instance
ORACLE_SID
DWH
Oracle instance
ORACLE_SID
INWEB
Database
DWH
Database
INWEB
SALES
PostgreSQL
Host: first
Instance: MYDB1
Host: second
Instance: MYDB2
Parameter file
Password file
Data files
Host: third
Instance: MYDB3
Host: ..nth
Instance: MYDB<N>
Archived Logs
Database
MYDB
UNDO TS
17.2.2016
PostgreSQL
Contains configuration files, and in default setup also files for all databases residing within a
particular Postgres cluster, see documentation Database File Layout
database cluster
TIME CMD
00:00:00 /usr/bin/postgres -D /var/lib/pgsql/data -p 5433
pg_stat/
pg_stat_tmp/
pg_subtrans/
pg_tblspc/
pg_twophase/
PG_VERSION
pg_xlog/
postgresql.conf
postmaster.opts
postmaster.pid
Configuration files
Databases directory
PostgreSQL
Postgres similar to Oracle might create archive of online logs for PITR
and other purposes
Instead of Oracle Archiver server processes, Postgres used to call any external
command responsible for copying inactive online log to some other destination
database cluster
TIME CMD
00:00:00 /usr/bin/postgres -D /var/lib/pgsql/data -p 5433
Configuration files
pg_stat/
Databases directory
pg_stat_tmp/
pg_subtrans/
postgres=# select oid, datname from
pg_database;
pg_tblspc/
oid | datname
pg_twophase/
tree base | head -5
-------+----------base
PG_VERSION
1 | template1
1
Data files
pg_xlog/ Online Redo
12968 | template0
12706
postgresql.conf
Parameter file 12973 | postgres
12706_fsm
(3 rows)
postmaster.opts
12706_vm
postmaster.pid
17.2.2016
Control files
11
archive_command ...
Password file
documentation
Archived Logs
Outage prevention
PostgreSQL
17.2.2016
12
PostgreSQL
The world's most advanced
open source database.
Before image is
Stored in UNDO
segment
Undo segments
Cyclic buffer
17.2.2016
13
PostgreSQL
The world's most advanced
open source database.
17.2.2016
14
PostgreSQL
WAL files
(2 + checkpoint_completion_target) *
checkpoint_segments + 1 or checkpoint_segments +
wal_keep_segments + 1 files. Each segment file is normally
16 MB.
17.2.2016
15
Archive_mode
PostgreSQL
wal_level
minimal
Archive
hot_standby
17.2.2016
16
PostgreSQL
Memory
Instance
Oracle structure:
SGA
Shared pool
Parameters relation.
Data buffer
cache
Oracle
Postgres
db_cache_size
shared_buffers
sort_area_size
(pga_aggregate_target)
work_mem,
temp_buffers
log_buffer_size
wal_buffers
SMON
DBW0
PMON
maintetance_work_mem
effective_cache_size
Postgres structure:
Nice description can be
found at link:
PostgreSQL 9.0 Architecture
17.2.2016
CKPT
Work mem
Maintenanace work mem
Temp buffer
Catalog cache
Optimizer/executor
LGWR
ostatn
SHARED MEMORY
Library Cache
Redo log
buffer
shared buffers
wal buffers
CLOG buffers
Locks space
Other buffers
17
PostgreSQL
Logical
Physical
Tablespaces
Segment
Data file
Extent
Operating
system block
Oracle block
17.2.2016
18
PostgreSQL
DB cluster
Physical
PGDATA
Tablespaces
pg_default
PGDATA/base
pg_global
PGDATA/global
custom
Tablespaces:
symlinks to
physical
directories
pg_tblspc/
Database
File name:
pg_class.relfilenode
DB Objects
table, index...
Data files
+free space map (_fsm)
+visibility map (_vm)
1GB default size limit,
subsequent files are created
automatically
8k pages
17.2.2016
Operating
system block
19
PostgreSQL
Database I
Database II
Database III
Tablespace_A
DB cluster
datafile
datafile
datafile
datafile
datafile
Default tablespace
PGDATA/base
17.2.2016
datafile
datafile
datafile
Tablespace_B
20
Architecture - connections
Oracle
Multi-threaded server
17.2.2016
pg_hba.conf (user/database/network
restrictions)
postgresql.conf (TCP port, kerberos,
RDBMS cofiguration...)
PostgreSQL
listener.ora (network
restrictions, TCP port)
sqlnet.ora (protocol
configuration, kerberos...)
PostgreSQL
PgBouncer
pgpool-II
21
PostgreSQL
Architecture notes
Oracle
17.2.2016
PostgreSQL
Do not re-implement
features already
implemented in OS,
thus it use file system to
store its data files (no
RAW device support)
22
Security observations I
Users and Roles are defined on DB level (not applies for PDB)
PostgreSQL
17.2.2016
23
PostgreSQL
Security observations
SW installation:
/oracle/product/12.1.0.2/db_1
OS access control to files
user1
RoleOne
X
Does't work
user3
TableA
TableB
TableA
RoleTwo
TableB
FunctionC
user2
Schema:
user2
FunctionC
Schema:
user3
X - Does't work
17.2.2016
24
Security observations II
PostgreSQL
One role might have granted access on objects from multiple databases
17.2.2016
25
PostgreSQL
The world's most advanced
open source database.
Oracle distinguish
17.2.2016
26
Security observations IV
PostgreSQL
The world's most advanced
open source database.
Postgres
SSO available
17.2.2016
27
Security observations V
PostgreSQL
tcp.validnode_checking = yes
tcp.invited_nodes = (hostname1, hostname2)
tcp.excluded_nodes = (192.168.10.3)
Postgres
pg_hba.conf File
17.2.2016
28
Security observations VI
PostgreSQL
The world's most advanced
open source database.
Postgres
17.2.2016
29
Security features...
PostgreSQL
17.2.2016
30
PostgreSQL
The world's most advanced
open source database.
Postgres
pg_dump / pg_restore
17.2.2016
31
Manual
PostgreSQL
pg_basebackup
17.2.2016
Handle calls to backup control functions and might produce copy of postgres
cluster or tar archive with the backup. Some features are available like
tablespace mapping for convenient backup procedure/higher flexibility
PostgreSQL for Oracle DBAs
32
pgBarman
PostgreSQL
pgBackRest
17.2.2016
33
PostgreSQL
HA & DR
Simply works
17.2.2016
34
Oracle replication
PostgreSQL
The world's most advanced
open source database.
Oracle DataGuard
ARCHIVE_LAG_TARGET
ASYNC
SYNC
Delayed recovery - DELAY=minutes attribute of the
LOG_ARCHIVE_DEST_n
Logical standby
Golden Gate
17.2.2016
35
RDBMS replication
PostgreSQL
The world's most advanced
open source database.
Postgres
Log-Shipping Standby Servers
Streaming Replication
archive_timeout
ASYNC (default)
SYNC - Synchronous Replication
Standby Server Settings recovery_min_apply_delay available from
9.4
Logical Standby
17.2.2016
36
PostgreSQL
Others I
17.2.2016
37
PostgreSQL
Others II
db links
PostgreSQL
select function();
17.2.2016
select 5/8;
38
PostgreSQL
Others III
39
Others partitioning
PostgreSQL
17.2.2016
40
PostgreSQL
The world's most advanced
open source database.
Bonus link:
How to find out which PostgreSQL table a file on
disk corresponds to
17.2.2016
41