Added Setup guide for Unifi using external mongodb database
This commit is contained in:
80
Linux/Docs/Setup-Unifi-With-External-Database.md
Normal file
80
Linux/Docs/Setup-Unifi-With-External-Database.md
Normal file
@@ -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: [ "<UnifiIP>" ] } ]});
|
||||
```
|
||||
|
||||
## 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 <Mailer@localhost>
|
||||
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:<UnifiDBPassword>@27017:PORT/Unifi
|
||||
statdb.mongo.uri=mongodb://Unifi:<UnifiDBPassword>@27017:PORT/Unifi_stat
|
||||
Unifi.db.name=Unifi
|
||||
```
|
||||
Reference in New Issue
Block a user