2017-04-09 644 views
2

我正在使用jenkins swarm插件将从节点连接到主节点。但是,它给出Connection Refused错误。jenkins群插件:无法连接到主。拒绝连接

我正在使用docker swarm将其部署到多节点群集上。现在我有一个节点的设置只测试,这里是为我设置撰写文件:使用docker stack deploy命令,使上述每个服务都有自己的内部负载平衡器部署

version: '3.1' 

    services: 
     viz: 
     image: manomarks/visualizer 
     volumes: 
      - "/var/run/docker.sock:/var/run/docker.sock" 
     ports: 
      - "8090:8080" 

     master: 
     image: myproject-jenkins-master 
     ports: 
      - "8080:8080" 
      - "50000:50000" 
     volumes: 
      - ./jenkins_home:/var/jenkins_home 

     nginx: 
     image: myproject-jenkins-nginx 
     ports: 
      - "80:80" 

     linuxagent: 
     image: myproject-jenkins-linuxagent 

和其正。

Jenkins通过nginx在网站上提供。但是我还保留了8080端口用于调试。如果我打开浏览器并点击http://localhosthttp://localhost:8080,我可以访问jenkins网页界面。在master上,我已经安装了jenkins swarm插件。如果我从我的linuxagent容器(其打算成为从属节点)进入bash shell,我可以ping其他docker服务,但是当我尝试运行swarm-client-3.3.jar文件时,会发生什么情况。

如果我尝试访问詹金斯,我可以通过访问http://myproject_master:8080

[email protected]:~# curl http://myproject_master:8080 
<html><head><meta http-equiv='refresh' content='1;url=/login?from=%2F'/><script>window.location.replace('/login?from=%2F');</script></head><body style='background-color:white; color:white;'> 


Authentication required 
<!-- 
You are authenticated as: anonymous 
Groups that you are in: 

