如何解决这个程序在运行market订阅线程向mongodb插入数据时自动死机的问题?

2024-05-20 17:10:24 发布

您现在位置:Python中文网/ 问答频道 /正文

系统是vultr vps上的centOS 7。 这个程序类似于vnpy,它订阅市场数据并将它们保存在本地数据库中,在本例中是mongodb4.0.1。 程序用python2.7编写。 当程序运行分钟时,进程将自动终止程序。 检查mongodb日志:

2018-08-17T11:01:34.509+0200 I NETWORK  [listener] connection accepted from 127.0.0.1:41042 #93 (1 connection now open)
2018-08-17T11:01:37.620+0200 I COMMAND  [ftdc] serverStatus was very slow: { after basic: 0, after asserts: 0, after backgroundFlushing: 0, after connections: 0, after dur: 0, after extra_info: 0, after freeMonitoring: 0, after globalLock: 0, after locks: 0, after logicalSessionRecordCache: 0, after network: 0, after opLatencies: 0, after opcounters: 0, after opcountersRepl: 0, after repl: 0, after security: 0, after storageEngine: 0, after tcmalloc: 225, after transactions: 260, after wiredTiger: 389, at end: 1253 }
2018-08-17T11:01:38.717+0200 I NETWORK  [conn93] received client metadata from 127.0.0.1:41042 conn93: { driver: { name: "PyMongo", version: "3.4.0" }, os: { type: "Linux", name: "CentOS Linux 7.4.1708 Core", architecture: "x86_64", version: "3.10.0-862.el7.x86_64" }, platform: "CPython 2.7.12.final.0" }
2018-08-17T11:01:39.824+0200 I COMMAND  [conn93] command admin.$cmd command: isMaster { ismaster: 1, client: { driver: { name: "PyMongo", version: "3.4.0" }, os: { type: "Linux", name: "CentOS Linux 7.4.1708 Core", architecture: "x86_64", version: "3.10.0-862.el7.x86_64" }, platform: "CPython 2.7.12.final.0" }, $db: "admin" } numYields:0 reslen:239 locks:{} protocol:op_query 1792ms
2018-08-17T11:01:43.219+0200 I COMMAND  [ftdc] serverStatus was very slow: { after basic: 95, after asserts: 353, after backgroundFlushing: 412, after connections: 474, after dur: 474, after extra_info: 474, after freeMonitoring: 474, after globalLock: 636, after locks: 701, after logicalSessionRecordCache: 814, after network: 930, after opLatencies: 1057, after opcounters: 1251, after opcountersRepl: 1314, after repl: 1409, after security: 1483, after storageEngine: 1580, after tcmalloc: 1647, after transactions: 1647, after wiredTiger: 1754, at end: 2390 }
2018-08-17T11:01:46.830+0200 I COMMAND  [conn93] command VnTrader_Log_Db.20180817 command: insert { insert: "20180817", ordered: true, $db: "VnTrader_Log_Db" } ninserted:1 keysInserted:1 numYields:0 reslen:60 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_query 3020ms
2018-08-17T11:01:48.613+0200 I NETWORK  [listener] connection accepted from 127.0.0.1:41046 #94 (2 connections now open)
2018-08-17T11:01:49.545+0200 I COMMAND  [ftdc] serverStatus was very slow: { after basic: 0, after asserts: 69, after backgroundFlushing: 69, after connections: 79, after dur: 79, after extra_info: 155, after freeMonitoring: 289, after globalLock: 351, after locks: 351, after logicalSessionRecordCache: 351, after network: 628, after opLatencies: 992, after opcounters: 1281, after opcountersRepl: 1305, after repl: 1305, after security: 1402, after storageEngine: 1619, after tcmalloc: 1851, after transactions: 1869, after wiredTiger: 2347, at end: 2914 }
2018-08-17T11:01:51.464+0200 I NETWORK  [conn94] received client metadata from 127.0.0.1:41046 conn94: { driver: { name: "PyMongo", version: "3.4.0" }, os: { type: "Linux", name: "CentOS Linux 7.4.1708 Core", architecture: "x86_64", version: "3.10.0-862.el7.x86_64" }, platform: "CPython 2.7.12.final.0" }
2018-08-17T11:01:52.505+0200 I NETWORK  [listener] connection accepted from 127.0.0.1:41048 #95 (3 connections now open)
2018-08-17T11:01:52.974+0200 I COMMAND  [conn94] command admin.$cmd command: isMaster { ismaster: 1, client: { driver: { name: "PyMongo", version: "3.4.0" }, os: { type: "Linux", name: "CentOS Linux 7.4.1708 Core", architecture: "x86_64", version: "3.10.0-862.el7.x86_64" }, platform: "CPython 2.7.12.final.0" }, $db: "admin" } numYields:0 reslen:239 locks:{} protocol:op_query 1269ms
2018-08-17T11:01:53.255+0200 I NETWORK  [conn93] end connection 127.0.0.1:41042 (2 connections now open)
2018-08-17T11:01:53.276+0200 I COMMAND  [ftdc] serverStatus was very slow: { after basic: 242, after asserts: 662, after backgroundFlushing: 692, after connections: 802, after dur: 879, after extra_info: 1038, after freeMonitoring: 1235, after globalLock: 1522, after locks: 1577, after logicalSessionRecordCache: 1577, after network: 1577, after opLatencies: 1577, after opcounters: 1577, after opcountersRepl: 1577, after repl: 1577, after security: 1577, after storageEngine: 1605, after tcmalloc: 1605, after transactions: 1605, after wiredTiger: 1605, at end: 1605 }
2018-08-17T11:01:53.286+0200 I NETWORK  [conn95] received client metadata from 127.0.0.1:41048 conn95: { driver: { name: "PyMongo", version: "3.4.0" }, os: { type: "Linux", name: "CentOS Linux 7.4.1708 Core", architecture: "x86_64", version: "3.10.0-862.el7.x86_64" }, platform: "CPython 2.7.12.final.0" }
2018-08-17T11:01:53.296+0200 I NETWORK  [conn95] end connection 127.0.0.1:41048 (1 connection now open)
2018-08-17T11:01:53.296+0200 I NETWORK  [conn94] end connection 127.0.0.1:41046 (0 connections now open)

检查系统消息日志,以下消息重复出现:

Aug 17 11:53:25 vultr python: SELinux is preventing /usr/bin/mongod from read access on the file netstat.#012#012*****  Plugin catchall (100. confidence) suggests   **************************#012#012If you believe that mongod should be allowed read access on the netstat file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c 'ftdc' --raw | audit2allow -M my-ftdc#012# semodule -i my-ftdc.pp#012
Aug 17 11:53:25 vultr setroubleshoot: SELinux is preventing /usr/bin/mongod from read access on the file snmp. For complete SELinux messages run: sealert -l 78d2809a-7188-4cc7-a885-86a556908eb0
Aug 17 11:53:25 vultr python: SELinux is preventing /usr/bin/mongod from read access on the file snmp.#012#012*****  Plugin catchall (100. confidence) suggests   **************************#012#012If you believe that mongod should be allowed read access on the snmp file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c 'ftdc' --raw | audit2allow -M my-ftdc#012# semodule -i my-ftdc.pp#012
Aug 17 11:53:26 vultr setroubleshoot: SELinux is preventing /usr/bin/mongod from read access on the file netstat. For complete SELinux messages run: sealert -l 78d2809a-7188-4cc7-a885-86a556908eb0

为什么会发生这种情况,我怎样才能避免自动杀戮?你知道吗


Tags: namefromaccessversionlinuxnetworkconnectionconnections