Below is my experience of migrating the Nexus 1.9.2 to 2.7.0. This is my instance of Nexus, and if you are planning to do this on a production environment, take more caution.
Nexus had moved on a lot from the last version I had installed. I was forced to look at the migration as the Nexus wasn’t starting after the target box was upgraded to Java 1.7 from 1.6. I went through this link on the Sonatype site to check https://support.sonatype.com/entries/21701998-nexus-upgrade-notes, the recommended upgrade path, and it seemed daunting, and nowhere did it mention that you can upgrade straight from 1.9. x to 2.7.x. Anyway, the good news is I managed to migrate my existing instance and here is how to do it.
-
Download the latest version of nexus
-
Untar it and move it next to your old instance
-
Stop the old instance if its still running crippled :(
-
Go to
/conf
folder and renamenexus.properties
tonexus.properties.bak
-
Copy the
conf/plexus.properties
to/conf/nexus.properties
-
I had to add and modify some of the properties on the copied
nexus.properties
file, see below for details# no change properties application-port=30000 application-host=0.0.0.0 nexus-work=/var/data/nexus # no longer required, remove them runtime=${basedir}/runtime apps=${runtime}/apps nexus-app=${runtime}/apps/nexus webapp=${runtime}/apps/nexus/webapp webapp-context-path=/nexus security-xml-file=${nexus-work}/conf/security.xml application-conf=${nexus-work}/conf runtime-tmp=${runtime}/tmp # add the new once nexus-webapp=${bundleBasedir}/nexus nexus-webapp-context-path=/nexus # modify this property runtime=${bundleBasedir}/nexus/WEB-INF # If this file is present, it will be used to configure Jetty. jetty.xml=${basedir}/conf/jetty.xml # Uncomment this to use the debug js files #index.template.file=templates/index-debug.vm
Comments on each section above need to be actioned in the main property file
nexus.properties
The above steps will get you running Nexus on the migrated data, assuming you are starting the service as a root user by setting “RUN_AS_USER” to root. As the new Nexus insists on running as a non-root user, here is how to go about stopping the annoying message.
The steps below are for Debian Linux and should work for most Debian derivatives
-
Add user for nexus named “nexus” with no shell login and home
directory to be /usr/local/nexus$ sudo useradd -s /bin/sh -d /usr/local/nexus nexus
-
Change the permissions on the Nexus installation directory and the data directory if it’s separate
$ sudo chown -R nexus:nexus /usr/local/nexus $ sudo chown -R nexus:nexus /var/data/nexus
-
Change the following keys in the
/usr/local/nexus/bin/nexus
script# nexus home NEXUS_HOME="/usr/local/nexus" # run the service as nexus RUN_AS_USER=nexus # path to directory where nexus user has write access PIDDIR="/var/data/nexus"
-
Create a file in init.d to start the service with the following lines
$ sudo ln -s /usr/local/nexus/bin/nexus /etc/init.d/nexus
-
Execute update-rc.d to add the service to the required run levels
$ updated-rc.d nexus defaults
-
To start the service, you can use the following command
$ sudo service nexus start
The above steps allow you to run the service as the nexus user and allow the service to automatically start on the next reboot.
I had issues with getting the service started correctly, as I had created the user with a false shell. Since the Nexus startup script executes “su” to switch the user, it needs shell access, so make sure you have a default shell provided to the user.