Jenkins配置从节点问题:ssh slave known_hosts [SSH]与Slave JVM has terminated. Exit code=126

第一个问题 : /var/jenkins_home/.ssh/known_hosts No Known

第二个问题:jenkins Slave JVM has terminated. Exit code=126

First  :原因:jenkins master 通过ssh登录slave失败

背景:已经安全ant,配置java环境OK

仔细看日志,发现错误信息: 
/var/jenkins_home/.ssh/known_hosts [SSH] No Known Hosts file was found at /var/jenkins_home/.ssh/known_hosts. Please ensure one is created at this path and that Jenkins can read it.

Jenkins用户下,操作如下:

   64  ssh-keygen
   65  cd .ssh
   69  cat id_rsa.pub > authorized_keys
   70  chmod 700 authorized_keys

Jenkins master Web界面操作:

step 1

Jenkins配置从节点问题:ssh slave known_hosts [SSH]与Slave JVM has terminated. Exit code=126_第1张图片

  选项:Host Key Verification Strategy (主机密钥验证策略)修改;ssh 连接默认22;如果修改port点击高级

参考链接

"Known Hosts file verification strategy" 更改为 "Manually trusted key verification strategy".

CONFIGURE AGENT -> LAUNCH METHOD -> Manually trusted key verification strategy - > SAVE.

step 2

远程工作目录 ,配置为 /root/.jenkins,此处配置为了让master能找到slave的.ssh目录。

至此,问题解决。

Jenkins配置从节点问题:ssh slave known_hosts [SSH]与Slave JVM has terminated. Exit code=126_第2张图片

---------------------------------------------------------------------------

第二个问题:出现现象

jenkins slave启动报错:hudson.util.IOException2: Slave JVM has terminated. Exit code=126

正常的配置如下

Jenkins配置从节点问题:ssh slave known_hosts [SSH]与Slave JVM has terminated. Exit code=126_第3张图片

 

分析下图原因:
因为java-path(JDK路径) ,这个报错就是由于路径设置(没精确到java指令)错误的填写。此处java路径 不能仅仅指定JAVA_HOME
还要精确到java指令位置。如果只是到JAVA_HOME就会出现 bash: /usr/java/jdk1.8.0_101: is a directory
Click the Advanced button under the Launch Method section of the slave configuration and make sure JavaPath is set to /usr/java/jdk1.6.0_29/bin/java. It has to be the full path to the executable, not the JAVA_HOME location.如图示我从节点的jdk配置
[root@test-prod-01 /usr/local]$ echo $JAVA_HOME
/usr/local/jdk/jdk1.8.0_171
[root@test-prod-01 /usr/local]$ cd /usr/local/jdk/jdk1.8.0_171/bin/   
附上报错日志:
添加mac slave节点报错如下:
Expanded the channel window size to 4MB
  [18/09/15 19:11:54] [SSH] Starting slave process: cd "/test/app/abc/slavetest" && /usr/java        /jdk1.8.0_101 -XX:MaxPermSize=2048m -Xmx2048m -jar slave.jar
  bash: /usr/java/jdk1.8.0_101: is a directory
  hudson.util.IOException2: Slave JVM has terminated. Exit code=126
    at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:953)
    at hudson.plugins.sshslaves.SSHLauncher.access$400(SSHLauncher.java:133)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:711)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
  Caused by: java.io.EOFException: unexpected stream termination
    at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:200)
    at hudson.remoting.Channel.(Channel.java:419)
    at hudson.remoting.Channel.(Channel.java:398)
    at hudson.remoting.Channel.(Channel.java:394)
    at hudson.remoting.Channel.(Channel.java:383)
    at hudson.remoting.Channel.(Channel.java:375)
    at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:344)
    at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:945)
    ... 7 more  
 [18/09/15 19:11:54] Launch failed - cleaning up connection
  [18/09/15 19:11:54] [SSH] Connection closed.

 java路径指定好之后;问题完美解决如图

Jenkins配置从节点问题:ssh slave known_hosts [SSH]与Slave JVM has terminated. Exit code=126_第4张图片

ps:参考文章https://stackoverflow.com/questions/26808494/jenkins-ssh-slave-configuration 

你可能感兴趣的:(docker服务构建)