Below is my experience of migrating the nexus 1.9.2 to 2.7.0, this is my personal instance of nexus and if you are planning to do this on 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 Sonatype site to check https://support.sonatype.com/entries/21701998-nexus-upgrade-notes the recommended upgrade path and it seemed daunting and no where it mentioned you can upgrade straight from 1.9.x to 2.7.x. Anyway 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 loger 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 needs to be actioned in the main property file
nexus.properties
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 new nexus insists on running as non-root user here is how to go about stopping the annoying message.
Below steps 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 data directory if its separate
$ sudo chown -R nexus:nexus /usr/local/nexus $ sudo chown -R nexus:nexus /var/data/nexus
-
Change following keys in
/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 following lines
$ sudo ln -s /usr/local/nexus/bin/nexus /etc/init.d/nexus
-
Execute update-rc.d to add the service to required runlevels
$ updated-rc.d nexus defaults
-
To start the service you can use the following command
$ sudo service nexus start
Above steps allow you to run the service as nexus user and allows the service automatically start on next reboot.
I had issues with getting the service started correctly as I had created the user with false shell. Since the nexus startup script executes “su” to switch the user it needs a shell access, so make sure you have default shell provided to the user.