(13) Springcloud of springboot E-commerce mall - using Eureka cluster to build and implement high availability service registry

Sweet girl 2021-04-08 10:25:47
springcloud springboot e-commerce commerce mall


The registration center we built above is only suitable for local development , In the production environment, we must build a cluster to ensure high availability .Eureka The method of building cluster is very simple : Each station Eureka Just specify more than one... In the configuration Eureka You can build a cluster with the address of .

Now let's 2 A node is taken as an example to illustrate the construction method . Suppose we have master and slaveone Two machines , What needs to be done is :

  • take master Sign up to slaveone above .
  • take slaveone Sign up to master above .

If it is 3 Taiwan machine , And so on :

  • take master Sign up to slaveone and slavetwo above .
  • take slaveone Sign up to master and slavetwo above .
  • take slavetwo Sign up to master and slaveone above .

Steps to build

Create a new project eureka-server-cluster, Configure the following eureka-server equally .

First , We need to increase 2 Property files , Start different instances in different environments . increase application-master.properties:

server.port=8761
# To your slave node Eureka
eureka.client.serviceUrl.defaultZone=http:// user name : password @localhost:8762/eureka/

increase application-slaveone.properties:

server.port=8762
# Pointing to your master node Eureka
eureka.client.serviceUrl.defaultZone=http:// user name : password @localhost:8761/eureka/

stay application.properties Add the following to :

spring.application.name=eureka-server-cluster
# Because the app is a registry , So set to false, Representative does not register himself with the registry 
eureka.client.register-with-eureka=false
# Because the registry's job is to maintain service instances , There's no need to retrieve Services , So it's also set to false
eureka.client.fetch-registry=false
spring.security.user.name=zhangsan
spring.security.user.password=123456
# Specify different environments 
spring.profiles.active=master

stay A The default on the machine is master start-up , And then in B Add on the machine --spring.profiles.active=slaveone Start it up .

This will be master Registered to slaveone in , take slaveone Registered to master in , No matter who has a problem , Applications can continue to use the surviving registry .

Previously, in the client, we configured eureka.client.serviceUrl.defaultZone To specify the corresponding registry , When our registry has multiple nodes , It needs to be modified eureka.client.serviceUrl.defaultZone Is configured as the address of multiple nodes , Multiple addresses can be separated by English commas :

eureka.client.serviceUrl.defaultZone=
http://zhangsan:123456@localhost:8761/eureka/,http://zhangsan:123456@localhost:8762/eureka/

Recommended cloth type Micro Service Mall

版权声明
本文为[Sweet girl]所创,转载请带上原文链接,感谢
https://javamana.com/2021/04/20210408100654796M.html

  1. HttpServletRequest, obtaining request header and request body through request, solving Chinese garbled code and other problems
  2. Mybatis learning notes - one to one, one to many, many to many association query
  3. Mybatis learning notes - basic concepts and operation
  4. Spring Cloud 升级之路 - 2020.0.x - 3. Undertow 的 accesslog 配置
  5. Spring cloud upgrade road - 2020.0. X - 3. Accesslog configuration of undertow
  6. 被Java培训机构坑骗后,我在这里找回了自信
  7. After being cheated by java training institutions, I found my confidence here
  8. Linux下安装Mysql出现的常见问题以及解决办法
  9. Common problems and solutions of installing MySQL under Linux
  10. java并发编程JUC第十二篇:AtomicInteger原子整型
  11. Java Concurrent Programming JUC Chapter 12: atomicinteger atomic integer
  12. 面经手册 · 第29篇《Spring IOC 特性有哪些,不会读不懂源码!》
  13. Chapter 29 "what are the features of spring IOC? I can't understand the source code! 》
  14. 浅析linux容器--Docker
  15. Analysis of Linux container -- docker
  16. 换种方法学操作系统,轻松入门Linux内核
  17. 浅析linux容器--Docker
  18. Another way to learn operating system, easy access to Linux kernel
  19. Analysis of Linux container -- docker
  20. 手摸手教你阅读和调试大型开源项目 ZooKeeper
  21. Hand in hand teaching you to read and debug large open source project zookeeper
  22. 基于SpringBoot 在线答题系统 含小程序!
  23. 10个优秀开源JavaScript模板引擎
  24. JavaScript基础知识及写法
  25. Based on springboot online answering system, including small procedures!
  26. 重磅!谷歌Fuchsia操作系统将支持运行Linux应用程序
  27. (四十) springcloud分布式商城之跟我学习SpringCloud-Gateway整合Eureka路由转发
  28. Spring IOC 特性有哪些,不会读不懂源码!
  29. 手摸手教你阅读和调试大型开源项目 ZooKeeper
  30. 10 excellent open source JavaScript template engines
  31. Basic knowledge and writing method of JavaScript
  32. win10安装mysql5.7
  33. Heavy weight! Google's Fuchsia operating system will support running Linux applications
  34. (40) Spring cloud distributed mall learn from me spring cloud gateway integrates Eureka routing and forwarding
  35. What are the spring IOC features? I can't understand the source code!
  36. Hand in hand teaching you to read and debug large open source project zookeeper
  37. Install mysql5.7 in win10
  38. SCIP:构造数据抽象--数据结构中队列与树的解释
  39. Spring Cloud+Nacos实现服务注册中心(Hoxton版本)
  40. rabbitmq-server的安装与升级
  41. SCIP: constructing data abstraction -- Explanation of queue and tree in data structure
  42. Spring cloud + Nacos to implement service registry (Hoxton version)
  43. Installation and upgrade of rabbitmq server
  44. Lei Jun: Xiaomi's spring conference has been largely streamlined, which will take at least four hours. Some products will be directly released on Weibo
  45. IntelliJ IDEA 2021最新激活码(亲测有效,可激活至 2089 年)
  46. java版本spring cloud+spring boot+mybatis 分布式商城 微服务商城 多租户商城 电子商务 直播带货商城 社交电商
  47. win10安装Redis5.0
  48. (十五)springboot电子商务商城之SpringCloud-使用Eureka集群搭建实现高可用服务注册中心
  49. (十四)springboot电子商务商城之SpringCloud-Eureka自我保护模式和InstanceID的配置
  50. 花生壳内网穿透(Linux版)
  51. Docker部署elasticsearch(单机)
  52. (十三)springboot电子商务商城之SpringCloud-使用Eureka集群搭建实现高可用服务注册中心
  53. (十二)springboot电子商务商城之Eureka注册中心开启密码认证
  54. 七、Spring Boot 集成 Thymeleaf 模板引擎
  55. mysql 命令行秒复制数据库
  56. Windows安装Mysql(msi 图形安装)
  57. The latest activation code of IntelliJ idea 2021
  58. Java应用全链路启动速度提升至15s,阿里云SAE能力再升级
  59. Linux基础命令
  60. Who moved your red envelope? Risk control report of 2021 spring festival activities