Permission you need to have (but didn't): hudson.model.Hudson.Read 
... which is implied by: hudson.security.Permission.GenericRead 
... which is implied by: hudson.model.Hudson.Administer 
--> 

</body></html>                                                                           [email protected]:~# 

也是这样做的,我可以通过http://myproject_nginx

roo[email protected]:~# curl http://myproject_nginx  
<html><head><meta http-equiv='refresh' content='1;url=/login?from=%2F'/><script>window.location.replace('/login?from=%2F');</script></head><body style='background-color:white; color:white;'> 


Authentication required 
<!-- 
You are authenticated as: anonymous 
Groups that you are in: 

Permission you need to have (but didn't): hudson.model.Hudson.Read 
... which is implied by: hudson.security.Permission.GenericRead 
... which is implied by: hudson.model.Hudson.Administer 
--> 

</body></html>                                                                           [email protected]:~# 

访问相同的。如果我尝试推出的jar文件群,我得到这个错误:

[email protected]:~# java -jar swarm-client-3.3.jar -username mandeep -password 12213 -master http://myproject_nginx  
Apr 09, 2017 5:52:44 PM hudson.plugins.swarm.Client main 
INFO: Client.main invoked with: [-username mandeep -password 12213 -master http://myproject_nginx] 
Apr 09, 2017 5:52:44 PM hudson.plugins.swarm.Client run 
INFO: Discovering Jenkins master 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
Apr 09, 2017 5:52:44 PM hudson.plugins.swarm.Client run 
INFO: Attempting to connect to http://myproject_nginx/ bc1be8e7-eaf0-47ff-8aeb-36f75d6ba081 with ID c84ce43b 
Apr 09, 2017 5:52:45 PM hudson.remoting.jnlp.Main createEngine 
INFO: Setting up slave: d139902be5de-c84ce43b 
Apr 09, 2017 5:52:45 PM hudson.remoting.jnlp.Main$CuiListener <init> 
INFO: Jenkins agent is running in headless mode. 
Apr 09, 2017 5:52:45 PM hudson.remoting.jnlp.Main$CuiListener status 
INFO: Locating server among [http://myproject_nginx/] 
Apr 09, 2017 5:52:45 PM hudson.remoting.jnlp.Main$CuiListener status 
INFO: Agent discovery successful 
    Agent address: myproject_nginx 
    Agent port: 50000 
    Identity:  86:5b:f3:77:84:92:21:87:95:4c:4b:0e:f7:4e:e5:1d 
Apr 09, 2017 5:52:45 PM hudson.remoting.jnlp.Main$CuiListener status 
INFO: Handshaking 
Apr 09, 2017 5:52:45 PM hudson.remoting.jnlp.Main$CuiListener status 
INFO: Connecting to myproject_nginx:50000 
Apr 09, 2017 5:52:55 PM hudson.remoting.jnlp.Main$CuiListener status 
INFO: Connecting to myproject_nginx:50000 (retrying:2) 
java.io.IOException: Failed to connect to myproject_nginx:50000 
    at org.jenkinsci.remoting.engine.JnlpAgentEndpoint.open(JnlpAgentEndpoint.java:243) 
    at hudson.remoting.Engine.connect(Engine.java:500) 
    at hudson.remoting.Engine.innerRun(Engine.java:364) 
    at hudson.remoting.Engine.run(Engine.java:287) 
Caused by: java.net.ConnectException: Connection refused 
    at sun.nio.ch.Net.connect0(Native Method) 
    at sun.nio.ch.Net.connect(Net.java:454) 
    at sun.nio.ch.Net.connect(Net.java:446) 
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:648) 
    at java.nio.channels.SocketChannel.open(SocketChannel.java:189) 
    at org.jenkinsci.remoting.engine.JnlpAgentEndpoint.open(JnlpAgentEndpoint.java:204) 
    ... 3 more 

似乎是这样的问题是从服务器期望主服务器为myproject_nginx,并因此到达端口50000,该端口失败,因为此服务没有公开端口50000。所以为此,我在myproject_master服务上公开了端口808050000。但是,当我尝试的URL,然后我得到一个不同的错误

[email protected]:~# java -jar swarm-client-3.3.jar -username mandeep -password 12213 -master http://myproject_master:8080 
Apr 09, 2017 5:57:01 PM hudson.plugins.swarm.Client main 
INFO: Client.main invoked with: [-username mandeep -password 12213 -master http://myproject_master:8080] 
Apr 09, 2017 5:57:01 PM hudson.plugins.swarm.Client run 
INFO: Discovering Jenkins master 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
Apr 09, 2017 5:57:01 PM hudson.plugins.swarm.Client run 
SEVERE: IOexception occurred 
java.net.ConnectException: Connection refused (Connection refused) 
    at java.net.PlainSocketImpl.socketConnect(Native Method) 
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) 
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) 
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) 
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 
    at java.net.Socket.connect(Socket.java:589) 
    at java.net.Socket.connect(Socket.java:538) 
    at java.net.Socket.<init>(Socket.java:434) 
    at java.net.Socket.<init>(Socket.java:286) 
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80) 
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122) 
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) 
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361) 
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387) 
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) 
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) 
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) 
    at hudson.plugins.swarm.SwarmClient.discoverFromMasterUrl(SwarmClient.java:224) 
    at hudson.plugins.swarm.Client.run(Client.java:115) 
    at hudson.plugins.swarm.Client.main(Client.java:88) 

这是我完全卡住,无法了解如何解决这个问题。由于从站运行在负载均衡器后面,是否会出现问题?或者,我试图完成的架构中是否存在任何根本错误?我希望能够动态扩展linuxagent服务,以便每个节点都充当从属代理,并且只要启动时就与主节点连接。我阅读了关于jenkins的swarm插件,并发现它可以用来实现这种设置

+0

您是否找到解决方法?我面临同样的问题与类似的设置 –

回答

0

对于我来说,改变固定它的参数顺序。 请将-master到开始的群参数:

java -jar /usr/share/jenkins/swarm-client-3.4.jar -disableSslVerification -master 

这应该可以解决下面的错误,我看到:

Jul 25, 2017 6:26:23 PM hudson.plugins.swarm.Client run 
INFO: Discovering Jenkins master 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for 
further details. 
Exception in thread "main" java.lang.IllegalArgumentException: Host 
name may not be null 
at org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:68) 
at org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:107) 
at org.apache.commons.httpclient.HttpMethodBase.setURI(HttpMethodBase.java:280) 
at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:220) 
at org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89) 
at hudson.plugins.swarm.SwarmClient.discoverFromMasterUrl(SwarmClient.java:220) 
at hudson.plugins.swarm.Client.run(Client.java:114) 
at hudson.plugins.swarm.Client.main(Client.java:87) 
0

尝试打开入站的TCP端口443和50000两。

相关问题