当前位置: 首页 > 工具软件 > WiredTiger > 使用案例 >

MongoDB:WiredTiger error (13) 问题解决.

鲜于子琪
2023-12-01

今天在调试MongoDB的时候,mongo无法正常打开

huangzhengtaodeMacBook-Pro:~ huangzhengtao$ mongo
MongoDB shell version v4.0.8
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2019-05-08T20:21:17.923+0800 E QUERY    [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:343:13
@(connect):2:6
exception: connect failed

这个时候 我进入mongod里面查看了下:

huangzhengtaodeMacBook-Pro:~ huangzhengtao$ mongod
2019-05-08T20:21:20.036+0800 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-05-08T20:21:20.046+0800 I CONTROL  [initandlisten] MongoDB starting : pid=722 port=27017 dbpath=/data/db 64-bit host=huangzhengtaodeMacBook-Pro.local
2019-05-08T20:21:20.046+0800 I CONTROL  [initandlisten] db version v4.0.8
2019-05-08T20:21:20.046+0800 I CONTROL  [initandlisten] git version: 9b00696ed75f65e1ebc8d635593bed79b290cfbb
2019-05-08T20:21:20.046+0800 I CONTROL  [initandlisten] allocator: system
2019-05-08T20:21:20.046+0800 I CONTROL  [initandlisten] modules: none
2019-05-08T20:21:20.046+0800 I CONTROL  [initandlisten] build environment:
2019-05-08T20:21:20.046+0800 I CONTROL  [initandlisten]     distarch: x86_64
2019-05-08T20:21:20.046+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2019-05-08T20:21:20.046+0800 I CONTROL  [initandlisten] options: {}
2019-05-08T20:21:20.046+0800 F STORAGE  [initandlisten] An incomplete repair has been detected! This is likely because a repair operation unexpectedly failed before completing. MongoDB will not start up again without --repair.
2019-05-08T20:21:20.046+0800 F -        [initandlisten] Fatal Assertion 50922 at src/mongo/db/storage/storage_engine_init.cpp 86
2019-05-08T20:21:20.046+0800 F -        [initandlisten] 

***aborting after fassert() failure

然后我根据他的提示执行mongod --repair

2019-05-08T19:51:54.546+0800 I CONTROL  [main] ***** SERVER RESTARTED *****
2019-05-08T19:51:54.556+0800 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-05-08T19:51:54.622+0800 I CONTROL  [initandlisten] MongoDB starting : pid=7358 port=27017 dbpath=/data/db 64-bit host=huangzhengtaodeMacBook-Pro.local
2019-05-08T19:51:54.622+0800 I CONTROL  [initandlisten] db version v4.0.8
2019-05-08T19:51:54.622+0800 I CONTROL  [initandlisten] git version: 9b00696ed75f65e1ebc8d635593bed79b290cfbb
2019-05-08T19:51:54.622+0800 I CONTROL  [initandlisten] allocator: system
2019-05-08T19:51:54.622+0800 I CONTROL  [initandlisten] modules: none
2019-05-08T19:51:54.622+0800 I CONTROL  [initandlisten] build environment:
2019-05-08T19:51:54.622+0800 I CONTROL  [initandlisten]     distarch: x86_64
2019-05-08T19:51:54.622+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2019-05-08T19:51:54.622+0800 I CONTROL  [initandlisten] options: { config: "/usr/local/mongodb/etc/mongodb.conf", net: { bindIp: "0.0.0.0", port: 27017 }, processManagement: { fork: false }, repair: true, security: { authorization: "enabled" }, storage: { dbPath: "/data/db" }, systemLog: { destination: "file", logAppend: true, path: "/Usr/local/mongodb/mongod.log" } }
2019-05-08T19:51:54.623+0800 I STORAGE  [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-05-08T19:51:54.624+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2019-05-08T19:51:55.095+0800 E STORAGE  [initandlisten] WiredTiger error (13) [1557316315:95478][7358:0x10dfe25c0], wiredtiger_open: __posix_open_file, 715: /data/db/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1557316315:95478][7358:0x10dfe25c0], wiredtiger_open: __posix_open_file, 715: /data/db/WiredTiger.turtle: handle-open: open: Permission denied
2019-05-08T19:51:55.095+0800 E STORAGE  [initandlisten] WiredTiger error (13) [1557316315:95720][7358:0x10dfe25c0], wiredtiger_open: __posix_open_file, 715: /data/db/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1557316315:95720][7358:0x10dfe25c0], wiredtiger_open: __posix_open_file, 715: /data/db/WiredTiger.turtle: handle-open: open: Permission denied
2019-05-08T19:51:55.095+0800 E STORAGE  [initandlisten] WiredTiger error (13) [1557316315:95868][7358:0x10dfe25c0], wiredtiger_open: __posix_open_file, 715: /data/db/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1557316315:95868][7358:0x10dfe25c0], wiredtiger_open: __posix_open_file, 715: /data/db/WiredTiger.turtle: handle-open: open: Permission denied
2019-05-08T19:51:55.095+0800 W STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.
2019-05-08T19:51:55.095+0800 F STORAGE  [initandlisten] Reason: 13: Permission denied
2019-05-08T19:51:55.095+0800 W STORAGE  [initandlisten] Attempting to salvage WiredTiger metadata
2019-05-08T19:51:55.108+0800 E STORAGE  [initandlisten] WiredTiger error (13) [1557316315:108672][7358:0x10dfe25c0], file:WiredTiger.wt, WT_SESSION.salvage: __posix_open_file, 715: /data/db/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1557316315:108672][7358:0x10dfe25c0], file:WiredTiger.wt, WT_SESSION.salvage: __posix_open_file, 715: /data/db/WiredTiger.turtle: handle-open: open: Permission denied
2019-05-08T19:51:55.127+0800 F STORAGE  [initandlisten] Failed to salvage WiredTiger metadata: 13: Permission denied
2019-05-08T19:51:55.127+0800 F -        [initandlisten] Fatal Assertion 50947 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 719
2019-05-08T19:51:55.127+0800 F -        [initandlisten] 

