将 Eureka 客户端注册到 Eureka 服务器
Registering a Eureka Client to a Eureka Server
我尝试将 Eureka 服务器连接到 Eureka 客户端,但没有成功。全部在容器中。 Docker/Container 网络设置为主机。
我尝试在我的桌面上托管两者:有效
我尝试在我的 Raspberry pi 上托管两者:有效
但是当我在我的 Raspberry Pi 上托管服务器时,我无法从我的桌面连接该服务。我试了很多都没有成功。
旁注:我可以访问 Eureka 仪表板,并且我有另一个容器 运行 成功连接到我桌面上的 SQL 数据库,我想应该不会有网络问题。
客户
server:
port: 9001
spring:
application.name: USER-SERVICE
cloud:
inetutils:
preferred-networks:
- 192.168
eureka:
instance:
prefer-ip-address: true
hostname: 192.168.0.20
client:
fetch-registry: true
register-with-eureka: true
service-url:
defeaultZone: http://192.168.0.69:8761/eureka
服务器
server:
port: 8761
eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://192.168.0.69:8761/eureka
instance:
hostname: 192.168.0.69
prefer-ip-address: true
192.168.0.20是我的桌面
192.168.0.69 是我的 raspberry pi
这可能吗?我尝试了很多不同的设置...正如我所说的,两者都在本地托管或在树莓派上运行。
提前致谢
错误信息:
2021-08-15 00:40:24.177 INFO 16044 --- [ main] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}, exception=I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect stacktrace=org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
我能够通过将 ${eureka_url: } 添加到 defaultZone 来解决问题。现在完美运行。
eureka:
client:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: ${eureka_url:http://192.168.0.69:8761/eureka}
instance:
hostname: 192.168.0.69
prefer-ip-address: true
我尝试将 Eureka 服务器连接到 Eureka 客户端,但没有成功。全部在容器中。 Docker/Container 网络设置为主机。
我尝试在我的桌面上托管两者:有效 我尝试在我的 Raspberry pi 上托管两者:有效
但是当我在我的 Raspberry Pi 上托管服务器时,我无法从我的桌面连接该服务。我试了很多都没有成功。
旁注:我可以访问 Eureka 仪表板,并且我有另一个容器 运行 成功连接到我桌面上的 SQL 数据库,我想应该不会有网络问题。
客户
server:
port: 9001
spring:
application.name: USER-SERVICE
cloud:
inetutils:
preferred-networks:
- 192.168
eureka:
instance:
prefer-ip-address: true
hostname: 192.168.0.20
client:
fetch-registry: true
register-with-eureka: true
service-url:
defeaultZone: http://192.168.0.69:8761/eureka
服务器
server:
port: 8761
eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://192.168.0.69:8761/eureka
instance:
hostname: 192.168.0.69
prefer-ip-address: true
192.168.0.20是我的桌面 192.168.0.69 是我的 raspberry pi
这可能吗?我尝试了很多不同的设置...正如我所说的,两者都在本地托管或在树莓派上运行。
提前致谢
错误信息:
2021-08-15 00:40:24.177 INFO 16044 --- [ main] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}, exception=I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect stacktrace=org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
我能够通过将 ${eureka_url: } 添加到 defaultZone 来解决问题。现在完美运行。
eureka:
client:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: ${eureka_url:http://192.168.0.69:8761/eureka}
instance:
hostname: 192.168.0.69
prefer-ip-address: true