標籤:postgresql 資料庫 最大串連數 資料庫連接數
最近監控系統的資料庫監控總是延遲,查看日誌報錯:
2015-08-27 10:20:19,534 ERROR Traceback (most recent call last): File "oracle_mon.py", line 306, in <module> update_status(ip, ‘stop‘, timer.end_date) File "oracle_mon.py", line 285, in update_status pg.db.update("oracle_mon", where=where, status=status, stat_date=status_date) File "/usr/lib/python2.7/site-packages/web/db.py", line 881, in update db_cursor = self._db_cursor() File "/usr/lib/python2.7/site-packages/web/db.py", line 566, in _db_cursor return self.ctx.db.cursor() File "/usr/lib/python2.7/site-packages/web/db.py", line 507, in _getctx self._load_context(self._ctx) File "/usr/lib/python2.7/site-packages/web/db.py", line 516, in _load_context ctx.db = self._connect_with_pooling(self.keywords) File "/usr/lib/python2.7/site-packages/web/db.py", line 970, in _connect_with_pooling conn = DB._connect_with_pooling(self, keywords) File "/usr/lib/python2.7/site-packages/web/db.py", line 563, in _connect_with_pooling return self._pooleddb.connection() File "/usr/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/PooledDB.py", line 331, in connection con = self.steady_connection() File "/usr/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/PooledDB.py", line 279, in steady_connection *self._args, **self._kwargs) File "/usr/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/SteadyDB.py", line 134, in connect failures, ping, closeable, *args, **kwargs) File "/usr/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/SteadyDB.py", line 186, in __init__ self._store(self._create()) File "/usr/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/SteadyDB.py", line 190, in _create con = self._creator(*self._args, **self._kwargs) File "/usr/lib64/python2.7/site-packages/psycopg2/__init__.py", line 179, in connect connection_factory=connection_factory, async=async)OperationalError: 致命錯誤: 已保留的串連位置為執行非複製請求的超級使用者預留
查到資料庫使用的活動串連數為90左右,而pg的預設最大串連數MAX_CONNECTION=100,懷疑是資料庫連接數過多導致報錯。
事實果然如此,老資料庫的MAX_CONNECTION=200,並沒有使用預設的100。
解決辦法:修改設定檔(postgresql.conf)中的預設最大串連數MAX_CONNECTION=200,重啟資料庫即可。
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
postgresql 致命錯誤: 已保留的串連位置為執行非複製請求的超級使用者預留