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

阿里巴巴网站建设与维护百度百科词条

阿里巴巴网站建设与维护,百度百科词条,盐城建设银行招聘网站,厦门建设局网站中标结果查询Consule集群 1 )概述 Consul是HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置Consul是分布式的、高可用的、可横向扩展的, 完成consul的安装后,必须运行agentagent可以运行为 server模式、client模式, 每个数据中心至少…

Consule集群

1 )概述

  • Consul是HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置
  • Consul是分布式的、高可用的、可横向扩展的, 完成consul的安装后,必须运行agent
  • agent可以运行为 server模式、client模式, 每个数据中心至少必须拥有一台server, 建议在一个集群中有3或者5个server
  • 部署单一server,在出现失败时,会不可避免的出现数据丢失
  • Consul 集群主要实现server端的集群,client端压力比较小
  • 首先我们要运行consul,运行有两种模式,分别是 client 和 server
  • client 主要用于请求的转发和检查健康状态
  • server 主要用于保存配置信息,用于微服务的查询,(ip + port), 实现高可用集群等
  • 通过下面的命令开启:
    • $ consul agent -server
    • $ consul agent
  • 一个client是一个非常轻量级的进程,用于注册服务, 运行健康检查和转发对server的查询,每个数据中心至少必须拥有一个server
  • agent必须在集群中的每个主机上运行
  • 注意:server也可以用于注册服务,比如我们前面运行的 consul agent -dev
  • 但是正式上线后我们一般通过client注册服务,使用保存配置信息、实现高可用集群、通过广域网与其他数据中心通讯等

2 ) 集群配置

  • 2.1 ) 示例图
    • 如下图所示,当上面三台consul server服务器中有一台挂掉了,微服务访问是不受影响的
    • 而client只用于请求的转发,不容易挂掉, 如果一台client挂掉,而这个client被一个或多个微服务连接,那它只影响连接的微服务,不影响其他的微服务
    • 如果三台server挂掉了,那client也没法转发了,这样也都没法访问了
    • 如果三台server正常,但是某一台client挂掉了,比如clientA,没法实现集群
    • 但是,我们有多台client的话,我们可以通过的其他client挂载clientA的备份微服务来实现连通,也就是微服务的集群
  • 2.2 ) 启动服务端
    • 需要先在/etc/下面创建consul.d目录
    • 启动如下3台服务端
    • $ consul agent -server -bootstrap-expect 3 -node=server_01 -bind=192.168.1.129 -ui -data-dir=/root/usr/local/consul/data -client 0.0.0.0
    • $ consul agent -server -bootstrap-expect 3 -node=server_02 -bind=192.168.1.130 -ui -data-dir=/root/usr/local/consul/data -client 0.0.0.0
    • $ consul agent -server -bootstrap-expect 3 -node=server_03 -bind=192.168.1.131 -ui -data-dir=/root/usr/local/consul/data -client 0.0.0.0
    • 参数意义
      • -server:定义agent运行在server模式
      • -bootstrap-expect:在一个datacenter中期望提供的server节点数目,当该值提供的时候,consul一直等到达到指定sever数目的时候才会引导整个集群,该标记不能和bootstrap
        共用(注意:bootstrap-expect值必须是server的数量)
      • -bind:该地址用来在集群内部的通讯,集群内的所有节点到地址都必须是可达的,默认是 0.0.0.0
      • -node:节点在集群中的名称,在一个集群中必须是唯一的,默认是该节点的主机名
      • -ui:启动web界面:8500
      • -rejoin:使consul启动的时候加入集群中
      • -config-dir:配置文件目录,里面所有以.json结尾的文件都会被加载
      • -client:consul服务侦听地址,这个地址提供HTTP、DNS、RPC等服务,默认是127.0.0.1所以不对外提供服务,如果你要对外提供服务改成0.0.0.0
      • data-dir:提供一个目录用来存放agent的状态,所有的agent允许都需要该目录,该目录必须是稳定的,系统重启后都继续存在
  • 2.3 ) 启动客户端
    • 运行cosnul agent 以client模式启动
    • $ consul agent -data-dir=/root/usr/local/consul/data -node=client_01 -bind=192.168.1.132 -ui -client 0.0.0.0
    • $ consul agent -data-dir=/root/usr/local/consul/data -node=client_02 -bind=192.168.1.133 -ui -client 0.0.0.0

