Unify Controller installation in Jail

Mattia3rd

Explorer
Joined
May 13, 2014
Messages
57
Hi,

I used to install the TrueNAS Plugin of Unify Controller which worked well.
Today I decided to upgrade my installation and went through the Update process of the plugin, but at the end it failed. After that I wrongly delete the plugin and it erased all my data.

Now I have created a new Jail and I installed the Unify plugin, which installed the unifi7 version 7.4.162.
I followed this simple guide

Unfortunately, in the end, if I connect to my jail I get this error:
1698409926707.png


Now:
I checked some log files and I see this
root@UnifyController:~ # less /usr/local/share/java/unifi/logs/mongod.log

{"t":{"$date":"2023-10-27T12:18:59.822+02:00"},"s":"I", "c":"CONTROL", "id":20712, "ctx":"LogicalSessionCacheReap","msg":"Sessions collection is not set up; waiti

ng until next sessions reap interval","attr":{"error":"NamespaceNotFound: config.system.sessions does not exist"}}
and this
root@UnifyController:~ # less /usr/local/share/java/unifi/logs/server.log

[2023-10-27 12:29:14,160] <launcher> INFO db - Starting database service initialization...

[2023-10-27 12:29:14,160] <launcher> INFO db - waiting for db connection...

[2023-10-27 12:29:14,160] <db-server> INFO db - Checking if database needs to be shut down

[2023-10-27 12:29:15,236] <db-server> INFO db - Database was not running

[2023-10-27 12:29:15,236] <db-server> INFO db - Database configuration, dir=/usr/local/share/java/unifi/data/db, port=27117

[2023-10-27 12:29:15,254] <db-server> INFO db - Starting database process...

[2023-10-27 12:29:15,267] <db-server> INFO db - {"t":{"$date":"2023-10-27T10:29:15.266Z"},"s":"I", "c":"STORAGE", "id":22293, "ctx":"main","msg":"Engine custom option","attr":{"option":"cache_size=256M"}}

[2023-10-27 12:29:15,727] <launcher> INFO db - Connecting to mongodb://localhost:27117

[2023-10-27 12:29:15,730] <launcher> INFO db - db connection established...

[2023-10-27 12:29:16,316] <launcher> INFO db - db connected (v4.4.24@mongodb://localhost:27117)

[2023-10-27 12:29:16,317] <launcher> INFO db - setting mongodb features compatibility version to 3.6

[2023-10-27 12:29:16,319] <launcher> WARN db - Unable to ensure mongodb features version to 3.6: Command failed with error 2 (BadValue): 'Invalid command argument. Expected '4.4' or '4.2', found 3.6 in: { setFeatureCompatibilityVersion: "3.6", $db: "admin", lsid: { id: UUID("c560f0fd-f13f-43fb-bed7-42bec7521a9d") } }. See https://docs.mongodb.com/master/release-notes/4.4-compatibility/#feature-compatibility.' on server localhost:27117. The full response is {"ok": 0.0, "errmsg": "Invalid command argument. Expected '4.4' or '4.2', found 3.6 in: { setFeatureCompatibilityVersion: \"3.6\", $db: \"admin\", lsid: { id: UUID(\"c560f0fd-f13f-43fb-bed7-42bec7521a9d\") } }. See https://docs.mongodb.com/master/release-notes/4.4-compatibility/#feature-compatibility.", "code": 2, "codeName": "BadValue"}
But I don't know what to do right now.
I'm stuck and I'm without Unify controller anymore..

Could you help me please?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Did you copy your database files to the new jail? Unifi 7.4 uses MongoDB 4.4 while your database files seem to be from 3.6. That's why the database server refuses to start.

If the non-working plugin jail is still available and MongoDB is still running there, you could use the mongodump tool and then mongorestore on the target jail.

If you only have the binary database files and no running environment - and no config backup created from the Unifi UI, either - then things get a bit more difficult.

Reason being that one must upgrade MongoDB for each single version in turn. 3.6 --> 3.8 --> 4.0 --> 4.2 --> 4.4.

You can use your preferred desktop - I assume Windows or Mac - and download MongoDB 3.6 binaries from here: https://www.mongodb.com/try/download/community

Copy in your DB files, start the Mongo DB server, check in the logfiles that everything is OK.

Shutdown the 3.6 server, download 3.8 server from the same URL as above, install, move the data, start, check in logfiles that the database was converted to 3.8 OK and everything is fine.

Shutdown 3.8 server, download and install 4.0 ...

4.2 ...

4.4 ...

Then move the data back to your new production jail.

Or start with a clean installation and reconfigure from scratch if that is - while annoying - less work than the path laid out above.

HTH,
Patrick
 
Last edited:

probain

Patron
Joined
Feb 25, 2023
Messages
211
Did you copy your database files to the new jail? Unifi 7.4 uses MongoDB 4.4 while your database files seem to be from 3.6. That's why the database server refuses to start.
From what I remember when I did this a couple of years ago. Unifi Network Application uses MongoDB 3.6 as the highest. But the repo you're pulling from is finding only newer versions. And throws a fit.
The only way I could solve it was do a lot of wiggling with the repos on my then (too) new Ubuntu Server version.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776

probain

Patron
Joined
Feb 25, 2023
Messages
211

Mattia3rd

Explorer
Joined
May 13, 2014
Messages
57
Did you copy your database files to the new jail? Unifi 7.4 uses MongoDB 4.4 while your database files seem to be from 3.6. That's why the database server refuses to start.

If the non-working plugin jail is still available and MongoDB is still running there, you could use the mongodump tool and then mongorestore on the target jail.

If you only have the binary database files and no running environment - and no config backup created from the Unifi UI, either - then things get a bit more difficult.

Reason being that one must upgrade MongoDB for each single version in turn. 3.6 --> 3.8 --> 4.0 --> 4.2 --> 4.4.

You can use your preferred desktop - I assume Windows or Mac - and download MongoDB 3.6 binaries from here: https://www.mongodb.com/try/download/community

Copy in your DB files, start the Mongo DB server, check in the logfiles that everything is OK.

Shutdown the 3.6 server, download 3.8 server from the same URL as above, install, move the data, start, check in logfiles that the database was converted to 3.8 OK and everything is fine.

Shutdown 3.8 server, download and install 4.0 ...

4.2 ...

4.4 ...

Then move the data back to your new production jail.

Or start with a clean installation and reconfigure from scratch if that is - while annoying - less work than the path laid out above.

HTH,
Patrick
Thank you Patrick for great details

I didn't copy any file because I lost my previous installation dataset. I just have a backup created from the UI the past month, may be I can use this at the end of the installation to restore my configs...

The strange thing is:
I did a fresh new install of Unify into a new plain Jail and it seems mongodb 3.6 is installed by default!
This doesn't match your indication of using Mongodb 4.2, so this seems to be an issue of the "pkg install" of Unify Controller..

So by my undestanding I have to download every release of mongo and upgrade manually the database.
The only other option is to understand why with the "pkg install unify" command installed the mongodb 3.6 by default..

So, have you the commands to update mongodb and could you tell me which version should I download to do the upgrade? May be source (tgz) ?
1698433711566.png
 

probain

Patron
Joined
Feb 25, 2023
Messages
211
Are you sure that you don't have automatic daily backups inside the unifi system folders? If you copy those folders, and the backup-files most importantly.
If you do. Then you can quite easilly just re-install a fresh Unifi with. And then at the bottom of the first screen, you can choose to restore from backup. And then just point it to your latest backup.

Obviously, snapshot and/or backup your data before working on any testing measures.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
Thank you Patrick for great details

I didn't copy any file because I lost my previous installation dataset. I just have a backup created from the UI the past month, may be I can use this at the end of the installation to restore my configs...

The strange thing is:
I did a fresh new install of Unify into a new plain Jail and it seems mongodb 3.6 is installed by default!
This doesn't match your indication of using Mongodb 4.2, so this seems to be an issue of the "pkg install" of Unify Controller..

So by my undestanding I have to download every release of mongo and upgrade manually the database.
The only other option is to understand why with the "pkg install unify" command installed the mongodb 3.6 by default..

So, have you the commands to update mongodb and could you tell me which version should I download to do the upgrade? May be source (tgz) ?
View attachment 71750
Before you go through all that hassle, try changing your repo to "latest" and see if that corrects your dependency issue.

https://www.truenas.com/community/t...-lets-encrypt-iocage.60375/page-2#post-477773
 

Mattia3rd

Explorer
Joined
May 13, 2014
Messages
57
Before you go through all that hassle, try changing your repo to "latest" and see if that corrects your dependency issue.

https://www.truenas.com/community/t...-lets-encrypt-iocage.60375/page-2#post-477773
Hi Jailer

I did it but nothing changed..

root@UnifyController:/usr/local/etc/pkg # cat FreeBSD.conf

FireeBSD: {

url: "pkg+http://pkg.FreeBSD.com/${ABI}/latest"

}

root@UnifyController:/usr/local/etc/pkg # pkg upgrade

Updating FreeBSD repository catalogue...

[UnifyController] Fetching packagesite.pkg: 100% 7 MiB 6.9MB/s 00:01

Processing entries: 0%

Newer FreeBSD version for package zziplib:

To ignore this error set IGNORE_OSVERSION=yes

- package: 1302001

- running kernel: 1301000

Ignore the mismatch and continue? [y/N]: y

Processing entries: 100%

FreeBSD repository update completed. 33951 packages processed.

All repositories are up to date.

Checking for upgrades (1 candidates): 100%

Processing candidates (1 candidates): 100%

Checking integrity... done (0 conflicting)

Your packages are up to date.

I just checked the db version, it's aleady uptodate :\
root@UnifyController:/usr/local/etc/pkg # mongod --version

db version v4.4.24

Build Info: {

"version": "4.4.24",

"gitVersion": "0b86b9b7b42ad9970c5f818c527dd86c0634243a",

"openSSLVersion": "OpenSSL 1.1.1o-freebsd 3 May 2022",

"modules": [],

"allocator": "system",

"environment": {

"distarch": "x86_64",

"target_arch": "x86_64"

}

}

What I can do now?
 
Last edited:

Mattia3rd

Explorer
Joined
May 13, 2014
Messages
57
Ok I think I figured out my problem!
I was connecting to the 8843 port instead of 8443..
What the hell, sorry guys :| :eek:
Now I see the setup wizard and I'll try to restore my config

I'll let you know
 
Top