几个月来一切都工作正常,然后我升级了我的 docker 版本,然后有些东西崩溃了。
有很多问题,如访问权限、docker 机器等,但后来我意识到我必须通过
mongod --repair
修复数据库,这是必要的也是最后的希望。
我想要实现的是恢复大约 1.6GB 的数据库,其中一个集合有 2600 万行外汇数据历史价格,这个集合对我来说最重要。
我已经尝试过
docker-compose up --build
:
mongo --repair --dbpath /data/db --storageEngine wiredTiger
以及/data/db
,这不是目录权限或访问问题,因为我修复了它并收到了另一个错误。但是这些都不能正常工作,所以我必须问你。
我的
docker-compose.yml
文件:
version: "3"
services:
mongo:
image: mongo:4.0
restart: always
volumes:
- ./database/db3:/data/db
- ./docker-entrypoint.sh:/entrypoint.sh
ports:
- 27022:27017
command: mongod --repair --dbpath /data/db --storageEngine wiredTiger
db_filler:
build: .
container_name: db_filler
image: db_filler
stdin_open: true
tty: true
depends_on:
- mongo
links:
- mongo
volumes:
- ./:/usr/src/app
我的
docker-entrypoint.sh
,我设置了对用户mongodb
的访问权限,以便能够写入一些数据
#!/usr/bin/env bash
#!/bin/bash
set -e
if [ "${1:0:1}" = '-' ]; then
set -- mongod "$@"
fi
if [ "$1" = 'mongod' ]; then
chown -R mongodb /data/db
numa='numactl --interleave=all'
if $numa true &> /dev/null; then
set -- $numa "$@"
fi
exec gosu mongodb "$@"
fi
exec "$@"
我的
Dockerfile
(我粘贴它是因为 docker-compose 使用了这个 Dockerfile,但我认为它不会改变任何东西):
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./requirements.txt
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
COPY ./backtest .
CMD ["/bin/bash"]
您如何认为:这是否是由于尝试处理(复制、索引、移动、修复等 - 我不知道如何--修复过程进行)集合而导致的,该集合太重且行数太多,因此有些发生超时或资源不足? 第一条日志表明此操作使用了一些资源
在我的数据库上处理
repair
时,我得到以下回溯:
mongo_1 | 2019-01-27T13:55:15.187+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
mongo_1 | 2019-01-27T13:55:15.212+0000 W ASIO [initandlisten] No TransportLayer configured during NetworkInterface startup
mongo_1 | 2019-01-27T13:55:15.236+0000 F - [initandlisten] Invalid access at address: 0
mongo_1 | 2019-01-27T13:55:15.259+0000 F - [initandlisten] Got signal: 11 (Segmentation fault).
mongo_1 | 0x55a2ac8b82e1 0x55a2ac8b74f9 0x55a2ac8b7b66 0x7ff9a0cf5390 0x55a2ac0fbfbc 0x55a2ac0eae31 0x55a2ac0ef5f7 0x55a2ac0ef781 0x55a2ab2c42c7 0x55a2ac1f5528 0x55a2abe0da1b 0x55a2ab74abdb 0x55a2ab3cb78f 0x55a2ab3d1b8a 0x55a2aae64437 0x55a2aaf4c97b 0x55a2aaee25a9 0x7ff9a093a830 0x55a2aaf4aae9
mongo_1 | ----- BEGIN BACKTRACE -----
mongo_1 | {"backtrace":[{"b":"55A2AA4CD000","o":"23EB2E1","s":"_ZN5mongo15printStackTraceERSo"},{"b":"55A2AA4CD000","o":"23EA4F9"},{"b":"55A2AA4CD000","o":"23EAB66"},{"b":"7FF9A0CE4000","o":"11390"},{"b":"55A2AA4CD000","o":"1C2EFBC","s":"_ZN5mongo8executor18NetworkInterfaceTL8shutdownEv"},{"b":"55A2AA4CD000","o":"1C1DE31","s":"_ZN5mongo8executor22ThreadPoolTaskExecutor5_joinESt11unique_lockISt5mutexE"},{"b":"55A2AA4CD000","o":"1C225F7","s":"_ZN5mongo8executor22ThreadPoolTaskExecutorD1Ev"},{"b":"55A2AA4CD000","o":"1C22781","s":"_ZN5mongo8executor22ThreadPoolTaskExecutorD0Ev"},{"b":"55A2AA4CD000","o":"DF72C7"},{"b":"55A2AA4CD000","o":"1D28528","s":"_ZN5mongo23CollectionShardingState3getEPNS_16OperationContextERKNS_15NamespaceStringE"},{"b":"55A2AA4CD000","o":"1940A1B","s":"_ZN5mongo31AutoGetCollectionForReadCommandC1EPNS_16OperationContextERKNS_21NamespaceStringOrUUIDENS_17AutoGetCollection8ViewModeENS_6Date_tE"},{"b":"55A2AA4CD000","o":"127DBDB","s":"_ZN5mongo7Helpers12getSingletonEPNS_16OperationContextEPKcRNS_7BSONObjE"},{"b":"55A2AA4CD000","o":"EFE78F"},{"b":"55A2AA4CD000","o":"F04B8A","s":"_ZN5mongo30repairDatabasesAndCheckVersionEPNS_16OperationContextE"},{"b":"55A2AA4CD000","o":"997437"},{"b":"55A2AA4CD000","o":"A7F97B","s":"_ZN5mongo11mongoDbMainEiPPcS1_"},{"b":"55A2AA4CD000","o":"A155A9","s":"main"},{"b":"7FF9A091A000","o":"20830","s":"__libc_start_main"},{"b":"55A2AA4CD000","o":"A7DAE9","s":"_start"}],"processInfo":{ "mongodbVersion" : "4.0.5", "gitVersion" : "3739429dd92b92d1b0ab120911a23d50bf03c412", "compiledModules" : [], "uname" : { "sysname" : "Linux", "release" : "4.9.125-linuxkit", "version" : "#1 SMP Fri Sep 7 08:20:28 UTC 2018", "machine" : "x86_64" }, "somap" : [ { "b" : "55A2AA4CD000", "elfType" : 3, "buildId" : "D2BD849936E6F1CDEAA6678F57E07D725B522378" }, { "b" : "7FFC11975000", "elfType" : 3, "buildId" : "AA3586244F239D468C9D9083DA99D53FE1408277" }, { "b" : "7FF9A20F5000", "path" : "/usr/lib/x86_64-linux-gnu/libcurl.so.4", "elfType" : 3, "buildId" : "E2D1DB1857AE8F07908959381751796E89FF56BB" }, { "b" : "7FF9A1EDA000", "path" : "/lib/x86_64-linux-gnu/libresolv.so.2", "elfType" : 3, "buildId" : "6EF73266978476EF9F2FD2CF31E57F4597CB74F8" }, { "b" : "7FF9A1A95000", "path" : "/lib/x86_64-linux-gnu/libcrypto.so.1.0.0", "elfType" : 3, "buildId" : "8942CA58A3B910E883CC31E04A23DBD09729B4B0" }, { "b" : "7FF9A182C000", "path" : "/lib/x86_64-linux-gnu/libssl.so.1.0.0", "elfType" : 3, "buildId" : "473092A9AF373FB0CAB555F9A003BC67F47756B6" }, { "b" : "7FF9A1628000", "path" : "/lib/x86_64-linux-gnu/libdl.so.2", "elfType" : 3, "buildId" : "8CC8D0D119B142D839800BFF71FB71E73AEA7BD4" }, { "b" : "7FF9A1420000", "path" : "/lib/x86_64-linux-gnu/librt.so.1", "elfType" : 3, "buildId" : "89C34D7A182387D76D5CDA1F7718F5D58824DFB3" }, { "b" : "7FF9A1117000", "path" : "/lib/x86_64-linux-gnu/libm.so.6", "elfType" : 3, "buildId" : "DFB85DE42DAFFD09640C8FE377D572DE3E168920" }, { "b" : "7FF9A0F01000", "path" : "/lib/x86_64-linux-gnu/libgcc_s.so.1", "elfType" : 3, "buildId" : "68220AE2C65D65C1B6AAA12FA6765A6EC2F5F434" }, { "b" : "7FF9A0CE4000", "path" : "/lib/x86_64-linux-gnu/libpthread.so.0", "elfType" : 3, "buildId" : "CE17E023542265FC11D9BC8F534BB4F070493D30" }, { "b" : "7FF9A091A000", "path" : "/lib/x86_64-linux-gnu/libc.so.6", "elfType" : 3, "buildId" : "B5381A457906D279073822A5CEB24C4BFEF94DDB" }, { "b" : "7FF9A2364000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3, "buildId" : "5D7B6259552275A3C17BD4C3FD05F5A6BF40CAA5" }, { "b" : "7FF9A06E7000", "path" : "/usr/lib/x86_64-linux-gnu/libidn.so.11", "elfType" : 3, "buildId" : "E09D3783AD1D0BBCD3204FA01E4EF6D756E18F57" }, { "b" : "7FF9A04CB000", "path" : "/usr/lib/x86_64-linux-gnu/librtmp.so.1", "elfType" : 3, "buildId" : "8D1CC1204D6B6D33BD1D2C5A2A0516A2234322CF" }, { "b" : "7FF9A0281000", "path" : "/usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2", "elfType" : 3, "buildId" : "41971A4A3CCDC54A447F41DF4BD96C948C546E0E" }, { "b" : "7FF9A0072000", "path" : "/usr/lib/x86_64-linux-gnu/liblber-2.4.so.2", "elfType" : 3, "buildId" : "5B146086EC173C299BA45F0C92E068D68CC7AD37" }, { "b" : "7FF99FE21000", "path" : "/usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2", "elfType" : 3, "buildId" : "D02A94DB90567C2C45F40C8565809A041FD22A55" }, { "b" : "7FF99FC07000", "path" : "/lib/x86_64-linux-gnu/libz.so.1", "elfType" : 3, "buildId" : "8D9BD4CE26E45EF16075C67D5F5EEAFD8B562832" }, { "b" : "7FF99F8D7000", "path" : "/usr/lib/x86_64-linux-gnu/libgnutls.so.30", "elfType" : 3, "buildId" : "3CE893F6D1382C2C7648DCCB06E71B1C7E0861CC" }, { "b" : "7FF99F6A4000", "path" : "/usr/lib/x86_64-linux-gnu/libhogweed.so.4", "elfType" : 3, "buildId" : "B11678F560199547DCF726384EA39153EE0DFABF" }, { "b" : "7FF99F46E000", "path" : "/usr/lib/x86_64-linux-gnu/libnettle.so.6", "elfType" : 3, "buildId" : "D6B36C5A463EE0FA84FDD6D5FD3F7726EDB90D54" }, { "b" : "7FF99F1EE000", "path" : "/usr/lib/x86_64-linux-gnu/libgmp.so.10", "elfType" : 3, "buildId" : "7B3533D5998D20EE1A1BE3F87789B69041E7F620" }, { "b" : "7FF99EF1C000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5.so.3", "elfType" : 3, "buildId" : "0EEF7058B0737B68BDF89E5DC604D0AC389C8BB1" }, { "b" : "7FF99ECED000", "path" : "/usr/lib/x86_64-linux-gnu/libk5crypto.so.3", "elfType" : 3, "buildId" : "FFBA483A43D9EF73925AC116811890C037523DA1" }, { "b" : "7FF99EAE9000", "path" : "/lib/x86_64-linux-gnu/libcom_err.so.2", "elfType" : 3, "buildId" : "1E16CB57F699E215A2A8D4EFEF90883BC749B12D" }, { "b" : "7FF99E8DE000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5support.so.0", "elfType" : 3, "buildId" : "B789D8D4B4FC333405AB34387D9237F954060EA4" }, { "b" : "7FF99E6C3000", "path" : "/usr/lib/x86_64-linux-gnu/libsasl2.so.2", "elfType" : 3, "buildId" : "87783DF8A1058CD150F8886CB36340384093C18F" }, { "b" : "7FF99E482000", "path" : "/usr/lib/x86_64-linux-gnu/libgssapi.so.3", "elfType" : 3, "buildId" : "1FE877BE52A424D0636AFD4D35BB330E41D6E0F3" }, { "b" : "7FF99E21E000", "path" : "/usr/lib/x86_64-linux-gnu/libp11-kit.so.0", "elfType" : 3, "buildId" : "A0E2D03FF5CF65937F4425D4EFD4D655243809EB" }, { "b" : "7FF99E00B000", "path" : "/usr/lib/x86_64-linux-gnu/libtasn1.so.6", "elfType" : 3, "buildId" : "E07E186694852D8F69459C6AB28A53F8DA3CE3B6" }, { "b" : "7FF99DE07000", "path" : "/lib/x86_64-linux-gnu/libkeyutils.so.1", "elfType" : 3, "buildId" : "3364D4BF2113C4E8D17EF533867ECC99A53413D6" }, { "b" : "7FF99DBFE000", "path" : "/usr/lib/x86_64-linux-gnu/libheimntlm.so.0", "elfType" : 3, "buildId" : "73A8EADBC85860662B24850E71D4AFBE22C33359" }, { "b" : "7FF99D974000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5.so.26", "elfType" : 3, "buildId" : "59E742306A4EA2872E061ECCE92F35FADDA75357" }, { "b" : "7FF99D6D2000", "path" : "/usr/lib/x86_64-linux-gnu/libasn1.so.8", "elfType" : 3, "buildId" : "E5C159E415406AE79D21056D752BA949C408B5B1" }, { "b" : "7FF99D49F000", "path" : "/usr/lib/x86_64-linux-gnu/libhcrypto.so.4", "elfType" : 3, "buildId" : "7D15576E1F096614D360784E4A01A1F5FAF908C9" }, { "b" : "7FF99D289000", "path" : "/usr/lib/x86_64-linux-gnu/libroken.so.18", "elfType" : 3, "buildId" : "481DB33C28D88E43DA6BED65E1A7599407D4D818" }, { "b" : "7FF99D081000", "path" : "/usr/lib/x86_64-linux-gnu/libffi.so.6", "elfType" : 3, "buildId" : "9D9C958F1F4894AFEF6AECD90D1C430EA29AC34F" }, { "b" : "7FF99CE58000", "path" : "/usr/lib/x86_64-linux-gnu/libwind.so.0", "elfType" : 3, "buildId" : "57E25072866B2D30CF02EBE7AE623B84F96FA700" }, { "b" : "7FF99CC49000", "path" : "/usr/lib/x86_64-linux-gnu/libheimbase.so.1", "elfType" : 3, "buildId" : "F6F1B4E9F89B716C4A0BA5819BDFFAF4A13EFB91" }, { "b" : "7FF99C9FE000", "path" : "/usr/lib/x86_64-linux-gnu/libhx509.so.5", "elfType" : 3, "buildId" : "C60082E3BB78D0D42868D9B359B89BF66CE5A1A7" }, { "b" : "7FF99C729000", "path" : "/usr/lib/x86_64-linux-gnu/libsqlite3.so.0", "elfType" : 3, "buildId" : "D9782BA023CAEC26B15D8676E3A5D07B55E121EF" }, { "b" : "7FF99C4F1000", "path" : "/lib/x86_64-linux-gnu/libcrypt.so.1", "elfType" : 3, "buildId" : "7BDD51353D50310FFA1587E4AA01B40ABE32D582" } ] }}
mongo_1 | mongod(_ZN5mongo15printStackTraceERSo+0x41) [0x55a2ac8b82e1]
mongo_1 | mongod(+0x23EA4F9) [0x55a2ac8b74f9]
mongo_1 | mongod(+0x23EAB66) [0x55a2ac8b7b66]
mongo_1 | libpthread.so.0(+0x11390) [0x7ff9a0cf5390]
mongo_1 | mongod(_ZN5mongo8executor18NetworkInterfaceTL8shutdownEv+0xDC) [0x55a2ac0fbfbc]
mongo_1 | mongod(_ZN5mongo8executor22ThreadPoolTaskExecutor5_joinESt11unique_lockISt5mutexE+0x421) [0x55a2ac0eae31]
mongo_1 | mongod(_ZN5mongo8executor22ThreadPoolTaskExecutorD1Ev+0x67) [0x55a2ac0ef5f7]
mongo_1 | mongod(_ZN5mongo8executor22ThreadPoolTaskExecutorD0Ev+0x11) [0x55a2ac0ef781]
mongo_1 | mongod(+0xDF72C7) [0x55a2ab2c42c7]
mongo_1 | mongod(_ZN5mongo23CollectionShardingState3getEPNS_16OperationContextERKNS_15NamespaceStringE+0x98) [0x55a2ac1f5528]
mongo_1 | mongod(_ZN5mongo31AutoGetCollectionForReadCommandC1EPNS_16OperationContextERKNS_21NamespaceStringOrUUIDENS_17AutoGetCollection8ViewModeENS_6Date_tE+0xBB) [0x55a2abe0da1b]
mongo_1 | mongod(_ZN5mongo7Helpers12getSingletonEPNS_16OperationContextEPKcRNS_7BSONObjE+0x11B) [0x55a2ab74abdb]
mongo_1 | mongod(+0xEFE78F) [0x55a2ab3cb78f]
mongo_1 | mongod(_ZN5mongo30repairDatabasesAndCheckVersionEPNS_16OperationContextE+0x5EA) [0x55a2ab3d1b8a]
mongo_1 | mongod(+0x997437) [0x55a2aae64437]
mongo_1 | mongod(_ZN5mongo11mongoDbMainEiPPcS1_+0x10DB) [0x55a2aaf4c97b]
mongo_1 | mongod(main+0x9) [0x55a2aaee25a9]
mongo_1 | libc.so.6(__libc_start_main+0xF0) [0x7ff9a093a830]
mongo_1 | mongod(_start+0x29) [0x55a2aaf4aae9]
mongo_1 | ----- END BACKTRACE -----
forex_bot_mongo_1 exited with code 139
我在修复 MongoDB 4.0.5 时遇到了同样的错误。当我从启动参数中删除 --config 选项时,问题得到解决。