Copy or move Hudson instance to another server. Add slave node to new instanceBy neokrates, written on April 23, 2010
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
$old_hudson – old Hudson instance
$new_hudson – new Hudson instance
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
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
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.
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.
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.
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
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):
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
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
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
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)
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:
- Of executors = 1
- Remote FS root = ~/.hudsonslave
Launch on unix machines via ssh:
- Host = ciagent38-5
- Username = root
- Private Key File = /home/tomcat/.ssh/id_dsa_hudson_master
Slave should work now, debug if needed.
LEARN MORE (amazon bookstore)
INCOMING SEARCH TERMS