- 浏览: 2564741 次
- 性别:
- 来自: 成都
-
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Spring Cloud Consul(2)Cluster
Install on Ubuntu
> wget https://releases.hashicorp.com/consul/1.4.0/consul_1.4.0_linux_amd64.zip
> unzip consul_1.4.0_linux_amd64.zip
Prepare the working directory
> mkdir ~/tool/consul-1.4.0
> mkdir ~/tool/consul-1.4.0/bin
Add to the PATH and check the installation
> consul version
Consul v1.4.0
Install on CentOS
> wget https://releases.hashicorp.com/consul/1.4.0/consul_1.4.0_linux_amd64.zip
Unzip and prepare the working directory
> mkdir -p ~/tool/consul-1.4.0/bin
> vi ~/.bash_profile
Check version on CentOS
> consul version
Consul v1.4.0
Prepare the Data directory, Start Master with -server Mode
> mkdir /opt/consul/data
> mkdir /opt/consul/conf
> consul agent -server -bootstrap -data-dir /opt/consul/data -node=agent-1 -bind=192.168.56.101 -advertise=192.168.56.101 -client=0.0.0.0 -config-dir /opt/consul/conf -datacenter dc1 -ui
Prepare the data and conf directory and start the Second Node Joining the Cluster
> consul agent -server -data-dir /opt/consul/data -node=agent-2 -bind=192.168.56.102 -advertise=192.168.56.102 -client=0.0.0.0 -config-dir /opt/consul/conf -datacenter dc1 -ui -retry-join "192.168.56.101"
Only one machine can start in -bootstrap mode, then We can visit the cluster in
http://ubuntu-master:8500/ui/dc1/services
Check members
> consul members
Node Address Status Type Build Protocol DC Segment
agent-1 192.168.56.101:8301 alive server 1.4.0 2 dc1 <all>
agent-2 192.168.56.102:8301 alive server 1.4.0 2 dc1 <all>
Check IP on the ubuntu-master machine
> local_ip="`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`"
> echo $local_ip
172.17.0.1 10.0.2.15 192.168.56.101
This can set up the default health check
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
/actuator/health
We can also implement the health check controller ourselves.
We can change the Producer API and Consumer API to connect to the cluster and Customer the Health Check if we need to.
Producer API 1
spring:
application:
name: springcloud-consul-producer
cloud:
consul:
host: ubuntu-master
port: 8500
discovery:
hostname: ubuntu-master
enabled: true
serviceName: consul-producer
health-check-interval: 10s
register: true
health-check-path: /health
tags: owner=Sillycat
server:
port: 8501
Health Check
@GetMapping("/health")
public String health(){
return "hello consul";
}
Producer API 2
spring:
application:
name: springcloud-consul-producer
cloud:
consul:
host: ubuntu-master
port: 8500
discovery:
hostname: centos-dev1
enabled: true
serviceName: consul-producer
health-check-interval: 10s
register: true
health-check-path: /health
tags: owner=Kiko
server:
port: 8502
Health Check
@GetMapping("/health")
public String health(){
return "hello consul";
}
More Configuration
https://www.imooc.com/article/22441
Check the Cluster from my Local
> consul members -http-addr=ubuntu-master:8500
Node Address Status Type Build Protocol DC Segment
agent-1 192.168.56.101:8301 alive server 1.4.0 2 dc1 <all>
agent-2 192.168.56.102:8301 alive server 1.4.0 2 dc1 <all>
It can be used as the configuration sharing center
https://gitbook.cn/books/5b38d875d00fdd680bb774e8/index.html
References:
https://my.oschina.net/tree/blog/1594206
Install on Ubuntu
> wget https://releases.hashicorp.com/consul/1.4.0/consul_1.4.0_linux_amd64.zip
> unzip consul_1.4.0_linux_amd64.zip
Prepare the working directory
> mkdir ~/tool/consul-1.4.0
> mkdir ~/tool/consul-1.4.0/bin
Add to the PATH and check the installation
> consul version
Consul v1.4.0
Install on CentOS
> wget https://releases.hashicorp.com/consul/1.4.0/consul_1.4.0_linux_amd64.zip
Unzip and prepare the working directory
> mkdir -p ~/tool/consul-1.4.0/bin
> vi ~/.bash_profile
Check version on CentOS
> consul version
Consul v1.4.0
Prepare the Data directory, Start Master with -server Mode
> mkdir /opt/consul/data
> mkdir /opt/consul/conf
> consul agent -server -bootstrap -data-dir /opt/consul/data -node=agent-1 -bind=192.168.56.101 -advertise=192.168.56.101 -client=0.0.0.0 -config-dir /opt/consul/conf -datacenter dc1 -ui
Prepare the data and conf directory and start the Second Node Joining the Cluster
> consul agent -server -data-dir /opt/consul/data -node=agent-2 -bind=192.168.56.102 -advertise=192.168.56.102 -client=0.0.0.0 -config-dir /opt/consul/conf -datacenter dc1 -ui -retry-join "192.168.56.101"
Only one machine can start in -bootstrap mode, then We can visit the cluster in
http://ubuntu-master:8500/ui/dc1/services
Check members
> consul members
Node Address Status Type Build Protocol DC Segment
agent-1 192.168.56.101:8301 alive server 1.4.0 2 dc1 <all>
agent-2 192.168.56.102:8301 alive server 1.4.0 2 dc1 <all>
Check IP on the ubuntu-master machine
> local_ip="`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`"
> echo $local_ip
172.17.0.1 10.0.2.15 192.168.56.101
This can set up the default health check
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
/actuator/health
We can also implement the health check controller ourselves.
We can change the Producer API and Consumer API to connect to the cluster and Customer the Health Check if we need to.
Producer API 1
spring:
application:
name: springcloud-consul-producer
cloud:
consul:
host: ubuntu-master
port: 8500
discovery:
hostname: ubuntu-master
enabled: true
serviceName: consul-producer
health-check-interval: 10s
register: true
health-check-path: /health
tags: owner=Sillycat
server:
port: 8501
Health Check
@GetMapping("/health")
public String health(){
return "hello consul";
}
Producer API 2
spring:
application:
name: springcloud-consul-producer
cloud:
consul:
host: ubuntu-master
port: 8500
discovery:
hostname: centos-dev1
enabled: true
serviceName: consul-producer
health-check-interval: 10s
register: true
health-check-path: /health
tags: owner=Kiko
server:
port: 8502
Health Check
@GetMapping("/health")
public String health(){
return "hello consul";
}
More Configuration
https://www.imooc.com/article/22441
Check the Cluster from my Local
> consul members -http-addr=ubuntu-master:8500
Node Address Status Type Build Protocol DC Segment
agent-1 192.168.56.101:8301 alive server 1.4.0 2 dc1 <all>
agent-2 192.168.56.102:8301 alive server 1.4.0 2 dc1 <all>
It can be used as the configuration sharing center
https://gitbook.cn/books/5b38d875d00fdd680bb774e8/index.html
References:
https://my.oschina.net/tree/blog/1594206
发表评论
-
Update Site will come soon
2021-06-02 04:10 1688I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 325I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 486NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 375Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 376Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 345Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 437Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 447Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 383Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 469VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 396Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 491NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 433Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 343Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 257GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 458GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 334GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 319Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 327Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 304Serverless with NodeJS and Tenc ...
相关推荐
SpringCloud Demo 亲测可用 Spring Cloud是一系列框架的有序集合. 主要的小弟有:Spring Cloud Config、Spring Cloud Netflix(Eureka、Hystrix、Zuul、Archaius…)、Spring Cloud Bus、Spring Cloud for Cloud ...
2. **Spring Cloud Netflix**:这是 SpringCloud 的核心组件,它整合了 Netflix 的多个开源组件,如: - **Eureka**:作为服务治理组件,Eureka 提供服务注册与发现功能,可以让服务提供者自动注册到 Eureka 服务器...
7. **一次性 Token** (OAuth2): Spring Cloud Security 提供了 OAuth2 的支持,用于生成一次性 Token,确保请求的安全性,防止未授权访问。 8. **全局锁** (Distributed Lock): 在分布式系统中,全局锁用于保证在多...
- **集群状态管理**:利用 Spring Cloud Cluster 管理集群状态。 #### 三、环境搭建 1. **安装 JDK 和 Maven** - 确保已经安装了 JDK 8 或更高版本。 - 安装 Maven 进行项目管理和构建。 ```bash sudo apt-...
- **领导选举**:利用Spring Cloud Cluster实现。 - **分布式会话**:通过Spring Session实现跨服务的会话共享。 - **集群状态**:例如使用Consul进行服务的状态管理。 #### 二、Spring Cloud配置中心 Spring ...
Spring Cloud 提供了 Ribbon,这是一个客户端负载均衡器,它可以与 Eureka、Consul 等服务发现组件结合使用。Ribbon 提供了多种负载均衡策略,例如轮询(Round Robin)、随机(Random)、最不常使用(Least ...
第三个开源作品地址: : 技术栈Spring Cloud Config,Spring Cloud Netflix(Eureka,Hystrix,Zuul,Archaius…),Spring Cloud Bus,Spring Cloud for Foundry,Spring Cloud Cluster,Spring Cloud Consul,...
- **Spring Cloud Consul**:使用Consul进行服务发现和配置管理。 - **Spring Cloud Security**:实现安全认证和授权。 - **Spring Cloud Sleuth**:跟踪分布式系统中的请求链路。 - **Spring Cloud Data Flow**...
Turbine使用了Spring Cloud的DiscoveryClient接口,这意味着它可以与Eureka、Consul等服务发现组件集成,自动发现并聚合所有提供Hystrix Metrics Stream的服务。 在实际的微服务环境中,我们通常会有如下的服务配置...
16. **Spring Cloud Cluster**: 提供领导选举机制,支持多种集群管理模式。 17. **Spring Cloud Starters**: 提供了一系列预配置的依赖项,简化了项目的搭建过程。 #### 五、总结 通过上述介绍可以看出,**Spring ...
对于Spring Cloud,重点在于服务发现(Eureka、Consul)、熔断机制(Hystrix)、负载均衡(Ribbon、Feign)以及API网关(Zuul、Gateway)等微服务治理组件。 微服务篇则会深入探讨微服务架构的优点、挑战及其实践。...
2. Spring Cloud:为微服务提供一套完整的解决方案,包括服务发现、配置中心、断路器、路由、熔断等。 3. Spring Data:简化数据库操作,支持JPA、MyBatis等持久层框架。 4. Spring AOP:实现切面编程,进行非业务...
了解服务发现(如Eureka、Consul),API Gateway(如Zuul、Spring Cloud Gateway),以及服务间的通信方式(RESTful API、gRPC、Dubbo等)。理解Docker容器化和Kubernetes编排系统在微服务部署中的作用。 【消息...
2. **Dubbo和SpringCloud有什么关系?** Dubbo和Spring Cloud都是用于构建分布式系统的框架,但它们的设计理念有所不同。Dubbo更专注于服务治理,而Spring Cloud则侧重于微服务架构的整体解决方案。 3. **Dubbo和...
1. **Spring Cloud集成**:Nacos可以很好地与Spring Cloud生态结合,作为服务注册与发现的组件,简化微服务的构建。 2. **配置中心**:在微服务架构中,Nacos可以替代传统的配置管理工具如Zookeeper或Consul,提供...
6. **数据源适配**:Sentinel 控制台可以接入不同数据源,如 Spring Cloud Config、Consul 等,实现规则的集中化管理。 **安装 Sentinel 控制台步骤:** 1. 首先,从 Sentinel 的官方仓库或 Maven 中心仓库下载...
Dubbo专注于RPC调用,强调服务治理,而Spring Cloud是基于Spring Boot的全面微服务解决方案,包括配置管理、服务发现、断路器、智能路由、微代理等更多功能。 **Dubbo支持的协议** Dubbo支持多种通信协议,如Dubbo...
例如,使用Atomikos或Seata等工具解决分布式事务的一致性问题,采用Spring Cloud或Service Mesh来构建微服务架构,以及使用Docker和Kubernetes进行应用的自动化部署和管理。 总的来说,分布式Java应用基础与实践...
例如,2.7.x版本引入了更多的微服务特性,如Spring Cloud集成、熔断机制、配置中心等,这些都是现代分布式系统中不可或缺的部分。 总的来说,分析和学习Apache Dubbo 2.7.5的源码,不仅可以加深对RPC框架的理解,还...