nexus-public: Nexus migration for OrientDB to H2 for 3.70.1-02 fails as nexus-db-migrator is version 3.70.1-03
hi,
We have Nexus OSS deployed using docker using the latest 3.70 tag;
services:
nexus:
container_name: nexus
restart: unless-stopped
image: sonatype/nexus3:3.70.1
user: nexus
environment:
- TZ=Pacific/Auckland
volumes:
- /home/ubuntu/nexus-data:/nexus-data
ports:
- 8081:8081
when Nexus starts up it shows as version OSS 3.70.1-02
We create a backup job for the OrientDB Nexus>create task>type: Admin - Export databases for backup taskname: backup backup location: /nexus-data/backup run task
so now we connect to the container and attempt to migrate the database to h2;
# docker exec -it nexus /bin/bash
$ cd /opt/sonatype/nexus
$ ./bin/nexus stop
$ cd /nexus-data/db
$ cp /nexus-data/backup/* .
$ curl -s -L -O https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.70.1-03.jar
$ java -Xmx2G -Xms2G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar nexus-db-migrator-3.70.1-03.jar --migration_type=h2 --healthcheck --debug
08:40:47 [main] WARN c.s.n.d.migrator.MigratorApplication - Please ensure any Nexus Repository instance has been gracefully shut down before proceeding.
08:40:47 [main] INFO c.s.n.d.migrator.MigratorApplication - Do you want to continue [y/n]?
y
The migration files in /nexus-data/db do not match the expected requirements: The backup versions are inconsistent.
As seen above the migration fails presumable as the migration tool is expecting the Nexus version to be 3.70.1-03 and not 3.70.1-02 but there is no docker tag for version 3.70.1-03. What is the solution here? We want to track the latest OSS release, but can only do that when we are using the H2 DB by the looks of things.
thanks.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 42 (3 by maintainers)
thanks @MrEAlderson, it was exactly as you suggested. When I ran the migrator from the /nexus-data/backup directory then it worked as expected so nice work! I moved the nexus.mv.db to the /nexus-data/db afterwards then reconfigured the nexus.properties file to have the; nexus.datastore.enabled=true and Nexus came up as expected, and I was then able to migrate it to the latest nexus release. for anyone else struggling with this, my build notes are below;
We got the same problem with unsupported userToken=‘1.4’. I have discovered, this component are only supported by Pro version. We used Pro to evaluate its features and disabled it by enabling oss version feature with
nexus.loadAsOSS=trueTo mitigate this issue, we have disabled OSS feature and started Pro version - it upgraded userToken to 1.5. Than enabled OSS version again and successfully migrated from OrientDB to H2A short report from me.
The migration to h2 worked in itself.
here my steps:
remove old backups -> backup-task docker-compose stop
here you have to configure your docker-network and docker-volume
docker run -it -u nexus --network nexus_running_default -v /srv/nexus/nexus_running/data:/nexus-data/ sonatype/nexus3:3.70.2 bashas specialy 30.70.2-1 of the migrator
our system with 4gb ram was enough
after that, configure
nexus.datastore.enabled=truein the “/nexus-data/etc/nexus.properties”change the nexus version to 3.72.0
Apparently, however, this rebuild-browser/rebuild-search task was not executed at the end, I had to create it manually. Now everything is working as desired.
Successfully upgraded docker-based Nexus 3.70.0-02 to 3.71.0-06 with OpenJDK11.0.24 To fix auto-increment values I have download H2 installer from http://www.h2database.com/html/download.html and start aforementioned script
#!/bin/bashh2sql() {echo "> $@" >&2java -cp /data/nexus-data/backup/h2/bin/h2-2.3.232.jar org.h2.tools.Shell -url jdbc:h2:/data/nexus-data/db/nexus -sql "$@" }schema=$(h2sql "SCRIPT NODATA")echo "$schema" | while read line; doif [[ $line =~ ^CREATE\ CACHED\ TABLE\ \"PUBLIC\"\.\"([^\"]+)\" ]]; thentbl="${BASH_REMATCH[1]}"elif [[ $line =~ ^\"([^\"]+)\"\ .*\ GENERATED\ BY\ DEFAULT ]]; thencol="${BASH_REMATCH[1]}"h2sql "ALTER TABLE $tbl ALTER COLUMN $col RESTART WITH SELECT max($col) + 1 FROM $tbl"fidoneThan enabled option
nexus.datastore.enabled=truein nexus.properties and successfully started app@ashleyw-gh thank you, you saved my day: everything works for us with your detailed procedure.
Try to run this java command:
java --add-exports=java.base/sun.nio.ch=ALL-UNNAMED -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar nexus-db-migrator-3.70.1-03.jarThis command at least lets me run the healthcheck with Java 17 (might also work with Java 11).
If anyone is interested in a detailed guide on updating Nexus to the latest version and migrating the database to PostgreSQL or H2, I’ve written one.
Thank you a lot, @ashleyw-gh and @MrEAlderson! That saved also my day! I was also getting the “The backup versions are inconsistent” error and in my case, that was because there were multiple
.bakfiles per type (analytics, components, …) in the directory (as they are kept for a while after being created). They might have been created by different Nexus versions or the migrator might have had difficulties dealing with this.So, just to add it for anyone dealing with the same problem: You should also make sure, that only the latest backup files are present in the
backupdirectory.Ok, it works with H2… Am I right in assuming that only H2 works in OSS and not Postgres?
How disappointing
java -version
openjdk version “11.0.24” 2024-07-16 OpenJDK Runtime Environment Temurin-11.0.24+8 (build 11.0.24+8) OpenJDK 64-Bit Server VM Temurin-11.0.24+8 (build 11.0.24+8, mixed mode)
这个版本完美运行
Uh, yes, I’ve evaluated the pro version at some point in the past, too! Thanks for the hint!
Hello,
Just an update. It turned out my whole problem was because I was using the Oracle JDK. When I switched to OpenJDK, the migrator worked fine.
Regards!
Hey all, apologies for the friction. We’re getting this onto a team’s plate to investigate, we’ll report back here when we have some more information.
I faced the same issue and had to decompile the jar to determine what they meant. You are not supposed to have your backups within your db folder. Move them (all files with .bak extension) out into their own folder and it should work. The migrator might trash this same folder on its own, so you might have to clean it manually after you run it.
Oh, and if anyone else randomly sees this message and wonders what the hell they mean with the migration step
6. Perform a full backup using normal backup procedures:If you get lucky as I am, this is the step where you get greeted with
Migration to an external database requires Nexus Repository Manager Pro🙃 Fortunately migration to H2 worked just fine at this stage.