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

网站建设后台是什么wordpress修改ftp

网站建设后台是什么,wordpress修改ftp,智慧校园平台,怎么用链接进自己做的网站前言 Docker Compose 则进一步简化了多个容器应用的编排与管理。另一方面#xff0c;Consul 作为一款先进的服务发现工具#xff0c;为分布式和微服务架构提供了可靠的服务注册与发现机制。本文将探讨 Docker Compose 和 Consul 在容器化环境中的协同作用#xff0c;以及它…前言 Docker Compose 则进一步简化了多个容器应用的编排与管理。另一方面Consul 作为一款先进的服务发现工具为分布式和微服务架构提供了可靠的服务注册与发现机制。本文将探讨 Docker Compose 和 Consul 在容器化环境中的协同作用以及它们如何共同帮助开发人员更高效地构建、部署和管理其应用程序。 Docker Compose相关介绍请参考 Docker-Compose单机多容器应用编排与管理-CSDN博客 目录 一、概述 1. 服务注册与发现 2. 什么是 consul 3. 服务架构 3.1 传统架构 3.2 consul 架构 4. 关键特性 二、Consul 部署 1. 容器服务更新与发现拓扑图 2. 部署信息 3. consul 服务器 3.1 建立 consul 服务 3.2 查看集群信息 3.3 通过 http api 获取集群信息 4. registrator 服务器 4.1 安装 Gliderlabs/Registrato 4.2 测试服务发现功能是否正常 4.3 验证 http 和 nginx 服务是否注册到 consul  5. consul-template  5.1 准备 template nginx 模板文件 5.2 安装配置 nginx 服务 5.3 配置并启动 template 5.4 访问 template-nginx 5.5 增加一个 nginx 容器节点 6. consul 多节点 6.1 安装 docker  6.2 拷贝 consul 相关服务文件启动 consul 服务 6.3 查看集群信息 一、概述 1. 服务注册与发现 ① 服务注册在Docker中运行的应用程序可以通过Consul客户端向Consul服务注册自己的信息包括服务名称、IP地址、端口号等。这样Consul就会维护一个服务目录记录着所有可用的服务实例及其位置信息。 ② 服务发现其他Docker容器或应用程序可以通过Consul客户端查询Consul服务注册中心动态地发现和连接到需要的服务。Consul根据服务名称、标签、健康状态等条件来选择合适的服务实例实现服务间的通信和协作。 2. 什么是 consul Consul 是一种开源的服务发现和配置管理工具由 HashiCorp 开发。它提供了一系列功能包括服务注册、服务发现、健康检查、KV存储等旨在简化构建和管理分布式系统的过程。 ① 服务注册与发现Consul 允许服务实例向 Consul 注册其信息包括服务名称、网络位置IP地址和端口号、健康状态等。其他服务或客户端可以通过 Consul 查询服务注册中心动态地发现和连接到需要的服务从而实现服务间的通信。 ② 健康检查Consul 可以定期对服务实例进行健康检查以确保服务的可用性。如果一个服务实例不健康Consul 会将其标记为不可用同时通知其他服务实例进行相应的调整保证系统的稳定性。 ③ KV 存储Consul 提供了一个分布式的键值存储系统允许用户存储和检索配置信息、应用程序状态等。这个功能对于动态配置和共享状态在分布式系统中是非常有用的。 ④ 多数据中心支持Consul 支持多数据中心部署可以轻松地在不同地理位置的数据中心中管理和发现服务提高系统的可用性和容错性。 3. 服务架构 3.1 传统架构 在 upstream 块中需要指定后端服务器的 IP 地址和端口号即 ip:port在proxy_pass指令中需要指定转发请求的目标 当需要添加新的后端服务器时需要修改代理端配置文件且需要重启服务才可以生效有一定的局限性。 3.2 consul 架构 后端服务 A-N 可以把当前自己的网络位置注册到服务发现模块服务发现就以 K-V 的方式记录下来K 一般是服务名V 就是 ip:port。服务发现模块定时的进行健康检查轮询查看这些后端服务能不能访问的了。前端在调用后端服务 A-N 的时候会先询问服务发现模块后端服务的网络位置然后再调用它们的服务。  4. 关键特性 服务注册与发现consul通过DNS或者HTTP接口使服务注册和服务发现变的很容易一些外部服务例如saas提供的也可以一样注册健康检查健康检测使consul可以快速的告警在集群中的操作。和服务发现的集成可以防止服务转发到故障的服务上面Key/Value存储一个用来存储动态配置的系统。提供简单的HTTP接口可以在任何地方操作。多数据中心无需复杂的配置即可支持任意数量的区域。 二、Consul 部署 1. 容器服务更新与发现拓扑图 Consul Template Consul Template守护进程是Consul Template工具的一部分用于监视Consul中的键值存储KV中的变化并根据这些变化来更新本地的配置文件。它可以在后台运行并定期检查Consul中的数据以确保生成的配置文件与最新的配置信息保持同步是一个配置文件模板可以获取注册中心所有的服务发现然后将服务发现的名称:端口号转发给 Nginx并且更新 nginx.conf 文件。 Consul Server 作为注册中心Consul Server 负责维护服务目录记录当前可用的服务实例及其位置信息负责执行健康检查来确保服务的可用性定期检查服务实例的健康状态如果某个服务实例出现故障或不可用Consul会将其标记为不健康并从服务目录中移除同时服务实例新增或者恢复Consul会将其加入到服务目录中提供了KV存储用于存储配置信息、应用程序状态等。这个分布式键值存储可以用于共享配置、动态更新应用程序参数等场景支持事件处理机制可以发布和订阅各种事件例如服务状态变更、健康检查结果等。 Consul Agent 是一个轻量级的代理程序用于运行在每个部署了服务的节点上。它负责与Consul集群通信并执行各种任务包括服务注册、健康检查、服务发现和处理来自其他节点的RPC请求等。  Registrator 是一个服务注册器它是一个独立的进程运行在容器编排环境中它的主要作用是监视运行中的服务实例并将它们注册到服务发现系统中例如Consul或etcd。通过这种注册其他服务可以发现并与这些服务进行通信而无需事先知道它们的位置或IP地址。 2. 部署信息 服务节点ip安装运行服务docker版本consul 服务器192.168.190.107运行consul服务、nginx服务、consul-template守护进程26.0.2registrator 服务器192.168.190.108运行registrator容器、运行nginx容器20.10.17consul 服务器192.168.190.106运行consul服务26.0.2 3. consul 服务器 3.1 建立 consul 服务 ① 二进制包直接安装 [rootconsul ~]# mkdir /opt/consul [rootconsul ~]# cd /opt/consul/ [rootconsul consul]# ls consul_0.9.2_linux_amd64.zip # 准备二进制包 [rootconsul consul]# unzip consul_0.9.2_linux_amd64.zip [rootconsul consul]# mv consul /usr/local/bin/ ② 设置代理后台启动 consul 服务端 [rootconsul consul]# consul agent \-server \-bootstrap \-ui \-data-dir/var/lib/consul-data \-bind192.168.190.107 \-client0.0.0.0 \-nodeconsul-server01 /var/log/consul.log [1] 7694③ 启动 consul 后默认会监听5个端口 [rootconsul consul]# netstat -natp | grep consul tcp 0 0 192.168.190.107:8300 0.0.0.0:* LISTEN 37870/consul tcp 0 0 192.168.190.107:8301 0.0.0.0:* LISTEN 37870/consul tcp 0 0 192.168.190.107:8302 0.0.0.0:* LISTEN 37870/consul tcp6 0 0 :::8500 :::* LISTEN 37870/consul tcp6 0 0 :::8600 :::* LISTEN 37870/consul # 8300replication、leader farwarding的端口 # 8301lan cossip的端口 # 8302wan gossip的端口 # 8500web ui界面的端口 # 8600使用dns协议查看节点信息的端口 3.2 查看集群信息 ① 查看members状态 [rootconsul consul]# consul members Node Address Status Type Build Protocol DC consul-server01 192.168.190.107:8301 alive server 0.9.2 2 dc1② 查看集群状态 [rootconsul consul]# consul operator raft list-peers # 获取Consul集群中Raft协议的节点列表 Node ID Address State Voter RaftProtocol consul-server01 192.168.190.107:8300 192.168.190.107:8300 leader true 2 [rootconsul consul]# consul info | grep leaderleader trueleader_addr 192.168.190.107:8300 3.3 通过 http api 获取集群信息 [rootconsul consul]# curl 127.0.0.1:8500/v1/status/peers [192.168.190.107:8300] # 查看集群server成员 [rootconsul consul]# curl 127.0.0.1:8500/v1/status/leader 192.168.190.107:8300 # 集群 server-leader [rootconsul consul]# curl 127.0.0.1:8500/v1/catalog/services {consul:[]} # 注册的所有服务 [rootconsul consul]# curl 127.0.0.1:8500/v1/catalog/nginx # 查看 nginx 服务信息 [rootconsul consul]# curl 127.0.0.1:8500/v1/catalog/nodes [{ID:f17caaee-ff27-b4e8-c592-afcdad3a2e47,Node:consul-server01,Address:192.168.190.107,Datacenter:dc1,TaggedAddresses:{lan:192.168.190.107,wan:192.168.190.107},Meta:{},CreateIndex:5,ModifyIndex:6}] # 集群节点详细信息 4. registrator 服务器 4.1 安装 Gliderlabs/Registrato Gliderlabs/Registrator 可检查容器运行状态自动注册还可注销 docker 容器的服务到服务配置中心。目前支持 Consul、Etcd 和 SkyDNS2。运行一个 Registrator 容器开启自动发现服务 [rootregistrator ~]# docker run -d \ # 运行Docker容器并将其设置为后台运行--nameregistrator \ # 指定名称为registrator--nethost \ # 使用主机网络模式-v /var/run/docker.sock:/tmp/docker.sock \ # 将主机的Docker守护进程的Unix套接字映射到容器内的/tmp/docker.sock这样Registrator容器就可以与 Docker守护进程通信--restartalways \ # 容器遇到错误或意外退出时自动重启gliderlabs/registrator:latest \ # 使用镜像gliderlabs/registrator来运行容器:latest表示使用最新版本的镜像--ip192.168.190.108 \ # 设置Registrator容器的IP地址为192.168.10.13consul://192.168.190.107:8500 # 192.168.190.107:8500是Consul的地址和端口 4.2 测试服务发现功能是否正常 [rootregistrator ~]# docker run -itd -p:1080:80 --name nginx-01 -h nginx1 nginx [rootregistrator ~]# docker run -itd -p:1081:80 --name nginx-02 -h nginx2 nginx [rootregistrator ~]# docker run -itd -p:1082:80 --name apache-01 -h apache1 httpd [rootregistrator ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3004e92d23e4 httpd httpd-foreground 8 seconds ago Up 7 seconds 0.0.0.0:1082-80/tcp, :::1082-80/tcp apache-01 108612e81495 nginx /docker-entrypoint.… 2 minutes ago Up 2 minutes 0.0.0.0:1081-80/tcp, :::1081-80/tcp nginx-02 dfbfe87308ed nginx /docker-entrypoint.… 2 minutes ago Up 2 minutes 0.0.0.0:1080-80/tcp, :::1080-80/tcp nginx-01 53166bf2c442 gliderlabs/registrator:latest /bin/registrator --… 23 minutes ago Up 23 minutes registrator # 一个发现服务两个容器服务 4.3 验证 http 和 nginx 服务是否注册到 consul  [rootconsul consul]# curl 127.0.0.1:8500/v1/catalog/services {consul:[],httpd:[],nginx:[]} 5. consul-template  Consul-Template是基于Consul的自动替换配置文件的应用。Consul-Template是一个守护进程用于实时查询Consul集群信息并更新文件系统上任意数量的指定模板生成配置文件。更新完成以后可以选择运行 shell 命令执行更新操作重新加载 Nginx。 Consul-Template可以查询Consul中的服务目录、Key、Key-values 等。这种强大的抽象功能和查询语言模板可以使 Consul-Template 特别适合动态的创建配置文件。例如创建Apache/Nginx Proxy Balancers 、 Haproxy Backends等。 5.1 准备 template nginx 模板文件 在consul服务器上操作 [rootconsul consul]# vim /opt/consul/nginx.ctmpl upstream http_backend {{{range service nginx}}server {{.Address}}:{{.Port}};{{end}} } # 定义nginx upstream一个模板server {listen 8000;server_name localhost 192.168.190.107;access_log /var/log/nginx/kgc.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://http_backend;} } # 定义一个server监听8000端口反向代理到upstream5.2 安装配置 nginx 服务 在 consul 节点安装  [rootconsul consul]# yum install -y epel-release.noarch [rootconsul consul]# yum install -y nginx [rootconsul consul]# vim /etc/nginx/nginx.conf http {include vhost/*.conf; # 添加虚拟主机目录创建虚拟主机目录 [rootconsul consul]# cd /etc/nginx/ [rootconsul nginx]# mkdir vhost 启动nginx服务 [rootconsul nginx]# systemctl start nginx.service 5.3 配置并启动 template 在 consul 节点操作  [rootconsul opt]# ls consul-template_0.19.3_linux_amd64.zip # 准备安装包 [rootconsul opt]# unzip consul-template_0.19.3_linux_amd64.zip [rootconsul opt]# mv consul-template /usr/local/bin/在前台启动template服务启动后不要按ctrlc中止consul-template进程 consul-template --consul-addr 192.168.190.107:8500 \ --template /opt/consul/nginx.ctmpl:/etc/nginx/vhost/fqlnginx.conf:/usr/sbin/nginx -s reload \ --log-levelinfo另外打开一个终端查看生成配置文件 [rootconsul opt]# cd /etc/nginx/vhost/ [rootconsul vhost]# ls fqlnginx.conf [rootconsul vhost]# cat fqlnginx.conf upstream http_backend {server 192.168.190.108:1080;server 192.168.190.108:1081;}server {listen 8000;server_name localhost 192.168.190.107;access_log /var/log/nginx/kgc.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://http_backend;} }5.4 访问 template-nginx 在 registrator 节点操作  [rootregistrator ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3004e92d23e4 httpd httpd-foreground 15 hours ago Up 15 hours 0.0.0.0:1082-80/tcp, :::1082-80/tcp apache-01 108612e81495 nginx /docker-entrypoint.… 15 hours ago Up 15 hours 0.0.0.0:1081-80/tcp, :::1081-80/tcp nginx-02 dfbfe87308ed nginx /docker-entrypoint.… 15 hours ago Up 15 hours 0.0.0.0:1080-80/tcp, :::1080-80/tcp nginx-01 53166bf2c442 gliderlabs/registrator:latest /bin/registrator --… 15 hours ago Up 15 hours registrator[rootregistrator ~]# docker exec -it nginx-01 /bin/bash rootnginx1:/# echo this is web1 nginx_01 /usr/share/nginx/html/index.html rootnginx1:/# exit [rootregistrator ~]# docker exec -it nginx-02 /bin/bash rootnginx2:/# echo this is web2 nginx_02 /usr/share/nginx/html/index.html rootnginx2:/# exit 访问 192.168.190.107:8000/ 查看轮询结果 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web1 nginx_01 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web2 nginx_02 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web1 nginx_01 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web2 nginx_02 5.5 增加一个 nginx 容器节点 ① 增加一个 nginx 容器节点测试服务发现及配置更新功能 [rootregistrator ~]# docker run -itd -p:1083:80 --name nginx-03 -h nginx3 nginx # 观察template服务会从模板更新/usr/local/nginx/conf/vhost/kgc.conf文件内容并且重载nginx服务 ② 查看 cousul 节点 template 更新的配置文件内容 [rootconsul vhost]# pwd /etc/nginx/vhost [rootconsul vhost]# ls fqlnginx.conf [rootconsul vhost]# cat fqlnginx.conf upstream http_backend {server 192.168.190.108:1080;server 192.168.190.108:1081;server 192.168.190.108:1083; # 新增了一个nginx服务} …… ③ 访问 192.168.190.107:8000/ 查看轮询结果 [rootregistrator ~]# docker exec -it nginx-03 /bin/bash rootnginx3:/# echo this is web3 nginx_03 /usr/share/nginx/html/index.html rootnginx3:/# exit[rootregistrator ~]# curl http://192.168.190.107:8000 this is web1 nginx_01 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web2 nginx_02 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web3 nginx_03 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web2 nginx_02 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web3 nginx_03 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web1 nginx_01 ④ 停用 nginx-01 服务查看 template 更新的配置文件内容以及轮询结果 [rootregistrator ~]# docker stop nginx-01 nginx-01 [rootregistrator ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a9814459efac nginx /docker-entrypoint.… 6 minutes ago Up 6 minutes 0.0.0.0:1083-80/tcp, :::1083-80/tcp nginx-03 108612e81495 nginx /docker-entrypoint.… 15 hours ago Up 9 minutes 0.0.0.0:1081-80/tcp, :::1081-80/tcp nginx-02 53166bf2c442 gliderlabs/registrator:latest /bin/registrator --… 15 hours ago Up 9 minutes registrator[rootconsul vhost]# cat fqlnginx.conf upstream http_backend {server 192.168.190.108:1081;server 192.168.190.108:1083;} ……[rootregistrator ~]# curl http://192.168.190.107:8000 this is web2 nginx_02 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web3 nginx_03 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web2 nginx_02 [rootregistrator ~]# curl http://192.168.190.107:8000 this is web3 nginx_036. consul 多节点 添加一台 docker 环境的服务器 192.168.190.106/24 加入已有的群集中实际是为了扩展 consul 集群的规模和容量以提高系统的可用性和可靠性。 6.1 安装 docker  安装依赖包 yum install -y yum-utils device-mapper-persistent-data lvm2 设置阿里云镜像源 yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 安装最新版本 yum install -y docker-ce docker-ce-cli containerd.io systemctl start docker.service systemctl enable docker.service 6.2 拷贝 consul 相关服务文件启动 consul 服务 192.168.190.107: [rootconsul vhost]# scp /usr/local/bin/consul 192.168.190.106:/usr/local/bin/ 192.168.190.106: [rootha02 ~]# consul agent \-server \-ui \-data-dir/var/lib/consul-data \-bind192.168.190.106 \ # 指定Consul agent监听的IP地址用于节点间通信-client0.0.0.0 \-nodeconsul-server02 \ # 指定当前节点的名称为consul-server02-enable-script-checkstrue \-datacenterdc1 \ # 指定Consul集群所属的数据中心名称为dc1-join 192.168.190.107 /var/log/consul.log # 加入已知的Consul节点这里指定加入IP地址为192.168.190.107的节点 [1] 31716.3 查看集群信息 查看members状态 [rootha02 ~]# consul members Node Address Status Type Build Protocol DC consul-server01 192.168.190.107:8301 alive server 0.9.2 2 dc1 consul-server02 192.168.190.106:8301 alive server 0.9.2 2 dc1 查看集群状态 [rootha02 ~]# consul operator raft list-peers Node ID Address State Voter RaftProtocol consul-server01 192.168.190.107:8300 192.168.190.107:8300 leader true 2 consul-server02 192.168.190.106:8300 192.168.190.106:8300 follower true 2 # 192.168.190.106状态为follower
http://www.w-s-a.com/news/126035/

