{"id":81,"date":"2023-09-24T23:56:22","date_gmt":"2023-09-24T20:56:22","guid":{"rendered":"http:\/\/pgdataeraold.local\/?p=81"},"modified":"2023-09-24T23:56:22","modified_gmt":"2023-09-24T20:56:22","slug":"postgresql-architecture","status":"publish","type":"post","link":"https:\/\/pgdataera.com\/en\/postgresql-architecture\/","title":{"rendered":"PostgreSQL Architecture Overview"},"content":{"rendered":"\n<p>The architecture of Postgresql consists of 3 main components:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Memory<\/li>\n\n\n\n<li>Process<\/li>\n\n\n\n<li>Storage Cluster<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"http:\/\/pgdataeraold.local\/wp-content\/uploads\/2023\/09\/image.png\" alt=\"\" class=\"wp-image-74\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-alpha-channel-opacity has-vivid-green-cyan-background-color has-background is-style-wide\" style=\"margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20)\" \/>\n\n\n\n<p>Postgresql Instance: It consists of <mark style=\"background-color:var(--ast-global-color-6)\" class=\"has-inline-color\">background processes, helper processes, and a<br>shared buffer area.<\/mark><br>The postmaster process manages the instance. An instance can only manage a<br>database cluster and its databases (Cluster concept is explained in detail in Storage<br>topic).<br>More than one instance can run on the same server at the same time, provided that<br>they are on different TCP ports.<br>The tasks of instance are Read\/write (I\/O), provision of ACID conditions, a connection<br>of client processes, access control, recovery\/restore, replication, etc.<br>When the database is started with <code><code data-enlighter-language=\"postgresql\" class=\"EnlighterJSRAW\">systemctl<\/code><\/code> or <code data-enlighter-language=\"postgresql\" class=\"EnlighterJSRAW\">pg_ctlcluster (pg_cluster)<\/code>,                                                                                              it assigns the memory from the operating system according to the<br>memory settings in the configuration file, starts the processes, and makes it available<br>for the clients to access.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"postgresql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">When the instance is stopped;\nroot@srv2:~# ps f -upostgres\nroot@srv2:~# top -u postgres\nPID TTY STAT TIME COMMAND\ntop - 19:19:21 up 6:45, 2 users, load average: 0.00, 0.00, 0.00\nTasks: 75 total, 1 running, 74 sleeping, 0 stopped, 0 zombie\n%Cpu(s): 0.0 us, 0.7 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.0 hi,0.0 si, 0.0 st\nMiB Mem : 1995.4 total, 1601.4 free, 107.2 used, 286.8 buff\/cache\nMiB Swap: 0.0 total, 0.0 free, 0.0 used. 1718.0 avail Mem\nPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-alpha-channel-opacity has-vivid-green-cyan-background-color has-background is-style-wide\" style=\"margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20)\" \/>\n\n\n\n<p><code data-enlighter-language=\"bash\" class=\"EnlighterJSRAW\">ps f -upostgres<\/code> ve <code data-enlighter-language=\"bash\" class=\"EnlighterJSRAW\">top -u postgres<\/code><br>When we check with the above commands, no postgresql processes or postgres users<br>are listed.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"postgresql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">When the Instance is started:\n# root kullan\u0131c\u0131s\u0131 ile ya da sudo yetkisi olan bir kullan\u0131c\u0131 \nile ba\u015f\u0131na \u201c sudo \u201d ekleyerek;\n\nsystemctl start postgresql\n\n# logu izleyelim, log dosyas\u0131n\u0131n ismi sizde farkl\u0131 olabilir \n\u201cls-ltr \u201d ile s\u0131ralay\u0131p en g\u00fcncel olan\u0131 kullanabilirsiniz.\n\ntail -f \/var\/log\/postgresql\/postgresql-13-main.log<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-alpha-channel-opacity has-vivid-green-cyan-background-color has-background is-style-wide\" \/>\n\n\n\n<p>While starting, the following logs can be seen.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"postgresql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#Another instance\n\/pg\/13.4\/bin\/pg_ctl -D \/pgdata\/13.4 -l pg_$DATE.log start\npostgres@srv2:~$ ps f -upostgres\n\/pg\/13.4\/bin\/postgres -D \/pgdata\/13.4\n_ postgres: checkpointer\n_ postgres: background writer\n_ postgres: walwriter\n_ postgres: autovacuum launcher\n_ postgres: stats collector\n_ postgres: logical replication launcher<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-alpha-channel-opacity has-vivid-green-cyan-background-color has-background is-style-wide\" style=\"margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20)\" \/>\n\n\n\n<p>When we execute <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">ps f -upostgres<\/code> and <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">top -u postgres<\/code> again, it lists<br>the processes that are opened and the instance assigns memory from the operating<br>system. This shows that the resources have been used.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Postgresql Connections<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"687\" height=\"370\" src=\"http:\/\/pgdataeraold.local\/wp-content\/uploads\/2023\/11\/image-18.png\" alt=\"\" class=\"wp-image-1396\" srcset=\"https:\/\/pgdataera.com\/wp-content\/uploads\/2023\/11\/image-18.png 687w, https:\/\/pgdataera.com\/wp-content\/uploads\/2023\/11\/image-18-300x162.png 300w\" sizes=\"auto, (max-width: 687px) 100vw, 687px\" \/><\/figure><\/div>\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-alpha-channel-opacity has-vivid-green-cyan-background-color has-background is-style-wide\" \/>\n\n\n\n<p>The daemon process listens for connection requests from clients and creates a server\/<br>backend process for each incoming connection request. When the daemon process is<br>not running, a connection over the network cannot be made.<br>When the client sends a connection request, the daemon process fulfills this request<br>and creates a backend process. After the backend process has been authenticated,<br>query, data entry\/update etc. coming from the client (client) is processed. The backend<br>process acts as the user\u2019s agent.<br>These processes are repeated for each incoming connection request and server\/<br>backend processes are created as many as the number of connections, up to the<br><code>max_connection<\/code> limit.<\/p>\n\n\n\n<p><mark style=\"background-color:var(--ast-global-color-6)\" class=\"has-inline-color\">Note: Having an extension line between two departments in your office indicates that<br>the connection exists. Whenever one calls the other and the other party opens and<br>starts the communication, the session is started.<\/mark><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"410\" src=\"http:\/\/pgdataeraold.local\/wp-content\/uploads\/2023\/11\/image-20.png\" alt=\"\" class=\"wp-image-1398\" srcset=\"https:\/\/pgdataera.com\/wp-content\/uploads\/2023\/11\/image-20.png 716w, https:\/\/pgdataera.com\/wp-content\/uploads\/2023\/11\/image-20-300x172.png 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-alpha-channel-opacity has-vivid-green-cyan-background-color has-background is-style-wide\" \/>\n\n\n\n<p>When users connect to the database, they usually want to read (<code>select<\/code>) or write<br>(<code>DML=insert\/update\/delete<\/code>) data. Software developers generally need<br>operations such as adding columns\/indexes to the table.<br>Multiple connections can be made at the same time with the same user.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The architecture of Postgresql consists of 3 main components: Postgresql Instance: It consists of background processes, helper processes, and ashared buffer area.The postmaster process manages the instance. An instance can only manage adatabase cluster and its databases (Cluster concept is explained in detail in Storagetopic).More than one instance can run on the same server at <a href=\"https:\/\/pgdataera.com\/en\/postgresql-architecture\/\" class=\"more-link\">&#8230;<span class=\"screen-reader-text\">  PostgreSQL Architecture Overview<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[277],"tags":[],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-postgresql-database-architecture"],"_links":{"self":[{"href":"https:\/\/pgdataera.com\/en\/wp-json\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pgdataera.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pgdataera.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pgdataera.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pgdataera.com\/en\/wp-json\/wp\/v2\/comments?post=81"}],"version-history":[{"count":0,"href":"https:\/\/pgdataera.com\/en\/wp-json\/wp\/v2\/posts\/81\/revisions"}],"wp:attachment":[{"href":"https:\/\/pgdataera.com\/en\/wp-json\/wp\/v2\/media?parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pgdataera.com\/en\/wp-json\/wp\/v2\/categories?post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pgdataera.com\/en\/wp-json\/wp\/v2\/tags?post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}