ALPR-Database icon indicating copy to clipboard operation
ALPR-Database copied to clipboard

unRAID Deployment

Open olympia opened this issue 1 year ago • 44 comments

Hi Charlie,

I installed and set this up on unRAID (without docker compose) a couple of days ago. I don't have lots of data yet, but looking absolutely amazing. Thank you very much for creating this!

Would it be possible to have a selector at the top plates to chose from last 24 hours, last week, last month, last year or maybe custom dates?

...and I am wondering about vehicle description on the live feed: is this configurable somewhere, or is this a dead leftover from some initial plan? :)

Many thanks again!

olympia avatar Nov 23 '24 22:11 olympia

olympia: I have tried to set up on unRAID using docker compose and its not working correctly. Was wondering if you could give me a quick overview on setting up without compose. thanks

prsmith777 avatar Nov 25 '24 05:11 prsmith777

@prsmith777 the docker-compose.yml file provides the overview, but what you need to do:

  1. Create a postgres13 directory in your unRAID appdata, then create a data and a schema subdir in that
  2. Copy the schema.sql referenced in the readme somewhere to schema subdir
  3. Install postgres13 from unRAID Community Applications where you set the database storage path to the data subdir you created and create a new path where the container path is /docker-entrypoint-initdb.d/ and the host path is the schema subdir you created and have the schema.sql in it. Also set password to any. user and db to postgres.
  4. create an alpr_dashboard directory in your unRAID appdata, then create am auth subdir in that
  5. add a new container manually from docker tab by referencing algertc/alpr-dashboard:latest
  6. add the following paths to alpr-dashboard: docker:
    • container path: /app/auth | host path to your auth subdir
    • container path: /app/config | host path to the alpr_dashboard directory
  7. add the following variables:
    • key: NODE_ENV | value: production
    • key: ADMIN_PASSWORD | value: to your password
    • key: DB_PASSWORD | value: to your password
  8. add a tcp port: 3000
  9. that's it, you should be able to access the alpr database dasboard now
  10. set database settings accordingly in the settings,

olympia avatar Nov 25 '24 07:11 olympia

@olympia

Awesome thank you. Got it going

EDIT:

Not connecting to database.... getting this error:

Database connection test failed: Error: getaddrinfo ENOTFOUND db at (/app/node_modules/pg-pool/index.js:45:11) at async l (/app/.next/server/chunks/79.js:1:979) at async A (/app/.next/server/chunks/79.js:288:45) at async d (/app/.next/server/app/api/plate-reads/route.js:1:1926) at async te.do (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:17826) at async te.handle (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:22492) at async doRender (/app/node_modules/next/dist/server/base-server.js:1455:42) at async responseGenerator (/app/node_modules/next/dist/server/base-server.js:1814:28) at async NextNodeServer.renderToResponseWithComponentsImpl (/app/node_modules/next/dist/server/base-server.js:1824:28) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'db'

prsmith777 avatar Nov 25 '24 17:11 prsmith777

Would it be possible to have a selector at the top plates to chose from last 24 hours, last week, last month, last year or maybe custom dates?

...and I am wondering about vehicle description on the live feed: is this configurable somewhere, or is this a dead leftover from some initial plan? :)

I'll add some more configuration ability to the dashboard for things like date filtering.

The vehicle description is a bit of a leftover because the AI doesn't have a great way to do this currently, but I do plan to allow the user to manually enter these details. For now, you could just put it in the notes if you needed to. The other addition that I am prioritizing is the ability to correct plate recognitions in the live feed page. This will allow you to prevent your plate database from having 5 different variations of the same plate as a result of OCR misreads.

Thank you for sharing your Unraid instructions. I was going to make a docs directory to link to other more specific guides like this. If you would like credit, please make a pull request and put it in /docs/unraid.md.

I can also do it myself if you prefer.

algertc avatar Nov 25 '24 21:11 algertc

@olympia

Awesome thank you. Got it going

EDIT:

Not connecting to database.... getting this error:

Database connection test failed: Error: getaddrinfo ENOTFOUND db at (/app/node_modules/pg-pool/index.js:45:11) at async l (/app/.next/server/chunks/79.js:1:979) at async A (/app/.next/server/chunks/79.js:288:45) at async d (/app/.next/server/app/api/plate-reads/route.js:1:1926) at async te.do (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:17826) at async te.handle (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:22492) at async doRender (/app/node_modules/next/dist/server/base-server.js:1455:42) at async responseGenerator (/app/node_modules/next/dist/server/base-server.js:1814:28) at async NextNodeServer.renderToResponseWithComponentsImpl (/app/node_modules/next/dist/server/base-server.js:1824:28) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'db'

