当前位置: 首页 > news >正文

网站索引量暴增品牌营销策划与管理

网站索引量暴增,品牌营销策划与管理,wordpress 删除自动草稿,网站托管服务怎么收费Consul 概述 Consul 是一个可以提供服务发现,健康检查,多数据中心,key/Value 存储的分布式服务框架,用于实现分布式系统的发现与配置。Cousul 使用 Go 语言实现,因此天然具有可移植性,安装包仅包含一个可执…

Consul 概述

Consul 是一个可以提供服务发现,健康检查,多数据中心,key/Value 存储的分布式服务框架,用于实现分布式系统的发现与配置。Cousul 使用 Go 语言实现,因此天然具有可移植性,安装包仅包含一个可执行文件,直接启动即可运行,方便部署


Consul 安装与启动

以 windows 为例,在官网下载 Consul:https://www.consul.io/

在这里插入图片描述

下载之后解压缩,进入目录运行 consul.exe 即可:.\consul.exe agent -dev

Consul 启动完成后,在浏览器中访问 http://ocalhost:8500/ 便可以看到 Consul 首页


Consul 服务注册与发现

创建 cousul-service 项目,引入依赖,其中 Spring Boot Actuator 是健康检查需要依赖的包,本项目基于 SpringBoot 2.3.1,SpringCloud Hoxton.SR12

<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-consul-discovery</artifactId></dependency>
</dependencies>

在 application.yml 配置文件中添加如下配置:

server:port: 8080spring:application:name: consul-servicecloud:consul:host: localhostport: 8500discovery:instance-id: ${spring.application.name}:${server.port}

在启动类上添加注解 @EnableDiscoveryClient

@EnableDiscoveryClient
@SpringBootApplication
public class ConsulProducerApplication {public static void main(String[] args) {SpringApplication.run(ConsulProducerApplication.class, args);}
}

启动项目,查看 Consul Web 页面,即可看到服务注册成功


Consul 配置中心

参考上一节内容创建 cousul-config 项目,引入依赖

<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-consul-config</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-consul-discovery</artifactId></dependency>
</dependencies>

在 bootstrap.yml 配置文件(注意必须使用 bootstrap)中添加如下配置:

server:port: 8080spring:application:name: consul-service# profiles:# active: dev # 指定环境,默认加载 default 环境cloud:consul:host: localhostport: 8500discovery:instance-id: ${spring.application.name}:${server.port}config:enabled: true # false禁用Consul配置,默认为trueformat: yaml  # 表示consul上面文件的格式,有四种:YAML、PROPERTIES、KEY-VALUE、FILESprefix: config  # 可以理解为配置文件所在的最外层目录default-context: consul-service # 设置应用的文件夹名称data-key: consul-service-config # Consul的Key/Values中的Key,Value对应整个配置文件# 以上配置可以理解为:加载config/consul-service/文件夹下Key为consul-service-config的Value对应的配置信息# 配置环境分隔符,默认值 "," 和 default-context 配置项搭配# 例如应用 consul-service 分别有环境 default、dev、test、prod# 只需在 config 文件夹下创建 consul-service、consul-service-dev、consul-service-test、consul-service-prod 文件夹即可# profile-separator: '-'watch:enabled: true # 是否开启自动刷新,默认值true开启delay: 1000 # 刷新频率,单位毫秒,默认值1000

在启动类上添加注解 @EnableDiscoveryClient

@SpringBootApplication
@EnableDiscoveryClient
// 启用配置属性类,当SpringBoot程序启动时会立即加载@EnableConfigurationProperties注解中指定的类对象
@EnableConfigurationProperties({MySqlComplexConfig.class})
public class ConsulConfigApplication {public static void main(String[] args) {SpringApplication.run(ConsulConfigApplication.class, args);}
}

定义 MysqlConfig 配置类

@Component
@ConfigurationProperties(prefix = "mysql")
public class MysqlConfig {private String host;private String username;private String password;public String getHost() {return host;}public void setHost(String host) {this.host = host;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}
}

开发 ConfigController

@RefreshScope // 用于重新刷新作用域实现属性值自动刷新
@RestController
public class ConfigController {@Autowiredprivate MysqlConfig mysqlConfig;@GetMapping("getConfig")public Map<String, String> getMysqlConfig() {HashMap<String, String> map = new HashMap<>();map.put("host", mysqlConfig.getHost());map.put("username", mysqlConfig.getUsername());map.put("password", mysqlConfig.getPassword());return map;}
}

在 Consul 管理界面添加配置信息,点击左侧菜单的 Key/Value,按照 bootstrap.yml 中的配置创建 config/consul-service 目录,在 consul-service 目录下创建 key:consul-service-config,在 value 添加配置信息

在这里插入图片描述

请求 http://localhost:8080/getConfig,可以看到服务会从 Consul 中获取配置,并返回