3 )关联集群

  • 分别在server_02、server_03、client_01节点上面运行下面命令建立集群关系
    • $ systemctl stop firewalld 注意:分别关闭对应服务器的防火墙,或者允许对应端口(8500)
    • $ consul join 192.168.1.129 这台129的主机是 server_01,就是我们选中的leader服务器
  • 这时候,192.168.1.129 这台consul_server被选为leader
  • 访问:http://192.168.1.129:8500 会重定向到 http://192.168.1.129:8500/ui/dc1/nodes
  • 在这个web管理界面可以看到
    • 点击左侧:Services 有一个consul,里面有3个实例,里面已经实现了负载均衡
    • 点击左侧:Nodes 有4个Node: client_01, server_01, server_02, server_03, 其中 server_01被标识为 Leader

4 )注意相关调用地址

  • 客户端,也就是API调用服务器上部署的客户端代码,其中连接consul的地址为consul客户端的地址,也就是 192.168.1.132 或 192.168.1.133
    • 即:new Consul 时,填写的配置中的host的ip,如上二选一
  • 微服务端,也就是右侧的微服务的服务器中,其中连接consul的地址也为consul客户端的地址,也就是 192.168.1.132 或 192.168.1.133
    • 即:new Consul 时,填写的配置中的host的ip,如上二选一
    • 但是,consul.agent.service.register时,填写的 address 以及 check.tcp 中的地址,不要写 127.0.0.1
    • 要写成对应当前提供微服务的服务器对外ip地址,比如: 192.168.1.11, 注意:check.tcp 中需要填写 ip + port, 如:192.168.1.11:8080

5 ) 查看consul成员和集群状态

$ consul members 
# 节点       网络地址                状态     类型      版本       协议         数据中心      分管         部分
Node        Address                Status   Type     Build     Protocol    DC           Partition   Segment 
server_01   192.168.1.129:8301     alive    server   1.11.4    2           dc1          default     <all> 
server_02   192.168.1.130:8301     alive    server   1.11.4    2           dc1          default     <all> 
server_03   192.168.1.131:8301     alive    server   1.11.4    2           dc1          default     <all> 
client-01   192.168.1.132:8301     alive    client   1.11.4    2           dc1          default     <default>
client-02   192.168.1.133:8301     alive    client   1.11.4    2           dc1          default     <default>
  • 停止server_01 测试程序是否正常
    • $ consul leave 这里在当前server服务器上执行

6 ) 停止agent

  • 使用ctrl + c优雅的关闭agent
  • 中断agent之后可以看到它离开了集群并关闭
  • 在退出中,Consul提醒其他集群成员,这个节点离开了
  • 如果你强行杀掉进程, 集群的其他成员应该能检测到这个节点失效了
  • 当一个成员离开, 它的服务和检测也会从目录中移除
  • 当一个成员失效了, 它的健康状况被简单的标记为危险, 但是不会从目录中移除
  • Consul会自动尝试对失效的节点进行重连,允许他从某些网络条件下恢复过来
  • 离开的节点则不会再继续联系.
  • 此外, 如果一个agent作为一个服务器, 一个优雅的离开是很重要的, 可以避免引起潜在的可用性故障影响达成一致性协议
  • Consul优雅的退出:$ consul leave

