From e7edb9ccce96c330bacf05ce9dcf5ff0ff0be148 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Thu, 8 Feb 2024 00:55:04 +0100 Subject: [PATCH] Added Setup guide for Unifi using external mongodb database --- .../Setup-Unifi-With-External-Database.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Linux/Docs/Setup-Unifi-With-External-Database.md diff --git a/Linux/Docs/Setup-Unifi-With-External-Database.md b/Linux/Docs/Setup-Unifi-With-External-Database.md new file mode 100644 index 0000000..e672347 --- /dev/null +++ b/Linux/Docs/Setup-Unifi-With-External-Database.md @@ -0,0 +1,80 @@ +## Setup MongoDB server +Install MongoDB the normal way +[Official documentation](https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-debian/). + + +**Create admin user for MongoDB** +Enter MongoDB shell using `mongo` +and use the following command +``` +use admin +db.createUser( + { + user: "root", + pwd: passwordPrompt(), + roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"], + authenticationRestrictions: [ { clientSource: [ "127.0.0.1" ] } ] + } +) +exit +``` +**Stop MongoDB server** +``` +systemctl stop mongod +``` + +**Update mongod config** +update the following items in `/etc/mongod.conf` +``` +net: + bindIp: 0.0.0.0 + +security: + authorization: enabled + clusterIpSourceWhitelist: + - 127.0.0.1 + - ::1 +``` + +**Start MongoDB server** +``` +systemctl start mongod +``` + +**Add MongoDB user for Unifi DB** + +Enter MongoDB shell using `mongo -u root` +and use the following command, make sure to update the ip before running the commmand +``` +db.getSiblingDB("Unifi").createUser({user: "Unifi", pwd: passwordPrompt(), roles: [{role: "dbOwner", db: "Unifi"},{role: "dbOwner", db: "Unifi_stat"}],authenticationRestrictions: [ { clientSource: [ "" ] } ]}); +``` + +## Setup Unifi server + +**Install dummy mongodb-server** +the dummy package is created as `.deb` with equivs, +and can be installed using dpkg + +Content of `mongodb-org-server.equivs` + +``` +Package: mongodb-org-server +Version: 4.4.28 +Maintainer: PKG Builder +Architecture: all +Description: Dummy MongoDB database server + A dummy package so that Unifi will install without MongoDB locally installed + +``` + +**Setup Unifi server** +Install Unfi the normal way +[Official documentation](https://help.ui.com/hc/en-us/articles/220066768-Updating-and-Installing-Self-Hosted-UniFi-Network-Servers-Linux). + +Add the following to `/usr/lib/Unifi/data/system.properties` +``` +db.mongo.local=false +db.mongo.uri=mongodb://Unifi:@27017:PORT/Unifi +statdb.mongo.uri=mongodb://Unifi:@27017:PORT/Unifi_stat +Unifi.db.name=Unifi +``` \ No newline at end of file