Postgres主進程文件—postmaster.pid

正如上一篇文章PostgreSQL的核心架構所講,PostgresSQL的主進程是Postmaster,當我們啓動PostgresSQL後,會在PostgreSQL中的數據文件夾下生產一個postmaster.pid的文件,那麼這個文件記錄了什麼信息呢,我通過查閱源代碼以及相關文檔,對此文件進行內容進行說明:

postmaster內容

使用cat -n 命令可以查看postmaster.pid文件內容:

這裏寫圖片描述)

根據每一行進行解釋,並給出對應的源代碼說明

  1. 13795: 代表Postgres主進程的PID

    這裏寫圖片描述

  2. /usr/local/pgsql/data: 代表數據目錄

  3. 1529235109: 代表postmaster文件的創建時間。

  4. 5432: 代表數據庫監聽端口,在postgresql.conf中對應port = 5432

    來自源代碼說明:

    /* The socket number we are listening for connections on */
    int           PostPortNumber;
  5. /tmp: 代表是unix socket的監聽目錄,在postgresql.conf中對應 unix_socket_directory = '/tmp'

    來自源代碼說明:

    /* The directory names for Unix socket(s) */
    char     *Unix_socket_directories;
  6. * : 代表數據庫監聽地址,對應postgresql.conf的listen_addresses = '\* '

    來自源代碼說明:

    /* The TCP listen address(es) */
    char     *ListenAddresses;
  7. 5432001 163840:代表的是共享內存的地址(shared memory segments中的key和shmid)。

    輸入ipcs可以查看:

    這裏寫圖片描述

    注: postmaster.pid顯示的是key轉成10進制後的數字。

  8. ready 代表主進程狀態

typedef enum
{
    PM_INIT,                    /* postmaster starting */
    PM_STARTUP,                 /* waiting for startup subprocess */
    PM_RECOVERY,                /* in archive recovery mode */
    PM_HOT_STANDBY,             /* in hot standby mode */
    PM_RUN,                     /* normal "database is alive" state */
    PM_WAIT_BACKUP,             /* waiting for online backup mode to end */
    PM_WAIT_READONLY,           /* waiting for read only backends to exit */
    PM_WAIT_BACKENDS,           /* waiting for live backends to exit */
    PM_SHUTDOWN,                /* waiting for checkpointer to do shutdown
                                 * ckpt */
    PM_SHUTDOWN_2,              /* waiting for archiver and walsenders to
                                 * finish */
    PM_WAIT_DEAD_END,           /* waiting for dead_end children to exit */
    PM_NO_CHILDREN              /* all important children have exited */
} PMState;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章