1. 程式人生 > >MongoDB 3.2配置檔案directoryPerDB引數,無法重啟

MongoDB 3.2配置檔案directoryPerDB引數,無法重啟

MongoDB3.2 使用過一段時間之後,想要配置下directoryPerDB引數,於是在mongod.conf配置檔案storage下加入:

  directoryPerDB: true

服務重啟時報錯資訊如下:

2016-07-21T02:47:14.007-0700 I CONTROL  [main] ***** SERVER RESTARTED *****
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten] MongoDB starting : pid=2740 port=27017 dbpath=/home/martin/mongodb/db 64-bit host=localhost.localdomain
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten] db version v3.2.8
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten] allocator: tcmalloc
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten] modules: enterprise 
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten] build environment:
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten]     distmod: rhel62
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten]     distarch: x86_64
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten]     target_arch: x86_64
2016-07-21T02:47:14.020-0700 I CONTROL  [initandlisten] options: { config: "/home/martin/mongodb/bin/mongod.conf", net: { bindIp: "0.0.0.0", port: 27017 }, processManagement: { fork: true, pidFilePath: "/home/martin/mongodb/mongod.pid" }, security: { authorization: "enabled" }, storage: { dbPath: "/home/martin/mongodb/db", directoryPerDB: true, journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/home/martin/mongodb/logs/mongod.log" } }
2016-07-21T02:47:14.041-0700 I -        [initandlisten] Detected data files in /home/martin/mongodb/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-07-21T02:47:14.042-0700 I STORAGE  [initandlisten] exception in initAndListen: 72 Requested option conflicts with current storage engine option for directoryPerDB; you requested true but the current server storage is already set to false and cannot be changed, terminating
2016-07-21T02:47:14.042-0700 I CONTROL  [initandlisten] dbexit:  rc: 100

根據錯誤日誌提示:

[initandlisten] exception in initAndListen: 72 Requested option conflicts with current storage engine option for directoryPerDB; you requested true but the current server storage is already set to false and cannot be changed, terminating

初始化失敗,當前directoryPerDB選項儲存引擎有72個選項衝突,你要求true,但是當前儲存服務已經設定為false,並且無法改變,程式終止。

解決辦法:
1、刪除dbPath資料夾下所有檔案,重啟MongoDB服務;
2、匯出MongoDB 儲存檔案,刪除dbPath資料夾下所有檔案,重啟MongoDB服務,匯入匯出的資料;