1.2 Architectural Fundamentals
1.2 基礎(chǔ)架構(gòu)
在深入學(xué)習(xí)之前,需要首先理解PostgreSQL基本的系統(tǒng)架構(gòu)。明白PostgreSQL各部分之間如何交互的,對(duì)于搞明白接下來介紹的知識(shí)點(diǎn)至關(guān)重要。
PostgreSQL是客戶端/服務(wù)器架構(gòu)。一個(gè)PostgreSQL會(huì)話包含以下相關(guān)的進(jìn)程:
-
服務(wù)器進(jìn)程。管理數(shù)據(jù)庫文件,接受并執(zhí)行客戶端連接請(qǐng)求。數(shù)據(jù)庫服務(wù)器進(jìn)程叫做:postgres。
-
想要進(jìn)行數(shù)據(jù)庫操作的客戶端程序。客戶端程序可以多種多樣:可以是一個(gè)文本工具,一個(gè)圖形化程序,一個(gè)展示數(shù)據(jù)庫數(shù)據(jù)的頁面,或者一個(gè)專用的數(shù)據(jù)庫維護(hù)工具。有些客戶端程序同PostgreSQL一起發(fā)布,但大部分是用戶自己開發(fā)的。
?因?yàn)槭强蛻舳?服務(wù)器架構(gòu),所以客戶端和服務(wù)器可以在不同的主機(jī)上,并通過TCP/IP通信。你必須牢記這一點(diǎn),因?yàn)樵诳蛻舳藱C(jī)器上可以訪問的文件,可能并不能在服務(wù)器上訪問(或者只能以不同的文件名訪問)。
?PostgreSQL服務(wù)器進(jìn)程可以處理多個(gè)客戶端的并發(fā)連接。它通過為每一個(gè)連接“fork”一個(gè)新的進(jìn)程來實(shí)現(xiàn)此功能??蛻舳伺cfork出來的新進(jìn)程通信的時(shí)候,原postgres進(jìn)程就不會(huì)再干預(yù)了。所以,postgres進(jìn)程是一直在運(yùn)行的,等待客戶端的連接,然后fork出來的進(jìn)程就隨著客戶端連接的斷開而消逝,隨著客戶端的連接而新生。(當(dāng)然,這是對(duì)用戶透明的,這里的描述是為了用戶對(duì)于PostgreSQL理解的全面性而做出的努力。)
1.2. Architectural Fundamentals
Before we proceed, you should understand the basic PostgreSQL system architecture. Understanding how the parts of PostgreSQL interact will make this chapter somewhat clearer.
In database jargon, PostgreSQL uses a client/server model. A PostgreSQL session consists of the following cooperating processes (programs):
? A server process, which manages the database files, accepts connections to the database from client applications, and performs database actions on behalf of the clients. The database server program is called postgres.
? The user's client (frontend) application that wants to perform database operations. Client applications can be very diverse in nature: a client could be a text-oriented tool, a graphical application, a web server that accesses the database to display web pages, or a specialized database maintenance tool. Some client applications are supplied with the PostgreSQL distribution; most are developed by users.
As is typical of client/server applications, the client and the server can be on different hosts. In that case they communicate over a TCP/IP network connection. You should keep this in mind, because the files that can be accessed on a client machine might not be accessible (or might only be accessible using a different file name) on the database server machine.
The PostgreSQL server can handle multiple concurrent connections from clients. To achieve this it starts (“forks”) a new process for each connection. From that point on, the client and the new server process communicate without intervention by the original postgres process. Thus, the master server process is always running, waiting for client connections, whereas client and associated server processes come and go. (All of this is of course invisible to the user. We only mention it here for completeness.)
?
總結(jié)
以上是生活随笔為你收集整理的1.2 Architectural Fundamentals的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Game Hacking Fundame
- 下一篇: 中小企业使用财务软件有以下好处