Replies: 3 comments 3 replies
-
Your procedure is very close, but to move from < 2.11 to 3.+ you need to do a stepwise upgrade at 2.11.x first and second the upgrade.sh script has all the commands for upgrading the db schema between versions, they are not automatically run on service start (like they might be with Liquibase IIRC), so you need to run upgrade.sh between step 5d and 5e in your example and you need to make one stop at 2.11.12 to upgrade then upgrade to 3.4.x as 3.4 doesn't include db migrations from before 2.11.
Getting a working 2.11 install can be a little finicky as time passes because pip install is going to grab the latest version of various dependent python libraries, which may have made incompatible API changes/version upgrades between the time 2.11 was current and now. You may need to search in the history of this mailing list to find others who have done the same migration recently to find the couple of libraries you need to pin versions for.
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: mmj10000 ***@***.***>
Sent: Tuesday, January 10, 2023 9:57 AM
To: netbox-community/netbox ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [netbox-community/netbox] Database Migration issue (Discussion #11456)
Production Server:
Netbox Version
v2.4.3
Python Version
3.6.9
PostgresSQL Version
12.13 (Recently upgraded from 10.8. Received the same error below before I upgraded the database)
New Server:
NetBox version
v3.4.2
Python version
3.8.10
PostgreSQL version
12.12
Steps to Reproduce
1. pg_dump --username netbox --password --host localhost netbox > netbox.sql
2. Copied netbox.sql to the new server
3. Set the secret_key in the configuration.py to the same value you used on the original server (Tried the migration with and without this step)
4. sudo systemctl stop netbox netbox-rq
5. Droped DB on new server, create a new blank, grant rights and import the dump:
a. sudo -u postgres psql -c 'drop database netbox'
b. sudo -u postgres psql -c 'create database netbox'
c. sudo -u postgres psql -c 'grant all privileges on database netbox to netbox
d. sudo -u postgres psql netbox < netbox.sql
e. sudo systemctl start netbox netbox-rq
After the migration I can login to the web interface however I receive the following error message:
Server Error
A database programming error was detected while processing this request. Common causes include the following:
Database migrations missing - When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You can run migrations manually by executing python3 manage.py migrate from the command line.
Unsupported PostgreSQL version - Ensure that PostgreSQL version 10 or later is in use. You can check this by connecting to the database using NetBox's credentials and issuing a query for SELECT VERSION().
The complete exception is provided below:
<class 'django.db.utils.ProgrammingError'>
relation "users_userconfig" does not exist
LINE 1: ...config"."user_id", "users_userconfig"."data" FROM "users_use...
^
Python version: 3.8.10
NetBox version: 3.4.2
Ran the following command python3 manage.py migrate from /opt/netbox/netbox
Expected Behavior
python3 manage.py migrate returning no errors.
Observed Behavior
Traceback (most recent call last):
File "manage.py", line 8, in
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
Any help would be greatly appreciated!!!!
—
Reply to this email directly, view it on GitHub<#11456>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM6PTMDRNSN52DWJC53WRWBFRANCNFSM6AAAAAATW7JROM>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
I'd say that leaving the existing host in place and doing the install/upgrade/upgrade dance on the new server has the least amount of risk, but either way can work, esp. since you have a backup of the database you can always reset and start over if something goes wrong.
You can have your netbox 3.4 and 2.11 installs in different directories on the new server each with their own virtualenv of library dependencies, so there are fewer ways for them to interact and interfere with one another, eg. /opt/netbox-2.11.12 and /opt/netbox-3.4.2 with a symlink from /opt/netbox to whichever one you want to be the default.
or you can just install /opt/netbox-2.11.12 off to the side, restore the db from 2.4.x onto your new server, run the upgrade.sh in /opt/netbox-2.11.12, then run the upgrade.sh in /opt/netbox/ (which is 3.4) and you should be up-to-date
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: mmj10000 ***@***.***>
Sent: Tuesday, January 10, 2023 11:27 AM
To: netbox-community/netbox ***@***.***>
Cc: Mark Tinberg ***@***.***>; Comment ***@***.***>
Subject: Re: [netbox-community/netbox] Database Migration issue (Discussion #11456)
Mark,
Thanks for the info. If I can upgrade the current server to 2.11.X, will I be able to migrate the database? Or do I have to build a whole new server with 2.11.X, migrate the database, then upgrade?
Thanks in advance!!!
Cheers
Mario
—
Reply to this email directly, view it on GitHub<#11456 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UMYGRDQK27STVUYWKNLWRWLYTANCNFSM6AAAAAATW7JROM>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
A slight tangent but I wonder if the next time a devops person is doing a stepwise upgrade if it would make sense for them to patch netbox 2.11.12, pin dependencies, update docs, etc. to make it installable and runnable at least enough for upgrade.sh on whatever interpreter current 3.x is supported on, and would the maintainers be willing pull and tag that as a 2.11.13+ release? It doesn't make sense to maintain 2.x for prod use, but if some of the people who've had to manage upgrades from old 2.x releases either put together a special upgrade doc or fixed up 2.11 so that upgrades worked out of the box, would that kind of change be accepted? I suppose if someone maintained a one-off fork for this purpose that could be linked to that would also work.
This doesn't scratch an itch that I have, I'm already on 3.x, but it'd be nice to be able to just link a FAQ or fork when people pop up who need to do stepwise upgrades, and have them more easily help themselves, instead of needing to walk each admin through it and having to re-discover all the workarounds and special cases when they inherit and old unmaintained Netbox instance. It just needs one of the people managing this upgrade path to leave some breadcrumbs for the next person who comes along, I don't know how big the long tail of unmaintained Netbox 2.x instances is, but they do keep popping up.
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: Brian Candler ***@***.***>
Sent: Wednesday, January 11, 2023 3:00 AM
To: netbox-community/netbox ***@***.***>
Cc: Mark Tinberg ***@***.***>; Comment ***@***.***>
Subject: Re: [netbox-community/netbox] Database Migration issue (Discussion #11456)
Or if you're using git, then
git fetch
git checkout v2.11.12
will give you the point-in-time checkout of 2.11.12 - at which point you run ./upgrade.sh. Then once that has completed successfully, you can do
git checkout master
to switch to the latest release (and run ./upgrade.sh again)
However, there's another issue to consider which is your python version. Netbox <=2.11 only supports python 3.6-3.8, but Netbox >=3.0 only supports python 3.8-3.10. If your system has python 3.8 then you're fine. If it doesn't, then you're also going to have to upgrade python as part of the upgrade process.
If you're running under (say) Ubuntu 18.04, where the python3 binary is python 3.6, but there is a package available of python3.8 (which appears as /usr/bin/python3.8), then you can tell ./upgrade.sh to use this particular version:
PYTHON=python3.8 ./upgrade.sh
Finally: if you want to do go straight to a new system with python 3.10, then it's possible to run Netbox 2.11.12 temporarily under this - at least enough to get the migrations to complete - but you have to modify some broken code in settings.py which does a wrong check on the python version (it thinks python '3' ,'10' is less than '3', '6')
—
Reply to this email directly, view it on GitHub<#11456 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM5J27DMM3PRSFXIKZLWRZZCRANCNFSM6AAAAAATW7JROM>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Production Server:
Netbox Version
v2.4.3
Python Version
3.6.9
PostgresSQL Version
12.13 (Recently upgraded from 10.8. Received the same error below before I upgraded the database)
New Server:
NetBox version
v3.4.2
Python version
3.8.10
PostgreSQL version
12.12
Steps to Reproduce
a. sudo -u postgres psql -c 'drop database netbox'
b. sudo -u postgres psql -c 'create database netbox'
c. sudo -u postgres psql -c 'grant all privileges on database netbox to netbox
d. sudo -u postgres psql netbox < netbox.sql
e. sudo systemctl start netbox netbox-rq
After the migration I can login to the web interface however I receive the following error message:
Server Error
A database programming error was detected while processing this request. Common causes include the following:
Database migrations missing - When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You can run migrations manually by executing python3 manage.py migrate from the command line.
Unsupported PostgreSQL version - Ensure that PostgreSQL version 10 or later is in use. You can check this by connecting to the database using NetBox's credentials and issuing a query for SELECT VERSION().
The complete exception is provided below:
<class 'django.db.utils.ProgrammingError'>
relation "users_userconfig" does not exist
LINE 1: ...config"."user_id", "users_userconfig"."data" FROM "users_use...
^
Python version: 3.8.10
NetBox version: 3.4.2
Ran the following command python3 manage.py migrate from /opt/netbox/netbox
Expected Behavior
python3 manage.py migrate returning no errors.
Observed Behavior
Traceback (most recent call last):
File "manage.py", line 8, in
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
Any help would be greatly appreciated!!!!
Beta Was this translation helpful? Give feedback.
All reactions