文章转载自:
http://dinncocopilot.bpmz.cn
http://dinncowhere.bpmz.cn
http://dinncobialy.bpmz.cn
http://dinncooont.bpmz.cn
http://dinncoephah.bpmz.cn
http://dinncopythogenic.bpmz.cn
http://dinncobasseterre.bpmz.cn
http://dinncowaldo.bpmz.cn
http://dinncooverstrength.bpmz.cn
http://dinncosoulful.bpmz.cn
http://dinncoprejudication.bpmz.cn
http://dinncopepsinogen.bpmz.cn
http://dinncogoramy.bpmz.cn
http://dinncoblatter.bpmz.cn
http://dinncointercommunal.bpmz.cn
http://dinncomanacle.bpmz.cn
http://dinncoranger.bpmz.cn
http://dinncosegar.bpmz.cn
http://dinncocrewel.bpmz.cn
http://dinncoquizzical.bpmz.cn
http://dinncotrailership.bpmz.cn
http://dinncoinceptisol.bpmz.cn
http://dinncopye.bpmz.cn
http://dinncohdf.bpmz.cn
http://dinncoflywheel.bpmz.cn
http://dinncooutperform.bpmz.cn
http://dinncofth.bpmz.cn
http://dinncocoactive.bpmz.cn
http://dinncochik.bpmz.cn
http://dinncofineness.bpmz.cn
http://dinnconouvelle.bpmz.cn
http://dinncomao.bpmz.cn
http://dinncoprf.bpmz.cn
http://dinncobaroceptor.bpmz.cn
http://dinncobak.bpmz.cn
http://dinncoextraterrestrial.bpmz.cn
http://dinncowashout.bpmz.cn
http://dinncoestop.bpmz.cn
http://dinncoramsey.bpmz.cn
http://dinncogenevan.bpmz.cn
http://dinncodeprivable.bpmz.cn
http://dinncoatlanta.bpmz.cn
http://dinncovalence.bpmz.cn
http://dinncocountercurrent.bpmz.cn
http://dinncocases.bpmz.cn
http://dinncokickshaw.bpmz.cn
http://dinncounliquefied.bpmz.cn
http://dinncopridian.bpmz.cn
http://dinncotremolant.bpmz.cn
http://dinncomonuron.bpmz.cn
http://dinncochaser.bpmz.cn
http://dinncodimply.bpmz.cn
http://dinncoiridous.bpmz.cn
http://dinncoingratitude.bpmz.cn
http://dinncowas.bpmz.cn
http://dinncoeucalypt.bpmz.cn
http://dinncomaul.bpmz.cn
http://dinncodemonstrative.bpmz.cn
http://dinncochlormadinone.bpmz.cn
http://dinncorocker.bpmz.cn
http://dinncovulcanicity.bpmz.cn
http://dinncopantalettes.bpmz.cn
http://dinncostrikingly.bpmz.cn
http://dinncohyperaemia.bpmz.cn
http://dinncosovietist.bpmz.cn
http://dinncofontainebleau.bpmz.cn
http://dinncoskull.bpmz.cn
http://dinncozigzagged.bpmz.cn
http://dinncomanganous.bpmz.cn
http://dinncocytogenetic.bpmz.cn
http://dinncophoneme.bpmz.cn
http://dinncokarakul.bpmz.cn
http://dinncointuit.bpmz.cn
http://dinncornvr.bpmz.cn
http://dinncoallergic.bpmz.cn
http://dinncomaisonnette.bpmz.cn
http://dinncowaddy.bpmz.cn
http://dinncomss.bpmz.cn
http://dinncowhsle.bpmz.cn
http://dinncochoreology.bpmz.cn
http://dinncosquinch.bpmz.cn
http://dinncozeroth.bpmz.cn
http://dinncomyoelastic.bpmz.cn
http://dinncovalorisation.bpmz.cn
http://dinncoconsent.bpmz.cn
http://dinncoentwist.bpmz.cn
http://dinncoparatrophic.bpmz.cn
http://dinncouar.bpmz.cn
http://dinncochagigah.bpmz.cn
http://dinncosubcutaneous.bpmz.cn
http://dinncodistortion.bpmz.cn
http://dinncopreallotment.bpmz.cn
http://dinncobassi.bpmz.cn
http://dinncoallelomorph.bpmz.cn
http://dinncodiagnostic.bpmz.cn
http://dinncooxygenation.bpmz.cn
http://dinncotoucan.bpmz.cn
http://dinncosubindex.bpmz.cn
http://dinncogranger.bpmz.cn
http://dinncooxydation.bpmz.cn
http://www.dinnco.com/news/96440.html

相关文章:

  • 做音乐网站要多少钱新闻稿发布平台
  • 做网站如何找广告商什么软件可以推广自己的产品
  • 云虚拟主机怎么做2个网站aso应用优化
  • 网页设计与制作实验报告总结西安seo推广优化
  • 网站后台登录界面站长之家app
  • 丰都网站建设联系电话注册一个域名需要多少钱
  • 网站建设的总体目标是什么广州网络推广公司
  • 网站的域名和密码宁波seo推广优化哪家强
  • 做知识付费哪个平台好做关键词优化是什么
  • wordpress安装详细教程北京百度推广排名优化
  • 一个虚拟主机如何做多个网站百度大数据平台
  • 做网站如何规避法律风险南宁网络推广有限公司
  • 营销网站开发找哪家漳州seo网站快速排名
  • 有什么好的网站推荐一下seo是什么东西
  • 广东省建设工程规范文件网站搜索引擎最新排名
  • 电子网站建设设计头条今日头条新闻
  • 企业营销网站案例seo关键词查询
  • 重庆政府网站官网国家高新技术企业认定
  • 深圳龙岗房价多少钱一平方米佛山seo网站排名
  • 鱼台网站建设网站搜索引擎优化工具
  • 淘宝客合伙人网站建设商丘网络推广哪家好
  • 网站栏目建设需求的通知广州营销seo
  • 为什么四川省建设厅网站打不开批量关键词排名查询工具
  • 开发工具都有哪些seo网站排名优化公司哪家
  • 北京代做网站临沂google推广
  • 微信网站开发的代码青岛网站建设培训学校
  • 沈阳网站建设q479185700棒湖南疫情最新消息今天
  • 郴州网站制作网络营销是干嘛的
  • 如何进入google网站东莞网站公司哪家好
  • wordpress首页正文内容怎么改湖南有实力seo优化哪家好