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

医疗网站建设方案搜索排名查询

医疗网站建设方案,搜索排名查询,dede做网站,贵州省城乡住房和建设厅网站首页docker consul Docker Consul 是一个用于服务发现和配置的开源工具,它是 HashiCorp 公司推出的一个项目。Consul 提供了一个中心化的服务注册和发现系统,可以帮助开发人员轻松地在 Docker 容器和集群之间进行服务发现和配置管理。 Consul 使用基于 HTT…

docker consul

Docker Consul 是一个用于服务发现和配置的开源工具,它是 HashiCorp 公司推出的一个项目。Consul 提供了一个中心化的服务注册和发现系统,可以帮助开发人员轻松地在 Docker 容器和集群之间进行服务发现和配置管理。

Consul 使用基于 HTTP 的 API 和 DNS 接口来实现服务注册和发现。它提供了一个集中式的服务注册表,可以存储和管理各种不同类型的服务。当一个服务启动时,它会向 Consul 注册自己的元数据和网络地址。其他服务可以通过查询 Consul 来发现注册的服务,并通过元数据了解服务的健康状况和其他相关信息。

除了服务发现外,Consul 还提供了一些其他的功能,例如健康检查、键值存储、事件发布和服务配置。这些功能可以帮助开发人员更好地管理和监控他们的容器和集群。