There are a few things you can check here.

  • Since these containers are now separate and not in a stack together, you may need to set the db host as the IP address of your unraid machine + the port you exposed. The fact that it is saying hostname db not found leads me to believe that this is the cause. Using db only works if the containers are in the same docker network. So if your unraid machine is 1.2.3.4 and you exposed port 4000, you would want to set the database address as 1.2.3.4:4000 instead of db:4000.

  • Make sure the postgres container is running and hasn't exited. If unraid is already running a database on port 5432, you will need to use a different port.

  • In the app, go to the settings page and ensure that the database configuration is correct.

algertc avatar Nov 25 '24 21:11 algertc

I'll add some more configuration ability to the dashboard for things like date filtering. The vehicle description is a bit of a leftover because the AI doesn't have a great way to do this currently, but I do plan to allow the user to manually enter these details. For now, you could just put it in the notes if you needed to. The other addition that I am prioritizing is the ability to correct plate recognitions in the live feed page. This will allow you to prevent your plate database from having 5 different variations of the same plate as a result of OCR misreads.

Super, many thanks for all these!

Thank you for sharing your Unraid instructions. I was going to make a docs directory to link to other more specific guides like this. If you would like credit, please make a pull request and put it in /docs/unraid.md.

OK, but let's wait first if the instructions can get the first one go :)

@prsmith777 Did you follow the order of the instructions for postgres installation? If you started postgres docker without configuring the schema path first, then the alpr database hasn't got generated.

Also, how did you set the network for the dockers? Did you configure "bridge' networks or you set specific IP addresses for your dockers?

olympia avatar Nov 25 '24 21:11 olympia

Thanks for both your help.

I added DBHOST: 192.168.0.250:3000 and still no luck

I did the configuration in order as stated.

I set network to bridge

There are no conflicts using port 5432

Here is postgres log:

