代码拉取完成,页面将自动刷新
version: '3'
networks:
byfn:
byfn1:
services:
etcd1:
image: quay.io/coreos/etcd:v3.5.0-rc.1
container_name: etcd1
command: etcd -name etcd1 -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster -initial-cluster "etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380,etcd4=http://etcd4:2380" -initial-cluster-state new
ports:
- "12379:2379"
- "12380:2380"
networks:
- byfn
etcd2:
image: quay.io/coreos/etcd:v3.5.0-rc.1
container_name: etcd2
command: etcd -name etcd2 -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster -initial-cluster "etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380,etcd4=http://etcd4:2380" -initial-cluster-state new
ports:
- "22379:2379"
- "22380:2380"
networks:
- byfn
etcd3:
image: quay.io/coreos/etcd:v3.5.0-rc.1
container_name: etcd3
command: etcd -name etcd3 -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster -initial-cluster "etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380,etcd4=http://etcd4:2380" -initial-cluster-state new
ports:
- "32379:2379"
- "32380:2380"
networks:
- byfn
etcd4:
image: quay.io/coreos/etcd:v3.5.0-rc.1
container_name: etcd4
command: etcd -name etcd4 -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster -initial-cluster "etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380,etcd4=http://etcd4:2380" -initial-cluster-state new
ports:
- "42379:2379"
- "42380:2380"
networks:
- byfn
go run order/main.go 8881
:服务一
go run order/main.go 8882
:服务二
go run order/main.go 8883
:服务三
服务提供2个接口,info
和 list
go run api/rpc.go
访问 http://localhost:8807/info
调用服务info接口
访问 http://localhost:8807/list
调用服务list接口
会以轮询的方式分别调用:服务一,服务二,服务三,返回结果中包含服务的地址端口信息
结束上面三个服务之一,api调用中会自动剔除结束掉的服务,并不影响。(服务异常退出或死掉)
增加服务四,api调用中会增加服务四的调用轮询。(达到随时扩容)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。