如果你的Cloud Key或是Debian UniFi Controller 因為某些原因導致 MongoDB 資料庫損毀而無法正常啟動
試試底下官方的修復命令能讓你的UniFi Controller再活過來.
- Repairing a Database on Cloud Key
- Repairing a Database on Debian-based Linux
- Repairing a Database on Windows
How to Repair a Database on Cloud Key (官方硬體控制器)
1. Download the mongo pruning script. As written, the script will only keep entries from the past 7 days. It will not remove entries that are required for UniFi administration. Do so by running the following command:
2. Stop the UniFi service
service unifi stop
3. The UniFi service will shut down the mongo process. Make sure that the UniFi service has been completely shut down. Repair the database to compact the data entries and free unused disk space field that is included in the query criteria.
mongod --dbpath /usr/lib/unifi/data/db --smallfiles --logpath /usr/lib/unifi/logs/server.log --repair
|
NOTE: Steps 4-7 are optional if you need to prune back the database to conserve disk space.
|
4. Restart mongo with this command:
mongod --dbpath /usr/lib/unifi/data/db --smallfiles --logpath /usr/lib/unifi/logs/server.log --journal --fork
|
NOTE: Journaling may not be have been enabled in your mongo database. If so, then remove the –journal option in the above command.
|
5. Execute the script to prune the stat collections that are causing the problem:
mongo < /tmp/CK_repair.js
6. Shut down the mongo server with this command:
mongod --dbpath /usr/lib/unifi/data/db --smallfiles --logpath /usr/lib/unifi/logs/server.log --shutdown
|
NOTE: The last command in the CK_repair.js script is “db.repairDatabase()”. It may result in an error if the stats collections have already grown too large to be repaired while the mongo server is running. If you see such an error running the script then you will need to repair the database from the command line once again by running the command in step 3.
|
7. Finally, restart the UniFi service:
service unifi start
How to Repair a Database on Debian-based Linux (Debian 控制器)
1. Stop the UniFi service
service unifi stop
2. Repair the database with this command:
mongod --dbpath /usr/lib/unifi/data/db --smallfiles --logpath /usr/lib/unifi/logs/server.log --repair
3. Finally, restart the UniFi service:
service unifi start
