博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Step by step guide to set up master and slave machines on Windows
阅读量:5979 次
发布时间:2019-06-20

本文共 4864 字,大约阅读时间需要 16 分钟。

Note: There is no need to install Jenkins on the slave machine.

  1. On your master machine go to Manage Jenkins > Manage Nodes.
  2. New Node --> Enter Node Name.
  3. Select Dumb Slave --> Press OK.
  4. Fill out the following:
    1. Set a number of executors (one or more) as needed.
    2. Set a Remote FS Root, a home directory for the master on the slave machine.
      1. For a Windows slave, use something like: "C:\Jenkins\"
      2. TODO: add details.
    3. Select the appropriate Usage setting:
      1. For an additional worker: Utilize this slave as much as possible 
      2. For specialized jobs: Leave this machine for tied jobs only
    4. Launch Method:
      1. An easy way to control a Windows slave is by using Launch slave agents via Java Web Start  (Recommended for Windows)
      2. TODO: add steps for other methods.
    5. Availability --> Keep this slave online as much as possible
      1. TODO: add details for each option.
    6. Press OK.
  5. Now you need to connect your slave machine to the master using the following steps.
    1. Open a browser on the slave machine and go to the Jenkins master server url ().
    2. Go to Manage Jenkins > Manage Nodes, Click on the newly created slave machine. You will need to login as someone that has the "Connect" Slave permission if you have configured global security.
    3. Click on the Launch button to launch agent from browser on slave.
    4. Run the program.
      ### If you encounter connection issue, then you could enlarge the popup windows to see the master port used and check your network configuration (firewall, port forward, ...)
    5. Now you should see the Slave machine connected under Nodes.
  6. If you want the service to run on start-up of the slave machine do the following (Windows only directions):
    1. In the Slave agent program running on your slave machine, 
    2. click File --> Install as Windows Service. 
      Note that this feature requires ".Net Framework 3.5"
    3. Start, type Services and Select the Services program.
    4. Find Jenkins Slave in the list, Double click to open.
    5. Select Startup type --> Automatic.
    6. Go to the Log On tab, change the Log on as to a user of your choice (Special user account Jenkins recommended).
    7. Make sure that auto login is set for the slave machine for the user account, then the VM (or physical computer) should connect and be available when needed.

Also: take a look at 

 

https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines+on+Windows

 

slave节点机器配置

  • 创建jenkins用户

用root用户登录slave节点,首先创建jenkins用户,并指定主目录

$ useradd -m jenkins -d /home/jenkins

查看jenkins用户及组的信息

$ id jenkinsuid=500(jenkins) gid=500(jenkins) 组=500(jenkins)

再修改jenkins密码,若不修改是未知的

$ passwd jenkins

再切换到jenkins用户,确保jdk已安装

$ su - jenkins

同时确保slave已安装jdk

$ java -version

且sshd正确运行

$ service --status-all | grep ssh
  • 创建公钥私钥,实现免用户密码登录

使用jenkins用户登录到jenkins master机器

使用jenkins用户登录时若发现连接失败(lost connection),可以先用root用户登录,打开/etc/passwd,找到

jenkins:x:498:499:Jenkins Continuous Integration Server:/var/lib/jenkins:/bin/false

将最后的/bin/false改为/bin/bash,便可以登录。记得使用完改回去,猜测是安全限制。

jenkins用户登录后执行以下命令,生成公私钥

$ ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): /var/lib/jenkins/.ssh/id_rsa

将公钥和私钥保存到jenkins主目录下,注意确保.ssh目录和id_rsa都是jenkins用户所拥有或者有可读写权限

然后会要求输入passphrase(密码),这里还是不设置,直接两次enter

进入/var/lib/jenkins/.ssh,使用scp命令将生成的公钥id_rsa.pub拷贝到各个slave节点,并命名为authorized_keys

$ scp id_rsa jenkins@xxx.xxx.xxx.xxx:~/.ssh/authorized_keys

同时要修改authorized_keys的权限,

$ chmod 700 authorized_keys

Jenkins控制台slave配置

回到jenkins控制台,打开以下页面,添加credentials,以下配置页面是添加slave的jenkins用户密码

另一种ssh免密码登录配置(基于公开密钥的认证),可指定jenkins master私钥的路径或者选择第三个From the Jenkins master ~./ssh,我们选择/var/lib/jenkins/.ssh/id_rsa,这是在上一节创建的私钥

创建slave

进入“系统管理>管理节点>新建节点”,输入节点名称,我已经建了一个节点,所以可以选择复制

进入配置页面,按要求填写,credentialsp这里选择用户密码登录,免密码登录需要指定一个属于它的id_rsa。

保存之后,点击Relaunch agent,启动节点

https://segmentfault.com/a/1190000008369457

作为slave的Linux机器为centos系统。

 

1) Linux 的 Slave机器设置 

 

创建jenkins用户sudo /usr/sbin/useradd -m jenkins -d /home/jenkins;

查看jenkins用户及组的信息id jenkins :

uid=506(jenkins) gid=506(jenkins) groups=506(jenkins) ;

使用sudo /usr/bin/passwd jenkins来设置用户jenkins的密码为0;

切换到用户jenkins环境下su - jenkins;

确保java安装正确:java --version;

确保sshd正确运行: /sbin/service --status-all | grep ssh;

安装ant,在root下运行yum install ant;

 

 

2) 在Slave的linux机器上创建public/private key pair:

确保当前用户为jenkins;

执行ssh-keygen来创建public/private key pair,直接enter,表示key将存储在/home/jenkins/.ssh/id_rsa下,再直接enter,表示不设置密码,再次enter确认密码为空;

创建authorized_keys:

cd .ssh

cat id_rsa.pub > authorized_keys

chmod 700 authorized_keys

;

 

将id_rsa(相当于privatekey)拷贝到jenkins master机器上,例如c:\jenkins\id_rsa下。

 

 

3)创建Slave(note),配置如下:

确保jenkins 中ssh slave plugin正确安装,一般默认安装。

然后lunch slave,使得master和slave通过ssh成功连接。其实launch的时候jenkins自动地从拷贝slave.jar到slave,然后运行通过命令java -jar slave.jar来运行slave。

 

 

4)在新建的Linux的Slave上运行上节中的JavaHelloWorld(),且需要修改JavaHelloWorld job的Label为JavaHelloWorldLinux来使用此slave,运行如下:

 

 

 

 

完! 

http://www.cnblogs.com/itech/archive/2011/11/10/2244690.html

 

转载于:https://www.cnblogs.com/softidea/p/6854993.html

你可能感兴趣的文章
B3log部署文档
查看>>
第 27 章 C++
查看>>
典型:Eayui项目aspx页面引用js
查看>>
Android 中文 API (22) —— MultiAutoCompleteTextView
查看>>
8.5. show mac-address-table
查看>>
10.2。PHP_CodeSniffer
查看>>
煮酒论AI,看看大牛怎么说
查看>>
利用多线程解决多业务不同定时区间歇触发问题的一种方法
查看>>
DDD~WCF做中间件,实现多个项目的缓存共享
查看>>
分布式系统的那些事儿(六) - SOA架构体系
查看>>
0-1背包-分支限界
查看>>
iOS开发之全局变量
查看>>
微信网页开发之创建Controller(三)
查看>>
二叉排序树
查看>>
Content-Type的几种常用数据编码格式
查看>>
电视尺寸与观看距离对应表
查看>>
小明历险记:规则引擎drools教程一
查看>>
MPLS LDP随堂笔记2
查看>>
国内下载golang.org/x/net
查看>>
数据库索引原理及优化
查看>>