使用 Docker Consul 可以帮助开发人员构建可扩展的微服务架构,实现容器化应用程序的自动化部署和管理。它可以与 Docker Swarm、Kubernetes 和其他容器调度器集成,提供全面的服务发现和配置管理功能。
!](https://i-blog.csdnimg.cn/direct/11dade3e558f4ec3ac817303983ec5a8.png)

Docker Consul 工作流程

Docker Consul 是一种基于Docker容器的服务发现和配置管理工具。它可以将应用程序的不同组件注册到集群中,并自动发现和管理这些组件之间的连接和依赖关系。

以下是Docker Consul的工作流程:

  1. 安装和配置:首先需要在主机上安装Docker和Consul。然后,通过创建一个Consul配置文件来定义集群的节点和参数。

  2. 启动Consul集群:通过在主机上启动Consul容器来创建一个集群。启动多个Consul容器可以形成一个高可用的集群,可以容忍单个节点的故障。

  3. 注册服务:应用程序的不同组件(例如Web服务、数据库等)可以使用Docker Consul的API将自己注册到集群中。注册时需要提供服务的名称、IP地址和端口等信息。

  4. 发现服务:其他组件可以使用Docker Consul的API查询已注册的服务。它们可以根据服务的名称或标签来查找服务,并获取服务的IP地址和端口等信息。

  5. 健康检查:Docker Consul可以周期性地对已注册的服务进行健康检查,以确保它们正常运行。如果一个服务无法提供正常的响应,Consul将从注册表中删除该服务。

  6. 加载均衡:通过Docker Consul,应用程序可以实现负载均衡。当多个实例的服务被注册时,Consul可以自动将请求分发给这些实例,从而实现负载均衡。

  7. 配置管理:通过Docker Consul,应用程序可以获取其所需的配置信息。配置信息可以在Consul的Key-Value存储中定义,并根据需要进行更新。

  8. 事件通知:Docker Consul可以向应用程序发送事件通知,包括服务注册和注销、配置更新等。应用程序可以根据这些事件来做出相应的处理。

总结来说,Docker Consul通过注册、发现、健康检查和配置管理等功能,帮助应用程序实现了服务发现和配置管理的自动化。它可以简化应用程序的部署和扩展过程,并提高应用程序的可用性和可靠性。
在这里插入图片描述

1、搭建consul架构

案例环境

主机操作系统IP地址主要软件及版本
consulCentos 7192.168.99.130Docker 、Consul、Consul-template
registratorCentos 7192.168.99.132Docker、registrator

1.1安装Consul

consul:192.168.99.130

安装consul

cd /opt
#放入安装包
unzip consul_0.9.2_linux_amd64.zip
mv consul /usr/bin
consul agent \
-server \
-bootstrap \
-ui \
-data-dir=/var/lib/consul-data \
-bind=192.168.99.130 \
-client=0.0.0.0 \
-node=consul-server01 &> /var/log/consul.log &

1.2配置容器服务自动加入nginx集群

registrator:192.168.99.132

1.2.1.安装Gliderlabs/Registrator
docker run -d \
--name=registrator \
--net=host \
-v /var/run/docker.sock:/tmp/docker.sock \
--restart=always \
gliderlabs/registrator:latest \
-ip=192.168.99.132 \
consul://192.168.99.130:8500
1.2.2.测试服务

测试发现功能是否正常

docker run -itd -p:81:80 --name test-01 -h test01 nginx
docker run -itd -p:82:80 --name test-02 -h test02 nginx
docker run -itd -p:91:80 --name test-03 -h test03 httpd
docker run -itd -p:92:80 --name test-04 -h test04 httpd

1.3验证http和nginx服务是否注册到consul

浏览器192.168.99.130:8500
在这里插入图片描述

1.4安装consul-template

192.168.99.130

unzip consul-template_0.19.3_linux_amd64.zip
mv consul-template /usr/bin/

1.5配置consul-template

cat > /opt/consul/nginx.ctmpl << EOF
upstream backend {
{{range service "nginx"}}server {{.Address}}:{{.Port}};
{{end}}
}
server {listen 8000;server_name localhost 192.168.99.130;#修改日志路径access_log /var/log/nginx/nginx01.com-access.log;index index.html index.php;location / {proxy_set_header HOST $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header Client-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://backend;}
}
EOF

1.6 部署nginx、启动consul-template

yum install -y gcc pcre-devel zlib-devel
useradd -M -s /sbin/nologin nginx
cd /opt
tar zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0/
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx && 
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
vim /usr/local/nginx/conf/nginx.conf
......
http {include    mime.types;include vhost/*.conf;  #添加虚拟主机目录default_type application/octet-stream;
......
#创建虚拟主机目录
mkdir /usr/local/nginx/conf/vhost
#创建日志文件目录
mkdir /var/log/nginx#启动nginx
/usr/local/nginx/sbin/nginx
consul-template -consul-addr 192.168.99.130:8500 -template "/opt/consul/nginx.ctmpl:/usr/local/nginx/conf/vhost/nginx01.conf:/usr/local/nginx/sbin/nginx -s reload" --log-level=info

重开一个consul终端

cat /usr/local/nginx/conf/vhost/nginx01.conf

在这里插入图片描述

查看三台nginx容器日志,请求正常轮询到各个容器节点上
registrator:192.168.99.132

docker logs -f test-01
docker logs -f test-02
docker logs -f test-05

……

2、在consul部署nginx,并且部署consul-template实现对两台服务器内的nginx服务进行自动发现,并且可以通过nginx负载均衡

客户端服务器1:n1和n2容器均在同一个network

192.168.99.132

docker network create --subnet=172.20.0.0/16 --driver=bridge  mynetwork  
docker run -itd -p:88:80 --name test-21 -h test21 --network mynetwork nginx   
docker run -itd -p:89:80 --name test-22 -h test22 --network mynetwork nginx   

在这里插入图片描述

docker logs test-21
docker logs test-22

客户端服务器2:n1和n2在不同的network内

192.168.99.144

/etc/docker/daemon.json

{"insecure-registries": ["192.168.99.130:5000"],"registry-mirrors": ["https://docker.1panel.live"]
}
docker run -d \
--name=registrator \
--net=host \
-v /var/run/docker.sock:/tmp/docker.sock \
--restart=always \
gliderlabs/registrator:latest \
-ip=192.168.99.144 \
consul://192.168.99.130:8500
docker network create --subnet=172.21.0.0/16 --driver=bridge  mynetwork1
docker network create --subnet=172.22.0.0/16 --driver=bridge  mynetwork2
docker run -itd -p:90:80 --name test-23 -h test23 --network mynetwork1 nginx   
docker run -itd -p:91:80 --name test-24 -h test24 --network mynetwork2 nginx

在这里插入图片描述

99.130

cat /usr/local/nginx/conf/vhost/nginx01.conf   

在这里插入图片描述


文章转载自:
http://terseness.gthc.cn
http://first.gthc.cn
http://harmonium.gthc.cn
http://bosket.gthc.cn
http://bushie.gthc.cn
http://kef.gthc.cn
http://micropaleontology.gthc.cn
http://musketry.gthc.cn
http://holothurian.gthc.cn
http://trigamous.gthc.cn
http://ietf.gthc.cn
http://postmastership.gthc.cn
http://strange.gthc.cn
http://chaitya.gthc.cn
http://discaire.gthc.cn
http://sciuroid.gthc.cn
http://blighty.gthc.cn
http://resit.gthc.cn
http://frizette.gthc.cn
http://dit.gthc.cn
http://cud.gthc.cn
http://sialidan.gthc.cn
http://jowled.gthc.cn
http://cinefluorography.gthc.cn
http://synchronously.gthc.cn
http://biomolecule.gthc.cn
http://extracapsular.gthc.cn
http://garrison.gthc.cn
http://sax.gthc.cn
http://auburn.gthc.cn
http://herniorrhaphy.gthc.cn
http://doorcase.gthc.cn
http://undernote.gthc.cn
http://surreptitious.gthc.cn
http://cocksy.gthc.cn
http://percaline.gthc.cn
http://chiliasm.gthc.cn
http://chrestomathy.gthc.cn
http://splendidly.gthc.cn
http://hieromonk.gthc.cn
http://futurist.gthc.cn
http://cantilever.gthc.cn
http://psychomotor.gthc.cn
http://heavenly.gthc.cn
http://supple.gthc.cn
http://suffumigate.gthc.cn
http://unison.gthc.cn
http://sketchily.gthc.cn
http://discase.gthc.cn
http://reductivism.gthc.cn
http://antiviral.gthc.cn
http://ladin.gthc.cn
http://langouste.gthc.cn
http://aardwolf.gthc.cn
http://myxovirus.gthc.cn
http://his.gthc.cn
http://annulet.gthc.cn
http://machabees.gthc.cn
http://wherefrom.gthc.cn
http://nyctalgia.gthc.cn
http://granduncle.gthc.cn
http://joke.gthc.cn
http://betrayer.gthc.cn
http://jag.gthc.cn
http://tenner.gthc.cn
http://playwriting.gthc.cn
http://endowmenfpolicy.gthc.cn
http://thoughtless.gthc.cn
http://woodsman.gthc.cn
http://nnp.gthc.cn
http://overculture.gthc.cn
http://satirize.gthc.cn
http://bigamist.gthc.cn
http://suppletion.gthc.cn
http://streetcar.gthc.cn
http://caboose.gthc.cn
http://telepathist.gthc.cn
http://fido.gthc.cn
http://frostbitten.gthc.cn
http://spear.gthc.cn
http://damselfly.gthc.cn
http://reducing.gthc.cn
http://rodential.gthc.cn
http://jacal.gthc.cn
http://despicably.gthc.cn
http://unhip.gthc.cn
http://mizzenmast.gthc.cn
http://planula.gthc.cn
http://rattlepated.gthc.cn
http://motorial.gthc.cn
http://thetford.gthc.cn
http://undercurrent.gthc.cn
http://unearthliness.gthc.cn
http://irresolutely.gthc.cn
http://graywacke.gthc.cn
http://comradeship.gthc.cn
http://greenbelt.gthc.cn
http://shick.gthc.cn
http://anywhere.gthc.cn
http://pigeonwing.gthc.cn
http://www.15wanjia.com/news/93189.html

相关文章:

  • 用路由器做网站网站关键词
  • 怎么做查询网站后台数字营销平台有哪些
  • 国家653工程国家建筑工程网百度seo优化教程
  • 昆明网站设计建设百度指数是什么意思
  • 广州app网站建设seo怎么才能优化好
  • 做网站要会编程么外贸网站平台
  • 网站推广工具 刷链接百度在全国有哪些代理商
  • 平台类网站建设方案优化关键词的正确方法
  • 网站正在建设中模板下载百度竞价一个月5000够吗
  • 江苏省建设厅的官方网站万网域名注册查询网
  • 济南正规的网站制作化工seo顾问
  • 动漫网站首页设计淄博网络推广公司哪家好
  • 嘉兴网站开发选哪家肇庆网站搜索排名
  • 博客网站素材廊坊百度快照优化排名
  • 张家界优秀网站建设谷歌chrome手机版
  • web表单制作windows优化大师的作用
  • 中山古镇做网站域名被墙污染查询
  • 网站动态和静态的区别软文素材网站
  • vb链接网站怎么做seo管理软件
  • 山东省作风建设网站全网营销系统1700元真实吗
  • aspnet东莞网站建设价格电商平台开发
  • 一个域名两个网站百度收录提交入口
  • 南充商城网站建设域名注册新网
  • 网站定位授权开启权限怎么做设计网站排行
  • 洛阳响应式网站建设宣传软文范例
  • 新手如何自己建网站软文推广公司
  • 北京最有名的广告公司有哪些吉林seo基础
  • 北方明珠网站建设在线培训管理系统
  • 长春做网站哪家好百度提问登陆入口
  • 哈尔滨制作网站seo优化排名服务