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
$ 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
$ 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
$ 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
$ sudo cat <<'EOF'>>/usr/lib/unifi/bin/mongod
#!/bin/bash
cleaned_args=$(echo $* | sed -e 's/--nohttpinterface//')
exec /usr/lib/unifi/bin/mongod.bin ${cleaned_args}
EOF
$ sudo chmod +x /usr/lib/unifi/bin/mongod
$ sudo cat <<'EOF'>>/usr/lib/unifi/bin/mongod
#!/bin/bash
cleaned_args=$(echo $* | sed -e 's/--nohttpinterface//')
exec /usr/lib/unifi/bin/mongod.bin ${cleaned_args}
EOF
$ sudo chmod +x /usr/lib/unifi/bin/mongod
5. After the install unifi will break all the packages on the system because they specify a maximum version on mongo. In order to fix that - edit the state of dpkg in /var/lib/dpkg/status: advance to "Package: unifi" and remove the maximum on Mongo-db
6. References
6. References
https://stackoverflow.com/questions/48318487/error-while-upgrading-mongodb-from-3-2-to-3-6?rq=1
https://docs.mongodb.com/tutorials/install-mongodb-on-ubuntu
https://community.ubnt.com/t5/UniFi-Wireless/Install-Unifi-on-Ubuntu-Desktop-18-04-LTS-Complete
https://community.ubnt.com/t5/UniFi-Routing-Switching/MongoDB-3-6/m-p/2533407/highlight/true#M113183
https://docs.mongodb.com/tutorials/install-mongodb-on-ubuntu
https://community.ubnt.com/t5/UniFi-Wireless/Install-Unifi-on-Ubuntu-Desktop-18-04-LTS-Complete
https://community.ubnt.com/t5/UniFi-Routing-Switching/MongoDB-3-6/m-p/2533407/highlight/true#M113183
No comments:
Post a Comment