postgresql幾個與主備同步有關的參數解析

      網友投稿 1597 2025-04-01

      postgresql里有很多和主備同步有關的參數,其中比較重要的兩個是synchronous_commit 和?synchronous_standby_names。下面我們來分析下這兩個參數。


      1. synchronous_commit

      這個參數用來設置事務提交返回客戶端之前,一個事務是否需要等待 WAL 記錄被寫入磁盤。合法的值是{local,remote_write,remote_apply,on,off}

      默認的并且安全的設置是on。

      local

      當事務提交時,寫入本地磁盤即可,不用關心備機的情況。

      postgresql的幾個與主備同步有關的參數解析

      remote_write:

      表示流復制主庫提交事務時,需等待備庫接收主庫發送的wal日志流并寫入備節點操作系統緩存中,之后向客戶端返回成功,這種情況下備庫出現異常關閉時不會有已傳送的wal日志丟失風險,但備機操作系統異常宕機就有已傳送的wal丟失風險

      這個選項帶來的事務響應時間較短。

      on:

      1 為on且沒有開啟同步備庫的時候,會當wal日志真正刷新到磁盤永久存儲后才會返回客戶端事務已提交成功,

      2 當為on且開啟了同步備庫的時候(設置了synchronous_standby_names),必須要等事務日志刷新到本地磁盤,并且還要等遠程備庫也提交到磁盤才能返回客戶端已經提交.

      remote_apply:

      表示流復制主庫提交事務時,需等待備庫接收主庫發送的wal流并寫入wal文件,同時備庫已經完成回放,之后才向客戶端返回成功,簡單的說remote_apply 表示本地wal已落盤,備庫wal已落盤并且已經完成回放,這個設置保證了擁有兩份持久化的wal,同時備庫也已經完成了回放。

      這個選項帶來的事務響應時間最長。

      off:

      當數據庫事務提交時不需要等待本地 wal buffer 寫入 wal 日志,立刻向客戶端返回成功

      2. synchronous_standby_names

      這個參數用來指定同步備機的列表,存放的是需要設置為同步備機的備機名稱,以逗號隔開。

      Specifies a comma-separated list of standby names that can support synchronous replication, as described in Section 25.2.7. At any one time there will be at most one active synchronous standby; transactions waiting for commit will be allowed to proceed after this standby server confirms receipt of their data. The synchronous standby will be the first standby named in this list that is both currently connected and streaming data in real-time (as shown by a state of streaming in the pg_stat_replication view). Other standby servers appearing later in this list represent potential synchronous standbys. If the current synchronous standby disconnects for whatever reason, it will be replaced immediately with the next-highest-priority standby. Specifying more than one standby name can allow very high availability. The name of a standby server for this purpose is the application_name setting of the standby, as set in the primary_conninfo of the standby's walreceiver. There is no mechanism to enforce uniqueness. In case of duplicates one of the matching standbys will be chosen to be the synchronous standby, though exactly which one is indeterminate. The special entry * matches any application_name, including the default application name of walreceiver. If no synchronous standby names are specified here, then synchronous replication is not enabled and transaction commits will not wait for replication. This is the default configuration. Even when synchronous replication is enabled, individual transactions can be configured not to wait for replication by setting the synchronous_commit parameter to local or off. This parameter can only be set in the postgresql.conf file or on the server command line.

      綜上可以看出,第一個參數控制的是事務提交的時候到底要不要等備機以及怎么等,第二個參數控制的是那些節點可以成為同步備機。

      PostgreSQL 云容災

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:WPS表格怎么設置數據自動求和(WPS表格怎樣自動求和)
      下一篇:如何使用WPS快速截屏?(wps里如何截屏)
      相關文章
      亚洲免费二区三区| 1区1区3区4区产品亚洲| 亚洲理论片在线观看| 久久亚洲综合色一区二区三区| 亚洲日韩精品无码专区网站| 国产亚洲综合精品一区二区三区| 亚洲久热无码av中文字幕| 亚洲色成人网站WWW永久四虎| 亚洲中文字幕无码一去台湾| 亚洲91精品麻豆国产系列在线| 亚洲国产美女精品久久| 亚洲欧洲日本国产| 亚洲女人18毛片水真多| 亚洲午夜精品一区二区公牛电影院| 亚洲欧洲精品久久| 亚洲国产电影在线观看| 亚洲一区精品视频在线| 亚洲香蕉久久一区二区| 亚洲人成网站在线播放2019 | 亚洲人成伊人成综合网久久久| 亚洲日本va中文字幕久久| 亚洲乱码国产乱码精品精| 亚洲线精品一区二区三区影音先锋 | 久久久久亚洲精品影视| 久久久久亚洲AV成人无码| 亚洲av日韩综合一区在线观看| 亚洲乱码国产乱码精品精| 亚洲AV日韩AV永久无码久久 | 亚洲日韩一区二区三区| 亚洲精品国产综合久久久久紧| 精品国产日韩亚洲一区91| 亚洲黄片手机免费观看| 精品亚洲成α人无码成α在线观看 | 亚洲综合校园春色| 亚洲精品无码久久久久YW| 亚洲a∨无码一区二区| 亚洲区小说区图片区| 亚洲欧洲国产精品香蕉网| 亚洲国产高清在线| 亚洲av永久无码嘿嘿嘿| 亚洲AV成人无码网站|