Copy or move Hudson instance to another server. Add slave node to new instance

By neokrates, written on April 23, 2010

article

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 1,339 views
Rate it
Ad
Poll
  • Which features are most important for perfect CI tool?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext

We have this build Hudson CI, which is always busy. It has old hardware, located in the sub-network with lots of limitations and thus is always a bottleneck during our builds. We need to relocate this instance 1:1 to the brand new server and add some Hudson slave nodes. Here is how it was done.

Basically, the Hudson state is under Hudson home directory in:
1 – plugins directory
2 – jobs directory
3 – config.xml file

Names
$old_hudson – old Hudson instance
$new_hudson – new Hudson instance

1

Make sure you have enough disk space

On the $new_hudson, you will need at least more than:

(executed on $old_hudson)

du -hs /hudson/home

2

Set Hudson home if needed

If you follow some directory layout you will probably want your Hudson to have different home then default.

Add to your .bashrc:

export HUDSON_HOME = /your/hudson/home

3

Check tools compatibility

Hudson uses a bunch of tools to build things…
Validate that tools which are on the $new_hudson will be in exactly the same version as on $old_hudson.
Like:

svn --version
java -version
mvn --version
ant 
....

The location of tools may be different. Although hudson will always try to download the tools automatically, it doesn’t always work and if it works it is still likely a bad idea. Infrastructure of your firm must remain consistent, maybe you even use patched tools like we do.

4

Copy Hudson state

Stop both instances.

On $old_hudson, do something like:

cd /your/old/hudson/home/

zip -r old_hudson_jobs.zip jobs
zip -r old_hudson_plugins.zip plugins

scp old_hudson_jobs.zip $NEW_HOST_USER@$NEW_HUDSON:/your/hudson/home/.
scp old_hudson_plugins.zip $NEW_HOST_USER@$NEW_HUDSON:/your/hudson/home/.
scp config.xml $NEW_HOST_USER@$NEW_HUDSON:/your/hudson/home/config.xml

 
On $new_hudson, do something like:

cd /your/hudson/home/
unzip sputnik_hudson_*
chown tomcat:tomcat -R /your/hudson/home/

IMPORTANT: here, I consider that the Hudson will be executed in tomcat, under tomcat user. The user Hudson is running under, MUST be the owner of /your/hudson/home/

Start both instances

The state is transferred. Debug if needed.

5

Add slave

I will use “launch via SSH on unix machines” connection mode. To enable this mode, I create the public-private key pair for the $new_hudson

5.1

Add public private authentication, make it usable by Hudson

Suppose, your user is called NEW_HOST_USER. Key will be generated on the $new_hudson under this user.

1. ssh-keygen -t dsa

to create the keypair (set NO password):

~/.ssh/id_dsa_hudson_master
~/.ssh/id_dsa_hudson_master.pub

2. Copy both files under /home/tomcat/.ssh


3. This location must be owned by the user which runs Hudson:

chown tomcat:tomcat /home/tomcat/.ssh -R

 
4. Add /home/tomcat/.ssh/id_dsa_hudson_master.pub to the authorized_keys on the slave node

Copy id_dsa_hudson_master.pub to $new_hudson_slave and add it to $NEW_HOST_USER_HOME/./ssh/authorized_keys file

5. Test

By now root user from $new_hudson must be able to login into $old_hudson without password

ssh -i ~/.ssh/id_dsa_hudson_master $NEW_HOST_USER@$new_hudson

5.2

Tune slave environment

In our case Hudson connects to the slave using SSH non-interactive mode.

Hudson must see Java. Make sure of it. On the slave side I add to .bashrc:

export JAVA_HOME=/your/java/home
export PATH=$PATH:$JAVA_HOME/bin

 

IMPORTANT.
1. Hudson slave must be disconnected and reconnected to see new environment settings from .bashrc or .profile. Here you can learn how to change hudson slave environment Configure (set) hudson slave environment.
2. Here is a complete howto for SSH environment variables: Setting ssh remote host environment variables (Interactive shell)

5.3

Add slave node to Hudson

In Hudson http://$new_hudson/hudson, go “manage hudson->manage-nodes->new node” and create new dumb node called “$new_hudson_slave

Set it up as following:

  1. Of executors = 1
  2. Remote FS root = ~/.hudsonslave

 
Launch on unix machines via ssh:

  1. Host = ciagent38-5
  2. Username = root
  3. Private Key File = /home/tomcat/.ssh/id_dsa_hudson_master

 
Slave should work now, debug if needed.

Have fun! 8-)

Be Sociable, Share!
 


TAGS

SOCIAL
Be Sociable, Share!


Leave a Reply