当前位置:网站首页>If you want to understand PostgreSQL, you must first brush the architecture
If you want to understand PostgreSQL, you must first brush the architecture
2022-06-23 04:33:00 【It bond】
hello ! Hello everyone , I am a 【IT bond 】, Jianghu people jeames007,10 year DBA Work experience
A highly motivated 【 Bloggers in big data field 】!
China DBA union (ACDU) member , Currently engaged in DBA And program programming ,B Station and Tencent classroom lecturer , Live broadcast volume breaking 10W
Good at mainstream data Oracle、MySQL、PG Operations and development , Backup recovery , Installation migration , performance optimization 、 Fault emergency treatment, etc .
If there is a pair of 【 database 】 Interested in 【 Cutie 】, Welcome to your attention 【IT bond 】
️️️ Thank you, big and small !️️️
List of articles
Preface
This paper deals with PostgreSQL The architecture of , I hope that's helpful️ 1. Physical structure


1.1 Directory description
postgresql.conf: Parameter file
pg_hba.conf: Black and white list
PG_VERSION:PG Large version number file
postgresql.auto.conf:alter system Set the configuration parameters
postmaster.pid: Database process 、 root directory 、 Port number and other information
global: Data dictionary information file
pg_wal: Online log directory
pg_log: Alarm log
1.2 Alarm file (pg_log)
effect : The running log of the database is recorded , Alarm log , Error log
Off by default , If you want to configure, you need to postgresql.conf Middle configuration
## Parameter file configuration
logging_collector = on
log_directory = ‘pg_log’
log_filename = ‘postgresql-%a.log’
log_truncate_on_rotation = on
## Modify online log format
postgres=# alter system set log_filename = ‘postgresql-%Y-%m-%d_%H%M%S.log’;
notes : Need to restart the database
pg_ctl stop
pg_ctl start
postgres=# select name from pg_settings where name
in (‘log_filename’,‘log_directory’,‘logging_collector’);

1.3 Online log (pg_wal)
stay $PGDATA/pg_wal, A single file is 16M, Internal unreadable , Unable to close , During physical backup , To back up this file
## The way of cutting logs
postgres=# select pg_switch_wal();
pg_switch_wal
---------------
0/15679F0
(1 row)
postgres=# show archive_timeout;
jmedb=# select * from pg_ls_waldir();
Position in :cd $PGDATA/pg_wal

1.4 Transaction commit log (pg_xact)
Transaction commit log , Record Metadata ; Directory in $PGDATA/pg_xact
1.5 Control documents
/postgresql/pgdata/global/pg_control
View control file information
[[email protected] ~]$ pg_controldata

️ 2. Memory structure
2.1 classification
Local memory area (Local mermory area): Each back-end process is allocated for its own use ( Customer service )
Shared memory area (Shared mermory area): All processes on the server use

2.2 Shared memory
The shared memory area consists of PostgreSQL The server allocates at startup . This area is also divided into several sub areas of fixed size .

a.shared buffer pool
The data of the disk is loaded into this memory , Operate them directly , Reduce the disk of IO
Fast access to data
Many users can access shared memory
Solve the problem of frequent access to disk
b.WAL buffer
Changing data blocks are cached in this area , Later, the database writes online logs , It ensures that the data will not be lost due to server failure
c.CommitLog
Save the state of all transactions , Later used for concurrency control
Submission state :committed; Status not submitted :in_progress
2.2 Local memory

work_mem: Sort table , Or table connection (hash join/merge join)
temp_buffers: Store temporary tables , Users can access the buffered data in this area
maintenance_work_mem: Do some maintenance work related to the table ( Rebuild index 、 Add foreign keys 、 Collect statistics )
Need to use this memory
️ 3.PG Learning Guide

1. Recommended reading 《PostgreSQL The nine story pagoda of learning 》:
https://mp.weixin.qq.com/s/i7b6FvY3PYC2JENCgiVxjQ
2. Can learn and read independently PG Basic documents of application management ,
This part is mainly about China PG Branch training certification PGCA Excerpts from the course ,
Related links :http://www.postgresqlchina.com/tecdoc
3.PG The main site of learning
PG The international community :https://www.postgresql.org/1)PG Summary :https://www.postgresql.org/about/
2)PG Online help documentation ( English version , many PG edition ):
https://www.postgresql.org/docs/
3) Can also pass PG Consult and learn Chinese manuals , Access address :
http://www.postgres.cn/docs/10/;
http://www.postgres.cn/docs/11/
4) Installation media download address :
https://www.postgresql.org/download/
There are mainly binary 、 There are two ways to compile and install the source code , Binary installation media correspond to different operating systems .
There is also an exception based on PG Installation of product release version ,
The installation media and installation methods can be obtained through the company's official website of the product ,
For example, Ali POLARDB、 Yaxin ANTDB、 tencent TBase、 Huawei GaussDB、 Hangao HGDB etc. .
5) Online learning resources
https://www.postgresql.org/docs/online-resources/
Contains rich tutorials 、 Hands on practice resources
边栏推荐
- 3D数学基础[十六] 匀加速直线运动的公式
- Background ribbon animation plug-in ribbon js
- Halcon glue line detection - template matching, pose transformation, glue width, glue continuity detection
- Avltree - arbre de recherche binaire équilibré
- Weekly Postgres world news 2022w02
- Redis启动有问题
- QMainWindow
- Particle animation background login page particles js
- svg d3. JS generate tree tree view
- [learn FPGA programming from scratch -40]: Advanced - Design - competition and risk
猜你喜欢

在线JSON转CSharp(C#)Class工具

【二叉樹進階】AVLTree - 平衡二叉搜索樹

Analysis on the current situation of the Internet of things in 2022

摆烂LuoGu刷题记
![[deep learning] deep learning reasoning framework tensorrt MNN openvino onnxruntime](/img/a9/11bc00a91b79358f28ada2d4c99f32.png)
[deep learning] deep learning reasoning framework tensorrt MNN openvino onnxruntime

炫酷鼠标跟随动画js插件5种

Implementation of VGA protocol based on FPGA

8 key indicators to measure technology debt in 2022

Online JSON to CSharp (c) class tool

x24Cxx系列EEPROM芯片C语言通用读写程序
随机推荐
Preface
【二叉树】二叉树的完全性检验
leetcode 91. Decode Ways 解码方法(中等)
How to make the page number start from the specified page in word
粒子动画背景登录页面particles.js
虫子 STM32 中断 (懂的都懂)
Section 2: spingboot unit test
QMainWindow
PTA:7-61 师生信息管理
Common events for elements
Similar to RZ / SZ, trzsz supporting TMUX has released a new version
Photoshop PS viewing pixel coordinates, pixel colors, pixel HSB colors
Code refactoring Guide
What is the digital "true" twin? At last someone made it clear!
How can I realize video call and interactive live broadcast in a small program?
【Pytorch】用自动微分求sin(x)的导数
【深度学习】深度学习推理框架 TensorRT MNN OpenVINO ONNXRuntime
A summary of PostgreSQL data types. All the people are here
Compilation, installation and global configuration section description of haproxy
PTA:6-71 时钟模拟