***aborting after fassert() failure

根据提示 我百度了WiredTiger error (13)的错误,只查到了WiredTiger error (0)删除mongod.lock的解决办法.
并没有什么用。
2019-05-08T19:51:55.127+0800 F STORAGE [initandlisten] Failed to salvage WiredTiger metadata: 13: Permission denied
根据这一句话,我想到了给WiredTiger 提升下权限 看是否有用.
果然,提升权限之后问题就得到了解决。

2019-05-09T14:10:55.523+0800 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-05-09T14:10:55.533+0800 I CONTROL  [initandlisten] MongoDB starting : pid=568 port=27017 dbpath=/data/db 64-bit host=huangzhengtaodeMacBook-Pro.local
2019-05-09T14:10:55.534+0800 I CONTROL  [initandlisten] db version v4.0.8
2019-05-09T14:10:55.534+0800 I CONTROL  [initandlisten] git version: 9b00696ed75f65e1ebc8d635593bed79b290cfbb
2019-05-09T14:10:55.534+0800 I CONTROL  [initandlisten] allocator: system
2019-05-09T14:10:55.534+0800 I CONTROL  [initandlisten] modules: none
2019-05-09T14:10:55.534+0800 I CONTROL  [initandlisten] build environment:
2019-05-09T14:10:55.534+0800 I CONTROL  [initandlisten]     distarch: x86_64
2019-05-09T14:10:55.534+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2019-05-09T14:10:55.534+0800 I CONTROL  [initandlisten] options: {}
2019-05-09T14:10:55.534+0800 I STORAGE  [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-05-09T14:10:55.534+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2019-05-09T14:10:56.103+0800 I STORAGE  [initandlisten] WiredTiger message [1557382256:103256][568:0x112ca45c0], txn-recover: Main recovery loop: starting at 8/7040 to 9/256
2019-05-09T14:10:56.167+0800 I STORAGE  [initandlisten] WiredTiger message [1557382256:167697][568:0x112ca45c0], txn-recover: Recovering log 8 through 9
2019-05-09T14:10:56.208+0800 I STORAGE  [initandlisten] WiredTiger message [1557382256:208563][568:0x112ca45c0], txn-recover: Recovering log 9 through 9
2019-05-09T14:10:56.241+0800 I STORAGE  [initandlisten] WiredTiger message [1557382256:241314][568:0x112ca45c0], txn-recover: Set global recovery timestamp: 0
2019-05-09T14:10:56.296+0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-05-09T14:10:56.310+0800 I CONTROL  [initandlisten] 
2019-05-09T14:10:56.310+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-05-09T14:10:56.310+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-05-09T14:10:56.310+0800 I CONTROL  [initandlisten] 
2019-05-09T14:10:56.310+0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2019-05-09T14:10:56.310+0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2019-05-09T14:10:56.310+0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2019-05-09T14:10:56.310+0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2019-05-09T14:10:56.310+0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2019-05-09T14:10:56.311+0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2019-05-09T14:10:56.311+0800 I CONTROL  [initandlisten] 
2019-05-09T14:10:56.311+0800 I CONTROL  [initandlisten] 
2019-05-09T14:10:56.311+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2019-05-09T14:10:56.329+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2019-05-09T14:10:56.331+0800 I NETWORK  [initandlisten] waiting for connections on port 27017

总结:
解决WiredTiger error (13)问题,给/data/db/WiredTiger 提升下权限就可以解决.
使用:sudo chmod -R 777 /data/db/WiredTiger 提升权限.
同时,在使用过程中也可以sudo chmod -R 777 /data/db 给db提升下权限.

 类似资料: