Sunday, June 3, 2018

Fix MongoDB incompatibility for Unifi 5.x in Ubuntu 18.04


1. Replace Ubuntu’s MongoDB 3.6 with Community Edition MongoDB 3.4
$ sudo service unifi stop
$ sudo apt uninstall mongodb-server mongo-tools mongodb-clients mongodb-server-core
$
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
$ echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
$ sudo apt update
$ sudo apt install mongodb-org
2. Enable MongoDB migration option. NOTE: since MongoDB is started by Unifi, we need to start Unifi
$ sudo service unifi start
$ sudo mongo --port 27117
> db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
> exit
$ sudo service unifi stop
3. Reinstall Ubuntu’s MongoDB 3.6
$ sudo rm /etc/apt/sources.list.d/mongodb-org-3.4.list
$ sudo apt update
$ sudo apt install mongodb-server
4. Fix Unifi’s MongoDB options incompatibility
$ sudo mv /usr/lib/unifi/bin/mongod /usr/lib/unifi/bin/mongod.bin
Create file /usr/lib/unifi/bin/mongod with following contents:
     #!/bin/bash
     cleaned_args=$(echo $* | sed -e 's/--nohttpinterface//')
     exec /usr/lib/unifi/bin/mongod.bin ${cleaned_args}
$ sudo chmod +x /usr/lib/unifi/bin/mongod
5. References


No comments: