zoukankan      html  css  js  c++  java
  • Spring Cloud Eureka集群部署到Linux环境

      还是三板斧:先改配置文件,支持集群,然后出包,上传到linux环境(3个节点),最后启动jar包跑起来。

      1、在原eureka服务端代码(参见Greenwich.SR2版本的Spring Cloud Eureka实例)基础上修改配置文件即可,这次我们废弃原来的application.properties文件,新增3个yml(用properties也可以,自己选用):

      application-es1.yml(给192.1.6.19节点用,它需要指定另外两个节点作为注册中心,其他两个同理):

    eureka:
      client:
        fetch-registry: true
        register-with-eureka: true
        service-url:
          defaultZone: http://192.1.6.20:8761/eureka,http://192.1.6.22:8761/eureka
      instance:
        prefer-ip-address: true
        instance-id: ${spring.cloud.client.ip-address}:${server.port}
        hostname: ${spring.cloud.client.ip-address}
        ip-address: 192.1.6.19
    
    spring:
      profiles:
        active: es1
      application:
        name: eureka-server
    
    server:
      port: 8761

      application-es2.yml:

    eureka:
      client:
        fetch-registry: true
        register-with-eureka: true
        service-url:
          defaultZone: http://192.1.6.19:8761/eureka,http://192.1.6.22:8761/eureka
      instance:
        prefer-ip-address: true
        instance-id: ${spring.cloud.client.ip-address}:${server.port}
        hostname: ${spring.cloud.client.ip-address}
        ip-address: 192.1.6.20
    
    spring:
      profiles:
        active: es2
      application:
        name: eureka-server
    
    server:
      port: 8761

      application-es3.yml:

    eureka:
      client:
        fetch-registry: true
        register-with-eureka: true
        service-url:
          defaultZone: http://192.1.6.19:8761/eureka,http://192.1.6.20:8761/eureka
      instance:
        prefer-ip-address: true
        instance-id: ${spring.cloud.client.ip-address}:${server.port}
        hostname: ${spring.cloud.client.ip-address}
        ip-address: 192.1.6.22
    
    spring:
      profiles:
        active: es3
      application:
        name: eureka-server
    
    server:
      port: 8761

      2、maven出包后直接到linux对应的三个节点上rz -y上传生成的jar包

      3、在三个节点上启动eureka-server,分别根据环境指定参数es1、es2、es3,比如我在192.1.1.0上启动,那么我需要指定环境为es1,其他两个同理:

    java -jar eureka-0.0.1-SNAPSHOT.jar --spring.profiles.active=es1

      最后看下eureka界面http://192.1.1.2:8761/,可以看到已经支持集群,另外两个链接界面就不贴了:

      如果要重启实例,需要先把原有进程找出来,比如我要重启es3环境的eureka:

    $ netstat -nlp | grep 8761
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    tcp6       0      0 :::8761                 :::*                    LISTEN      14998/java          
    $ kill 14998
    $ java -jar eureka-0.0.1-SNAPSHOT.jar --spring.profiles.active=es3
  • 相关阅读:
    Arthas线上问题排查
    如何快速增加pdf书签,解除pdf限制
    数组指针——指向数组的指针(通过指针控制数组)
    指针和数组直接对应关系之如何记忆
    C/C++语言中指针数组和数组指针比较区别
    int最大值+1为什么是-2147483648最小值-1为什么是2147483647
    电脑进行二进制加减运算方法
    C/C++语言中的函数参数传参三种对比
    Python基于VS2013 开发环境搭建 Hello World 10分钟搞定
    算法的复杂度包括时间复杂度和空间复杂度分别如何计算?
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/11230848.html
Copyright © 2011-2022 走看看