Antes de los distintos configuración de clúster, puede llamar al servicio, pero el servicio aquí url disponible-réplicas siempre presente, medios que no están disponibles. Después de varios intentos, al final, o al agrupar el nombre de host del camino, pero el servicio de la aplicación, o las llamadas de agrupamiento sobre IP.
Varios fallos, Baidu por un largo tiempo, finalmente encontró el artículo. El problema se resuelve. Antes de confusión es la forma de contenedores ventana acoplable para configurar el archivo hosts.
Artículo de referencia: https: //blog.csdn.net/benben_2015/article/details/88426438
La versión final de este escrito el guión.
// definir una URL, es la dirección del clúster.
= UREKA_SERVICEURL " HTTP: // test8761: 8761 / Eureka /, HTTP: // test8762: 8762 / Eureka /, HTTP: // test8763: 8763 / Eureka / "
Ejecutar Servicios SH " acoplable RUN --restart = Siempre -p 8761 : 8761 " + " $ -d {-v} log_path: log_path $ {} " +
// Centro de Registro de direcciones " -e eureka.client.serviceUrl.defaultZone EUREKA_SERVICEURL = $ {} " +
// nombre del contenedor " -e Eureka = test8761 .instance.hostname " +
// atención se centra en esta línea, archivo host tres direcciones adicionales. Finalmente, en el contenedor en el archivo / etc / hosts también vio tres direcciones. "--add-host = test8761: 192.168.89.130 --add-host = test8762: 192.168.89.130 --add-host = test8763: 192.168.89.130 " + " $ {--name PROJECT_NAME} " + " $ GUARDAMUEBLES "
Compruebe en el contenedor
[Maestro root @ ~ ] # acoplable PS ========== Ver todos corriendo buque PUERTOS ID de contenedor Estado la imagen creada los nombres de comando 7e8a4101623c 192.168 . 89.132 / MYBs-Cloud / Eureka: 0.0 . . 1 -SNAPSHOT " -Djava.securit ... Java " 19 minutos atrás Hasta miembro 19 minutos 0.0 . 0.0 : 8763 -> 8761 / tcp eureka8763 707bb1f2dc5c 192.168 . 89.132/ MYBs-nube / Eureka: 0,0 . 1 -SNAPSHOT " java -Djava.securit ... " 19 hace minutos hasta 19 minutos 0.0 . 0.0 : 8762 -> 8761 / tcp eureka8762 24636b410d2d 192.168 . 89.132 / MYBs-nube / Eureka: 0,0 . 1 -SNAPSHOT " java -Djava.securit ... " 19 hace minutos hasta 19 minutos 0.0 . 0.0 : 8761 -> 8761/ tcp Eureka [root @ amo ~] # exec ventana acoplable -es 24636b410d2d / bin / fiesta ===========进入容器 root @ 24636b410d2d: / # cat / etc / anfitrión =======查看anfitriones文件 anfitriones host.conf nombre de host hosts.allow hosts.deny root @ 24636b410d2d: / # cat / etc / hosts 127.0 . 0,1 localhost :: 1 localhost ip6-localhost ip6- loopback FE00 :: 0 ip6- localnet FF00 :: 0 ip6- mcastprefix FF02 :: 1 ip6- allnodes FF02 :: 2 ip6-allrouters 192.168 . 89.130 test8761 192.168 . 89.130 test8762 192.168 . 89.130 test8763 172,17 . 0,3 24636b410d2d root @ 24636b410d2d: / #
El Nodo ( " $ {} nodeTag " ) { // acoplable registro de depósito privado DEF REGISTRY_URL = " 192.168.89.132 " DEF REGISTRY_UID = " ADMIN " DEF REGISTRY_PID = " Harbor12345 " // depósito privado nombre de la casa DEF MAIN_NAME = " MS- nube " // directorio directorio del proyecto DEF PROJECT_NAME = " $ {} projectName " // versión del elemento DEF PROJECT_VERSION = " 0.0.1-SNAPSHOT " // nombre de la imagen DEF = el repositorio "$ {} REGISTRY_URL / $ {} MAIN_NAME / $ {} PROJECT_NAME: $ {} PROJECT_VERSION " // 日志路径 def log_path = " / home / fecha / logs / $ {} PROJECT_NAME / " // 注册中心Eureka地址 def = EUREKA_SERVICEURL " http://192.168.89.130:8761/eureka/,http://192.168.89.130:8762/eureka/,http://192.168.89.130:8763/eureka/ " fase ( ' empezar ' ) { sh " fecha + '% Y-% m-% d% H:% M:% S' " } etapa ( " 1, claro $ {PROJECT_NAME} " ) { echo " limpieza de $ {PROJECT_NAME} ..." sh " parada ventana acoplable $ {} PROJECT_NAME | true " sh " ventana acoplable rm -f $ {} PROJECT_NAME | true " sh " ventana acoplable imagen rm $ GUARDAMUEBLES | true " } etapa ( " 2, desplegar $ {} PROJECT_NAME " ) { echo " desplegar $ {} PROJECT_NAME ... " sh " ventana acoplable entrada -u $ {} REGISTRY_UID -p $ {} $ {REGISTRY_PID REGISTRY_URL} " si (== PROJECT_NAME " MS-base-eureka ") { EUREKA_SERVICEURL = "http: // test8761: 8761 / Eureka /, http: // test8762: 8762 / Eureka /, http: // test8763: 8763 / Eureka / " SH " run ventana acoplable --restart = siempre -p 8761: 8761 " + " -d -v $ {} log_path: $ {} log_path " + " -e eureka.client.serviceUrl.defaultZone = $ {} EUREKA_SERVICEURL " + " -e eureka.instance.hostname = test8761 " + " --add-anfitrión = test8761: 192.168.89.130 --add-host = test8762: 192.168.89.130 --add-host = test8763: 192.168.89.130 " + " $ --name {} PROJECT_NAME "+ " $ GUARDAMUEBLES" Sh " ventana acoplable rm -f $ {} PROJECT_NAME 8762 | true " sh " run = ventana acoplable --restart siempre -p 8762: 8761 " + " -d -v $ {} log_path 8762: $ {} log_path " + " - e eureka.client.serviceUrl.defaultZone = $ {} EUREKA_SERVICEURL " + " -e eureka.instance.hostname = test8762 " + " --add-host = test8761: 192.168.89.130 --add-host = test8762: 192.168.89.130 --add-host = test8763: 192.168.89.130 " + " $ --name {} PROJECT_NAME 8762 "+ "$ GUARDAMUEBLES " sh " ventana acoplable rm -f $ {} PROJECT_NAME 8763 | true " sh " run = ventana acoplable --restart siempre -p 8763: 8761 " + " -d -v $ {} log_path 8763: $ {} log_path " + " -e eureka.client.serviceUrl.defaultZone = $ {} EUREKA_SERVICEURL " + " -e eureka.instance.hostname = test8763 " + " --add-host = test8761: 192.168.89.130 --add-host = test8762: 192.168 .89.130 --add-host = test8763: 192.168.89.130 " + "--name $ {} PROJECT_NAME 8763 "+ " $ GUARDAMUEBLES " } demás si (== PROJECT_NAME " MS-base-config " ) { sh " run = ventana acoplable --restart siempre -p 8888: 8888 " + " -d -v $ {} log_path: $ {log_path } " + " -e eureka.client.serviceUrl.defaultZone = $ {} EUREKA_SERVICEURL " + " $ {--name PROJECT_NAME} " + " $ GUARDAMUEBLES " } demás { error 'Por favor seleccione la rama que desea publicar ' } } De la etapa ( ' Resultados 3 ' ) { echo " acabado $ {PROJECT_NAME} " } etapa ( ' final ' ) { sh " fecha + '% Y-% m-% d% H:% M:% S' " eco " 本次运行时间: $ {} currentBuild.duration ms " } }