{"id":280,"date":"2010-07-24T05:09:11","date_gmt":"2010-07-24T05:09:11","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2010\/07\/24\/hudson-master-slave-setup\/"},"modified":"2017-12-29T13:17:32","modified_gmt":"2017-12-29T13:17:32","slug":"hudson-master-slave-setup","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/hudson-master-slave-setup\/","title":{"rendered":"How to Setup Configure Hudson Master Slave? &#8211; Complete Guide"},"content":{"rendered":"<div class=\"date-posts\">\n<div class=\"post-outer\">\n<div class=\"post hentry\">\n<div class=\"post-body entry-content\">\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4420 aligncenter\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2010\/07\/hudson-master-slave-setup.png\" alt=\"hudson-master-slave-setup\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2010\/07\/hudson-master-slave-setup.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2010\/07\/hudson-master-slave-setup-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/div>\n<div style=\"margin-bottom: 0in;\">The tasks can be scheduled to run on the same machine (Master), or on a different machine (Slave). A master is a installation of Hudson, that can manage one or more slaves. The role of master remains same in Master slave setup. It serves HTTP requests, and it can still build projects on it&#8217;s own.<\/div>\n<div style=\"margin-bottom: 0in;\">Slaves are computers that are setup to build projects triggered from the master. A separate program called <strong><em>slave agent<\/em><\/strong><span style=\"font-weight: normal;\"> runs on slave computer. In this article we&#8217;ll discuss about how to setup Hudson to executed distributed builds using Master slave. One computer can be configured to execute multiple slave agents.<\/span><\/div>\n<h1 class=\"western\"><span style=\"font-size: large;\">How it works<\/span><\/h1>\n<div style=\"margin-bottom: 0in;\">When the slaves are registered to a master, the master starts distributing loads to slaves. The delegation depends on the specific job. The job can be configured to either execute on the master, or it can be tied to a specific slave. On the other hand, the jobs can be configured to freely roam between slaves, wherein the job is executed using the free slave. As per the user is concerned, the setup is transparent. The results for all jobs are viewable using the Master, irrespective of the Slave that executed the job.<\/div>\n<div style=\"margin-bottom: 0in;\">The slave may be built using any Operating system. The Master slave setup is highly helpful while the user has to execute the job on different Operating system. Consider this use case: The application is expected to run on different operating system, Linux, Solaris and Windows system. To address this need, the user can install Hudson on any machine, say Linux, and add 2 slaves: Solaris and Windows. The user can add 3 different jobs, one running on Master itself and others running on slave machines.<\/div>\n<h1 class=\"western\"><span style=\"font-size: large;\">Methods to\u00a0set up\u00a0Slave agents<\/span><\/h1>\n<div style=\"margin-bottom: 0in;\">The slave can be launched from Master using any of below methods:<\/div>\n<ol>\n<li>Launch Slave agents on Unix machines via SSH.<\/li>\n<li>Launch Slave agents via JNLP.<\/li>\n<li>Launch Slave agents via execution of command on the master.<\/li>\n<li>Let Hudson control windows slave as a windows service.<\/li>\n<\/ol>\n<p>The following screenshot illustrates the list of modes under which the Hudson slave can be launched.<br \/>\n<a style=\"margin-bottom: 1em; float: right; margin-left: 1em; clear: right;\" href=\"http:\/\/3.bp.blogspot.com\/_dWL7A18AuFA\/S3p7yGMyE4I\/AAAAAAAABEo\/h6x1l2oCndM\/s1600-h\/hudson-slave-modes.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/3.bp.blogspot.com\/_dWL7A18AuFA\/S3p7yGMyE4I\/AAAAAAAABEo\/h6x1l2oCndM\/s640\/hudson-slave-modes.png\" width=\"640\" height=\"51\" border=\"0\" \/><\/a><\/p>\n<p><em><span style=\"font-size: small;\"><strong>Set up Slave agents on Unix machines via SSH<\/strong><\/span><\/em><\/p>\n<div><span style=\"font-weight: normal;\">Hudson has a built-in SSH client implementation that it can use to talk to remote sshd and start a slave agent. This is the most convenient and preferred method for Unix slaves, which normally has sshd out-of-the-box. Click <\/span><em><span style=\"font-weight: normal;\">Manage Hudson<\/span><\/em><span style=\"font-weight: normal;\">, then <\/span><em><span style=\"font-weight: normal;\">Manage Nodes<\/span><\/em><span style=\"font-weight: normal;\">, then click <\/span><em><span style=\"font-weight: normal;\">New Node<\/span><\/em><span style=\"font-weight: normal;\">. In this set up, the connection information is supplied, including SSH host name, user name and authentication credentials. The authentication is performed using password or ssh keys. If it is configured to use ssh keys, the SSH public key should be copied to <\/span><span style=\"font-family: Courier New, monospace;\"><span style=\"font-weight: normal;\">~\/.ssh\/authorized_keys<\/span><\/span><span style=\"font-weight: normal;\"> file. Hudson will do the rest of the work by itself, including copying the binary needed for a slave agent, and starting\/stopping slaves.<\/span><\/div>\n<p>&nbsp;<\/p>\n<blockquote>\n<div style=\"text-align: justify;\">Depending on the project and hardware resource availability, the user Desktop can be used as one of Slave, without affecting his day-to-day activities, thus avoiding the need for dedicated Slaves.<\/div>\n<\/blockquote>\n<h2 class=\"western\"><em><span style=\"font-size: small;\"><strong>Establish\u00a0slave agent via Java Web Start<\/strong><\/span><\/em><\/h2>\n<div style=\"font-weight: normal;\">Another way of launching slave is to start a slave agent through Java Web Start (JNLP). In this approach, the user will login to the slave node, open a browser and open the slave page using the URL pointed to the Master. It may look like the following URL:<\/div>\n<div style=\"font-weight: normal;\"><span style=\"font-family: Courier New, monospace;\">http:\/\/masterserver:port\/hudson\/jnlpJars\/slave.jar<\/span><\/div>\n<div style=\"font-weight: normal;\">The user is presented with the JNLP launch icon. If user click the icon, the Java Web Start kicks in and it launches a slave agent on this computer.<\/div>\n<div style=\"font-weight: normal;\">This mode is convenient when the master cannot initiate a connection to slaves, such as when it runs outside a firewall while the rest of the slaves are in the firewall. The disadvantage is, if the machine with a slave agent goes down, the master has no way of re-launching it on its own.<\/div>\n<h3 class=\"western\"><em><span style=\"font-size: small;\">Set up\u00a0slave agent headlessly<\/span><\/em><\/h3>\n<div style=\"margin-bottom: 0in; font-weight: normal;\">This launch mode uses a mechanism very similar to Java Web Start, except that it runs without using GUI, making it convenient for an execution as a daemon on Unix. To do this, the user should configure this slave to be a JNLP slave by downloading <tt><span style=\"font-family: Courier New, monospace;\"><em>slave.jar<\/em><\/span><\/tt>, and then from the slave, run a command like this:<\/div>\n<pre style=\"font-weight: normal;\"><span style=\"font-family: Courier New, monospace;\">\u00a0<\/span><\/pre>\n<pre style=\"font-weight: normal;\"><span style=\"font-family: Courier New, monospace;\">java -jar slave.jar -jnlpUrl http:\/\/yourserver:port\/computer\/slave-name\/slave-agent.jnlp<\/span><\/pre>\n<div style=\"margin-bottom: 0in; font-weight: normal;\">\n<p>The <span style=\"font-family: Courier New, monospace;\">slave.jar<\/span> file is downloaded from the above mentioned URL. Make sure to replace <strong>slave-name<\/strong> with the name of the slave setup in Master.<\/p>\n<blockquote><p>By default, Hudson runs on port 8080. It can be installed and managed without the need for super user privilege. The super user privilege is not required to manage both Master and Slave.<\/p><\/blockquote>\n<\/div>\n<p>The\u00a0below diagram illustrates the list of configuration parameters specific to a slave.<\/p>\n<div class=\"separator\" style=\"text-align: center; clear: both;\"><a style=\"margin-bottom: 1em; float: right; margin-left: 1em; clear: right;\" href=\"http:\/\/3.bp.blogspot.com\/_dWL7A18AuFA\/S3qBFN_G-CI\/AAAAAAAABEw\/GYdxfv2w__4\/s1600-h\/hudson-slave-2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/3.bp.blogspot.com\/_dWL7A18AuFA\/S3qBFN_G-CI\/AAAAAAAABEw\/GYdxfv2w__4\/s400\/hudson-slave-2.png\" width=\"400\" height=\"176\" border=\"0\" \/><\/a><\/div>\n<p>&nbsp;<\/p>\n<h2 class=\"western\"><em><span style=\"font-size: small;\">set up\u00a0Slave Agent using own scripts<\/span><\/em><\/h2>\n<div>If the above modes is not flexible, the user can write his own script to launch the Slave agent. The script is placed in the Master computer and Hudson runs this script whenever it should connect to the slave. The script may use the remote login program like SSH, RSH to establish connection between Master and slave.<\/div>\n<div>The script would execute the slave agent program like <span style=\"font-family: Courier New, monospace;\">java -jar slave.jar. <\/span><span style=\"font-family: Times New Roman, serif;\">The stdin and stdout for the script should be connected to the master. For example, the script that does <\/span><span style=\"font-family: Courier New, monospace;\">ssh myslave java -jar ~\/bin\/slave.jar<\/span><span style=\"font-family: Times New Roman, serif;\"> would satisfy this need, when it is executed from the Master web interface. For this reason, running this script manually from the command line does no good.<\/span><\/div>\n<div style=\"font-family: Arial, Helvetica, sans-serif;\">The copy of slave.jar can be downloaded from the above mentioned URL. Launching the slave agent using this mode requires additional setup in the Slave. The benefit is that when the connection goes bad, the user can use Hudson web interface to re-establish the connection. <!-- BLOG_CMT_createIframe('http:\/\/www.blogger.com\/rpc_relay.html', '12285068873195078521'); \/\/ --><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The tasks can be scheduled to run on the same machine (Master), or on a different machine (Slave). A master is a installation of Hudson, that can manage one or&#8230; <\/p>\n","protected":false},"author":1,"featured_media":4420,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[1122,3113,429,4249,4244,4250,919,4246,4248,4240,593,230,4247,4245,732,213,1452],"class_list":["post-280","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorised","tag-guide","tag-how-to","tag-hudson","tag-hudson-master-slave-configuration","tag-hudson-master-slave-setup","tag-hudson-master-slave-setup-guide","tag-instructions","tag-master-slave-setup","tag-master-slave-hudson","tag-method","tag-process","tag-setup","tag-slave-agents-setup-method","tag-slave-setup","tag-steps","tag-tutorial","tag-ways"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=280"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/280\/revisions"}],"predecessor-version":[{"id":4422,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/280\/revisions\/4422"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/4420"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}