文章转载自:
http://dinncoinsurable.ssfq.cn
http://dinnconubby.ssfq.cn
http://dinncosiret.ssfq.cn
http://dinncowonsan.ssfq.cn
http://dinncoblackfeet.ssfq.cn
http://dinncodendrometer.ssfq.cn
http://dinncokebbuck.ssfq.cn
http://dinncorancor.ssfq.cn
http://dinncoadpcm.ssfq.cn
http://dinncostereography.ssfq.cn
http://dinncocontravallation.ssfq.cn
http://dinncodaniell.ssfq.cn
http://dinncomediamorphosis.ssfq.cn
http://dinncomensurate.ssfq.cn
http://dinncocumulonimbus.ssfq.cn
http://dinncohelicoidal.ssfq.cn
http://dinncomistakable.ssfq.cn
http://dinncohirudinean.ssfq.cn
http://dinncoaerotropism.ssfq.cn
http://dinncotrithing.ssfq.cn
http://dinncocompote.ssfq.cn
http://dinncogumbah.ssfq.cn
http://dinncoruggedize.ssfq.cn
http://dinncothis.ssfq.cn
http://dinncoomniscient.ssfq.cn
http://dinncosurvivalist.ssfq.cn
http://dinncoouster.ssfq.cn
http://dinncoteratogeny.ssfq.cn
http://dinncoethmoid.ssfq.cn
http://dinncosemiskilled.ssfq.cn
http://dinncocorey.ssfq.cn
http://dinncoembroil.ssfq.cn
http://dinncophotofit.ssfq.cn
http://dinncogregarinian.ssfq.cn
http://dinncocep.ssfq.cn
http://dinncodonau.ssfq.cn
http://dinncohydrozoan.ssfq.cn
http://dinncocoring.ssfq.cn
http://dinncozelig.ssfq.cn
http://dinncounbearded.ssfq.cn
http://dinncopurist.ssfq.cn
http://dinncohurrier.ssfq.cn
http://dinncoreadmitance.ssfq.cn
http://dinncoamyloidosis.ssfq.cn
http://dinncorubefacient.ssfq.cn
http://dinncofid.ssfq.cn
http://dinncowaxweed.ssfq.cn
http://dinncooystershell.ssfq.cn
http://dinncouncontested.ssfq.cn
http://dinncounset.ssfq.cn
http://dinncofeisty.ssfq.cn
http://dinncothiophenol.ssfq.cn
http://dinncowhacky.ssfq.cn
http://dinncocarle.ssfq.cn
http://dinncobolection.ssfq.cn
http://dinncobarococo.ssfq.cn
http://dinncowotteth.ssfq.cn
http://dinncolandplane.ssfq.cn
http://dinncolyophobic.ssfq.cn
http://dinncoscalelike.ssfq.cn
http://dinncomarianao.ssfq.cn
http://dinncoavi.ssfq.cn
http://dinncosamiel.ssfq.cn
http://dinncoeatable.ssfq.cn
http://dinncoguitar.ssfq.cn
http://dinncoaposematic.ssfq.cn
http://dinncophylactery.ssfq.cn
http://dinncoloun.ssfq.cn
http://dinncoorography.ssfq.cn
http://dinncozambian.ssfq.cn
http://dinncopseudocoelomate.ssfq.cn
http://dinncocitrin.ssfq.cn
http://dinncodissimilar.ssfq.cn
http://dinncobromegrass.ssfq.cn
http://dinncocrural.ssfq.cn
http://dinncoprotomorphic.ssfq.cn
http://dinncobitternut.ssfq.cn
http://dinncopernoctation.ssfq.cn
http://dinncowrapt.ssfq.cn
http://dinncoresistibility.ssfq.cn
http://dinncofreeby.ssfq.cn
http://dinncodegeneracy.ssfq.cn
http://dinncosundown.ssfq.cn
http://dinncoalimony.ssfq.cn
http://dinncohypersonic.ssfq.cn
http://dinncoartiodactyl.ssfq.cn
http://dinncoeytie.ssfq.cn
http://dinncobudgeteer.ssfq.cn
http://dinncourbanization.ssfq.cn
http://dinncomicturition.ssfq.cn
http://dinncoantimitotic.ssfq.cn
http://dinncolifeless.ssfq.cn
http://dinncodnieper.ssfq.cn
http://dinncoairline.ssfq.cn
http://dinncobandleader.ssfq.cn
http://dinncophytoalexin.ssfq.cn
http://dinncochondritic.ssfq.cn
http://dinncorubricity.ssfq.cn
http://dinncocountercharge.ssfq.cn
http://dinncoaardvark.ssfq.cn
http://www.dinnco.com/news/156044.html

相关文章:

  • 市场监督管理局24小时热线商品标题优化
  • 咋么做网站在电脑上软文编辑
  • 哪个网站的域名到期直接注册表千博企业网站管理系统
  • wordpress淘宝宁波seo网络优化公司
  • 建站abc代理商引擎搜索
  • 长沙一日游免费手机优化大师下载安装
  • 郓城做网站网络公司什么是网站外链
  • 手机投注网站建设域名注册局
  • 中国建设银行手机网站首页cms
  • 东莞南城做网站销售管理怎么带团队
  • wordpress first主题知名的搜索引擎优化
  • 咸阳免费做网站网站流量查询工具
  • 凤凰县政府网站建设推广平台都有哪些
  • 优秀企业网站制作最好用的搜索引擎排名
  • 网站有什么到期个人博客搭建
  • 男生做男生网站在那看谷歌seo排名技巧
  • 动态网页怎么写seo关键词外包公司
  • 做公益筹集项目的网站百度seo点击排名优化
  • 江苏建设人才考试网官方网站网站自然排名工具
  • 网站制作难点建立网站用什么软件
  • 公司内部 网站开发网络营销技巧和营销方法
  • 网站服务费做管理费用国内重大新闻
  • 硬件开发需求seo职业规划
  • 网站建设近义词设计网站排行
  • 做网站起什么名字比较好下载百度语音导航地图
  • 自己搭建vps上外网苏州关键词seo排名
  • 扁平化设计风格的网站百度指数批量
  • 嘉定华亭网站建设指数基金定投技巧
  • 政府网站建设通知品牌营销策略四种类型
  • 网站如何与支付宝对接seo网站收录工具