[xuxueli/xxl-job]Docker 运行 xxl-job-executor-samples提示无法连接xxl-job-admin

2023-12-13 65 views
8

今尝试将xxl-job-admin和xxl-job-executor-samples封装到docker中,发现通信存在问题

1 建立自定义网络mynet

2 运行xxl-job-admin

docker run -it --name xxl-job-admin --rm --net mynet xxl-job-admin:1.0.0

3 运行xxl-job-executor-samples

docker run -it --name xxl-job-executor-sample-springboot --rm --net mynet --env JAR_PARAM="--xxl.job.admin.addresses=http://xxl-job-admin/xxl-job-admin --xxl.job.executor.ip=xxl-job-admin" xxl-job-executor-sample-springboot:1.0.0

4 容器xxl-job-admin尝试ping xxl-job-executor-samples是通的,如下图 556b4d78ddfe1bb09970b26e48e22f89_b98ec017_778925

5 容器xxl-job-executor-samples尝试ping xxl-job-admin是通的,如下图 e6fb553a205ed2b31cd39fe612dc22bb_f3d470ae_778925

6 但是xxl-job-executor-samples的运行日志一直报错,连不上admin,异常如下

11:48:08.892 logback [xxl-job, executor ExecutorRegistryThread] INFO  c.x.j.c.t.ExecutorRegistryThread - >>>>>>>>>>> xxl-job registry fail, registryParam:RegistryParam{registryGroup='EXECUTOR', registryKey='xxl-job-executor', registryValue='http://xxl-job-admin:9989/'}, registryResult:ReturnT [code=500, msg=xxl-job remoting error(Connection refused (Connection refused)), for url : http://xxl-job-admin/xxl-job-admin/api/registry, content=null]
11:48:38.893 logback [xxl-job, executor ExecutorRegistryThread] ERROR c.x.job.core.util.XxlJobRemotingUtil - Connection refused (Connection refused)
java.net.ConnectException: Connection refused (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
        at java.net.Socket.connect(Socket.java:606)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:499)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:594)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:278)
        at sun.net.www.http.HttpClient.New(HttpClient.java:375)
        at sun.net.www.http.HttpClient.New(HttpClient.java:393)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1240)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1167)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1061)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:995)
        at com.xxl.job.core.util.XxlJobRemotingUtil.postBody(XxlJobRemotingUtil.java:99)
        at com.xxl.job.core.biz.client.AdminBizClient.registry(AdminBizClient.java:42)
        at com.xxl.job.core.thread.ExecutorRegistryThread$1.run(ExecutorRegistryThread.java:48)
        at java.lang.Thread.run(Thread.java:750)

回答

0

我们也是用的docker容器化,你需要给你的容器指定一个固定ip,否则ip将变化 --network=myent --ip 172.18.11.1

4

容器内 服务端和 客户端的配置 都是用的别名,未涉及到ip , 上述截图中有体现, 想问下咱的机制是哪里需要用ip吗 @xuxueli