相关文章:

  • 郑州网站怎么推广贵阳市网站建设
  • 规范网站建设福州外贸网站建设推广
  • 平台电商网站开发传媒公司排行
  • 在哪给人做网站怎么样制作一个网页
  • 网站更改文章标题广西新闻
  • 专业做网站路桥寺院网站建设方案
  • 网站维护与优化教程广州做网站的网络公司排名
  • 网站做贷款许可证网站改版方案模板
  • 装饰公司怎么做网站嘉兴网站制作推广
  • 深圳兼职做网站涿州网站制作
  • 能找本地人做导游的网站app模板素材下载免费
  • 网站积分的作用网站开发需要看相关书籍
  • 建设银行总行网站alexa排名与什么有关系
  • 阿里云服务器发布网站收款网站怎么建设
  • 开发东莞网站制作公司做网站优化步骤
  • 网站版权信息的正确写法如何制作网络游戏
  • 郑州移动端网站建设如何在网上推广自己的公司
  • 企业建站源码系统破解网站后台
  • 石家庄网站开发报价企业注册资本代表什么
  • 招商平台公司宁波seo教程推广平台
  • 哪些网站可以做房产推广垂直门户网站都有什么
  • 不得不知道的网站金石项目管理软件
  • 怎么恢复网站数据库网站开发作业代做
  • 哪里建设网站最好用中国第五冶金建设公司医院网站
  • 雄安网建 网站建设订餐网站建设
  • 广州视频网站建站公司网站 体系
  • 青浦门户网站网站推广烟台公司电话
  • 湖北荆门建设银行网站wordpress购物模板下载
  • 学ui+wordpress模板北京推广优化
  • 建分类网站得花多少钱深圳设计网站开发