Consul安装

1.1 Win安装


选择我们想要下载的版本

点击下载,如果芯片是AMD选择右边下载。

解压下载的文件

进入解压之后的文件查看是否成功安装

consul agent -dev
-dev表示开发模式运行,另外还有-server表示服务模式运行


前端查看:

1.2 CentOS安装

1.查看系统芯片架构

arch

2.安装解压工具unzip

yum install -y unzip


3.下载consul

wget https://releases.hashicorp.com/consul/1.17.0/consul_1.17.0_linux_386.zip

格式
wget https://releases.hashicorp.com/consul/${VER}/consul_${VER}_linux_386.zip
注:${VER}为consul的版本


4.解压提取文件

unzip consul_1.17.0_linux_386.zip

5.将解压的文件移动到/usr/local/bin

6.检查是否安装成功

consul version


7.启动:

consul agent -dev -ui -node=consul-dev -client=0.0.0.0

nohup consul agent -ui -dev -node=consul-dev -client=0.0.0.0 2>&1 &


8.微服务注册中心测试

spring:
  application:
    name: cloud-payment-service
  profiles:
    # 多环境配置文件,不写就是default
    active: prop
  cloud:
    consul:
      host: ip地址
      port: 8500
      discovery:
        service-name: ${spring.application.name}
        heartbeat:
          enabled: true
      #        分布式配置
      config:
        profile-separator: '-'
        format: YAML
        watch:
          wait-time: 1
@SpringBootApplication
@EnableDiscoveryClient
@RefreshScope
public class Main8001 {
    public static void main(String[] args) {
        SpringApplication.run(Main8001.class,args);
    }
}

posted @ 2024-05-11 12:36  无涯子wyz  阅读(49)  评论(0编辑  收藏  举报