第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

Consul&Nginx&Registrator&ConsulTemplate部署高可用負(fù)載均衡

1. Consul Server

创建consul server虚拟主机

docker-machine create consul

出现如下内容即创建成功

Running pre-create checks...
Creating machine...
(consul) Copying /Users/enoch/.docker/machine/cache/boot2docker.iso to /Users/enoch/.docker/machine/machines/consul/boot2docker.iso...
(consul) Creating VirtualBox VM...
(consul) Creating SSH key...
(consul) Starting the VM...
(consul) Check network to re-create if needed...
(consul) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env consul

创建工作目录consul

mkdir -p ~/workspace/consul && cd ~/workspace/consul

创建docker-compose.yml

version: "3"

services:
  consul:
    image: consul:latest
    ports:
      - 8500:8500
    command: agent -server -bootstrap -ui -client=0.0.0.0 -node=server01

切换环境到consul

eval $(docker-machine env consul)

执行docker-compose.yml

docker-compose up -d

查看虚拟主机IP

docker-machine ip consul
# output 192.168.99.103

通过IP在浏览器访问8500端口,即可看到Consul的UI界面

图片描述

2. Nginx + Consul Template

创建反向代理虚拟主机

docker-machine create reverseproxy

出现以下内容代表创建成功

Running pre-create checks...
Creating machine...
(reverseproxy) Copying /Users/enoch/.docker/machine/cache/boot2docker.iso to /Users/enoch/.docker/machine/machines/reverseproxy/boot2docker.iso...
(reverseproxy) Creating VirtualBox VM...
(reverseproxy) Creating SSH key...
(reverseproxy) Starting the VM...
(reverseproxy) Check network to re-create if needed...
(reverseproxy) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env reverseproxy

切换当前环境到虚拟主机

eval $(docker-machine env reverseproxy)

创建工作目录reverseproxy

mkdir -p ~/workspace/reverseproxy && cd ~/workspace/reverseproxy

创建docker-compose.yml

version: "3"

services:
  nginx:
    image: nginx:latest
    ports:
      - 8081:80
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./conf.d:/etc/nginx/conf.d

  consul-template:
    image: hashicorp/consul-template:alpine
    volumes:
      - ./conf.d:/etc/nginx/conf.d
    command: consul-template --consul-addr 192.168.99.103:8500 --template "/etc/nginx/conf.d/nginx.ctmpl:/etc/nginx/conf.d/vhost.conf" --log-level=info

把容器跑起来

docker-compose up -d

查看IP

docker-machine ip reverseproxy
# output 192.168.99.102

浏览器访问reverseproxy的8081端口,出现如下内容代表启动成功

图片描述

3. Webserver搭建

创建虚拟主机webserver1

docker-machine create webserver1
eval $(docker-machine env webserver1)
mkdir webserver1 & cd webserver1

创建docker—compose.yml

version: "3"

services:

  nginx1:
    image: nginx:latest
    ports:
      - 81:80

  nginx2:
    image: nginx:latest
    ports:
      - 82:80

  registrator:
    image: shaharil/registrator:latest
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock
    command: consul://192.168.99.103:8500

跑起来

docker-compose up -d

打开reverseproxy/conf.d/vhost.conf可以看到webserver启动的nginxIP地址都被加了进去

upstream http_backend {
    
    server 172.18.0.2:81;
    
    server 172.18.0.3:82;
    
}

server {
    listen 8000;
    server_name localhost;
    location / {
        proxy_pass http://http_backend;
    }
}

做个试验,现在将其中一台nginx容器关闭

eval $(docker-machine env webserver1)
docker stop webserver1_nginx2_1

此时可以看到vhost.conf中的IP被去掉了

upstream http_backend {
    
    server 172.18.0.2:81;
    
}

server {
    listen 8000;
    server_name localhost;
    location / {
        proxy_pass http://http_backend;
    }
}

再将nginx容器打开,该容器的IP地址随之也会被加进去

docker start webserver1_nginx2_1

//以下是文件内容
upstream http_backend {
    
    server 172.18.0.2:81;
    
}

server {
    listen 8000;
    server_name localhost;
    location / {
        proxy_pass http://http_backend;
    }
}
點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫(xiě)下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶(hù)
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專(zhuān)欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消