2024-11-25 14:26:40.025 MST [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-11-25 14:26:40.025 MST [1] LOG: listening on IPv6 address "::", port 5432 2024-11-25 14:26:40.032 MST [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-11-25 14:26:40.040 MST [27] LOG: database system was shut down at 2024-11-25 14:26:36 MST 2024-11-25 14:26:40.048 MST [1] LOG: database system is ready to accept connections The files belonging to this database system will be owned by user "postgres". This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default time zone ... America/Denver creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok

Success. You can now start the database server using:

pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2024-11-25 14:07:36.418 MST [49] LOG: starting PostgreSQL 13.18 (Debian 13.18-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-11-25 14:07:36.422 MST [49] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-11-25 14:07:36.434 MST [50] LOG: database system was shut down at 2024-11-25 14:07:34 MST 2024-11-25 14:07:36.442 MST [49] LOG: database system is ready to accept connections done server started

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/

2024-11-25 14:07:36.544 MST [49] LOG: received fast shutdown request waiting for server to shut down....2024-11-25 14:07:36.547 MST [49] LOG: aborting any active transactions 2024-11-25 14:07:36.549 MST [49] LOG: background worker "logical replication launcher" (PID 56) exited with exit code 1 2024-11-25 14:07:36.549 MST [51] LOG: shutting down 2024-11-25 14:07:36.572 MST [49] LOG: database system is shut down done server stopped

PostgreSQL init process complete; ready for start up.

PostgreSQL Database directory appears to contain a database; Skipping initialization

PostgreSQL Database directory appears to contain a database; Skipping initialization

prsmith777 avatar Nov 25 '24 22:11 prsmith777

It's not possible to tell from the log if the alpr database has created successfully or not.

go to postgres docker console and type:

  1. psql -d postgres -U postgres -W
  2. enter password
  3. type: \dt

What do you get there?

olympia avatar Nov 25 '24 22:11 olympia

psql -d postgres -U postgres -W

Password: psql (13.18 (Debian 13.18-1.pgdg120+1)) Type "help" for help.

postgres=# \dt Did not find any relations. postgres=#

prsmith777 avatar Nov 25 '24 22:11 prsmith777

That's not OK. ALPR database is not there.

  1. Stop postgres docker
  2. delete everything from the data subdirectory of your postgres appdata directory.
  3. start the docker again
  4. try and post the result of the previous command in the console again.

olympia avatar Nov 25 '24 22:11 olympia

followed those steps and getting same result:

postgres=# \dt Did not find any relations.

prsmith777 avatar Nov 25 '24 22:11 prsmith777

Then probably something is not OK with your docker config, particularly the reference the the schema.sql. Can you post a screenshot of the docker config?

olympia avatar Nov 25 '24 22:11 olympia

docker

prsmith777 avatar Nov 25 '24 22:11 prsmith777

3000 is not the right port. Notice that it says the database is listening on 5432. 3000 is for the app itself. You will want to set the database host to :5432 or if you exposed a different outside port for the database set it to that.

algertc avatar Nov 25 '24 22:11 algertc

docker1 Changed the port.
Does this look right?

Still not working

prsmith777 avatar Nov 25 '24 22:11 prsmith777

3000 is not the right port. Notice that it says the database is listening on 5432. 3000 is for the app itself. You will want to set the database host to :5432 or if you exposed a different outside port for the database set it to that.

Yes, that's indeed incorrect too, but his database hasn't been generated correctly. First we would need to get that resolved. This DBHOST variable is not even needed...

"Unfortunately" the docker config is correct, so I am not sure what the issue is. I guess the schema.sql file has been correctly copied to the schema subdirectory, correct?

Can you delete the content of the data subdir again, then run the docker and then post the the docker logs?

olympia avatar Nov 25 '24 22:11 olympia

Here is the log after deleting data subdir and starting docker back up:

2024-11-25 15:25:18.003 MST [1] LOG: starting PostgreSQL 13.18 (Debian 13.18-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-11-25 15:25:18.003 MST [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-11-25 15:25:18.003 MST [1] LOG: listening on IPv6 address "::", port 5432 2024-11-25 15:25:18.033 MST [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-11-25 15:25:18.054 MST [61] LOG: database system was shut down at 2024-11-25 15:25:17 MST 2024-11-25 15:25:18.068 MST [1] LOG: database system is ready to accept connections 2024-11-25 15:40:34.370 MST [1] LOG: received fast shutdown request 2024-11-25 15:40:34.372 MST [1] LOG: aborting any active transactions 2024-11-25 15:40:34.372 MST [75] FATAL: terminating connection due to administrator command 2024-11-25 15:40:34.374 MST [1] LOG: background worker "logical replication launcher" (PID 67) exited with exit code 1 2024-11-25 15:40:34.375 MST [62] LOG: shutting down 2024-11-25 15:40:34.396 MST [1] LOG: database system is shut down 2024-11-25 15:40:34.884 MST [1] LOG: starting PostgreSQL 13.18 (Debian 13.18-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-11-25 15:40:34.884 MST [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-11-25 15:40:34.884 MST [1] LOG: listening on IPv6 address "::", port 5432 2024-11-25 15:40:34.890 MST [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-11-25 15:40:34.900 MST [27] LOG: database system was shut down at 2024-11-25 15:40:34 MST 2024-11-25 15:40:34.908 MST [1] LOG: database system is ready to accept connections 2024-11-25 15:48:03.900 MST [1] LOG: received fast shutdown request 2024-11-25 15:48:03.902 MST [1] LOG: aborting any active transactions 2024-11-25 15:48:03.904 MST [1] LOG: background worker "logical replication launcher" (PID 33) exited with exit code 1 2024-11-25 15:48:03.904 MST [28] LOG: shutting down 2024-11-25 15:48:03.924 MST [1] LOG: database system is shut down initdb: warning: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. 2024-11-25 15:48:29.031 MST [1] LOG: starting PostgreSQL 13.18 (Debian 13.18-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-11-25 15:48:29.031 MST [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-11-25 15:48:29.031 MST [1] LOG: listening on IPv6 address "::", port 5432 2024-11-25 15:48:29.037 MST [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-11-25 15:48:29.047 MST [61] LOG: database system was shut down at 2024-11-25 15:48:28 MST 2024-11-25 15:48:29.054 MST [1] LOG: database system is ready to accept connections

2024-11-25 15:25:17.851 MST [48] LOG: received fast shutdown request waiting for server to shut down....2024-11-25 15:25:17.863 MST [48] LOG: aborting any active transactions 2024-11-25 15:25:17.864 MST [48] LOG: background worker "logical replication launcher" (PID 55) exited with exit code 1 2024-11-25 15:25:17.865 MST [50] LOG: shutting down 2024-11-25 15:25:17.899 MST [48] LOG: database system is shut down done server stopped

PostgreSQL init process complete; ready for start up.

PostgreSQL Database directory appears to contain a database; Skipping initialization

The files belonging to this database system will be owned by user "postgres". This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default time zone ... America/Denver creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok

Success. You can now start the database server using:

pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2024-11-25 15:48:28.786 MST [48] LOG: starting PostgreSQL 13.18 (Debian 13.18-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-11-25 15:48:28.791 MST [48] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-11-25 15:48:28.801 MST [49] LOG: database system was shut down at 2024-11-25 15:48:26 MST 2024-11-25 15:48:28.809 MST [48] LOG: database system is ready to accept connections done server started

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/

waiting for server to shut down...2024-11-25 15:48:28.909 MST [48] LOG: received fast shutdown request .2024-11-25 15:48:28.912 MST [48] LOG: aborting any active transactions 2024-11-25 15:48:28.913 MST [48] LOG: background worker "logical replication launcher" (PID 55) exited with exit code 1 2024-11-25 15:48:28.914 MST [50] LOG: shutting down 2024-11-25 15:48:28.944 MST [48] LOG: database system is shut down done server stopped

PostgreSQL init process complete; ready for start up.

prsmith777 avatar Nov 25 '24 22:11 prsmith777

This line in the log doesn't seem right:

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/

prsmith777 avatar Nov 25 '24 23:11 prsmith777

The log file indicates the presence of an existing database with the message:
"PostgreSQL Database directory appears to contain a database; Skipping initialization."

I don't see how this can be if there is nothing in the data directory.

olympia avatar Nov 25 '24 23:11 olympia

perhaps the issue because I first tried setting things up using docker compose manager. maybe that original database is still in there confusing things.

Is there a way to manually delete all databases and try again?

prsmith777 avatar Nov 25 '24 23:11 prsmith777

By deleting the data dir, everything should be purged. shrug

olympia avatar Nov 25 '24 23:11 olympia

directory global and gb_wal aren't deleting. I thought they were

Trying krusader to delete

prsmith777 avatar Nov 25 '24 23:11 prsmith777

still same result

\dt no relations

prsmith777 avatar Nov 25 '24 23:11 prsmith777

how you delete the data dir? Using SMB or terminal?

olympia avatar Nov 25 '24 23:11 olympia

Deleting using Unraid file manager

prsmith777 avatar Nov 25 '24 23:11 prsmith777

This line in the log says:

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/

It is ignoring this entrypoint so maybe it cant get to the schema.sql file.

prsmith777 avatar Nov 25 '24 23:11 prsmith777

It is ignoring this entrypoint so maybe it cant get to the schema.sql file.

The log suggests that it is ignoring initialization, because it finds and existing database.

I am running out of ideas...

Can you delete the data folder once again (make sure the docker is stopped first). Then open a terminal and type: ls -la /mnt/user/appdata/postgres13

share what you see there.

and then ls -la /mnt/user/appdata/postgres13/schema

share what you see there.

olympia avatar Nov 25 '24 23:11 olympia

root@Storinator1:# ls -la /mnt/user/appdata/postgres13 total 12 drwxrwxrwx 1 nobody users 4 Nov 25 16:15 ./ drwxrwxrwx 1 nobody users 20 Nov 25 14:08 ../ drwx------ 1 999 users 2 Nov 25 16:35 data/ drwxr-xr-x 1 root root 2 Nov 25 16:15 schema/ root@Storinator1:# ls -la /mnt/user/appdata/postgres13/schema total 2 drwxr-xr-x 1 root root 2 Nov 25 16:15 ./ drwxrwxrwx 1 nobody users 4 Nov 25 16:15 ../ root@Storinator1:#

prsmith777 avatar Nov 25 '24 23:11 prsmith777

so where is the schema.sql? :)

olympia avatar Nov 25 '24 23:11 olympia

well it was there. I re added it

prsmith777 avatar Nov 25 '24 23:11 prsmith777