Go游戏服务器开发的一些思考(二十):Docker Swarm部署Etcd示例
来源:互联网 发布:javascript实战.pdf 编辑:程序博客网 时间:2024/05/28 23:22
静态配置方式部署Etcd集群
在部署Etcd集群时,可以通过给每个etcd实例配置etcd集群所有IP的方式来部署。
这种方式,不是很灵活。比如 换机器、IP变了、机器当机等等,都会破坏这种部署配置。
而通过 Docker Swarm方式,可以完美解决上述问题。
使得即便是静态配置,也可以通过Docker Swarm自身,让etcd进程失效时,自动在Docker Swarm所管理的机器群上自动切换。从而保持Etcd集群的有效性
Docker Swarm编排脚本示例
version: "3"services: etcd1: image: quay.io/coreos/etcd deploy: placement: constraints: [node.role == worker] replicas: 1 restart_policy: condition: on-failure ports: - "12379:2379" - "12380:2380" volumes: - data1:/etcd-data networks: - net command: /usr/local/bin/etcd --data-dir=/etcd-data --name node1 --initial-advertise-peer-urls http://etcd1:2380 --listen-peer-urls http://0.0.0.0:2380 --advertise-client-urls http://etcd1:2379 --listen-client-urls http://0.0.0.0:2379 --initial-cluster "node1=http://etcd1:2380,node2=http://etcd2:2380,node3=http://etcd3:2380" --initial-cluster-token my-etcd-token --initial-cluster-state new etcd2: image: quay.io/coreos/etcd deploy: placement: constraints: [node.role == worker] replicas: 1 restart_policy: condition: on-failure ports: - "22379:2379" - "22380:2380" volumes: - data2:/etcd-data networks: - net command: /usr/local/bin/etcd --data-dir=/etcd-data --name node2 --initial-advertise-peer-urls http://etcd2:2380 --listen-peer-urls http://0.0.0.0:2380 --advertise-client-urls http://etcd2:2379 --listen-client-urls http://0.0.0.0:2379 --initial-cluster "node1=http://etcd1:2380,node2=http://etcd2:2380,node3=http://etcd3:2380" --initial-cluster-token my-etcd-token --initial-cluster-state new etcd3: image: quay.io/coreos/etcd deploy: placement: constraints: [node.role == worker] replicas: 1 restart_policy: condition: on-failure ports: - "32379:2379" - "32380:2380" volumes: - data3:/etcd-data networks: - net command: /usr/local/bin/etcd --data-dir=/etcd-data --name node3 --initial-advertise-peer-urls http://etcd3:2380 --listen-peer-urls http://0.0.0.0:2380 --advertise-client-urls http://etcd3:2379 --listen-client-urls http://0.0.0.0:2379 --initial-cluster "node1=http://etcd1:2380,node2=http://etcd2:2380,node3=http://etcd3:2380" --initial-cluster-token my-etcd-token --initial-cluster-state newnetworks: net:volumes: data1: data2: data3:
Etcd发现方式部署Etcd集群
篇幅关系,略之。
详细可以参见 go-discovery开源库,github地址:
https://github.com/fananchong/go-discovery
阅读全文
1 0
- Go游戏服务器开发的一些思考(二十):Docker Swarm部署Etcd示例
- Go游戏服务器开发的一些思考(二十五):Redis的Docker Swarm部署
- Go游戏服务器开发的一些思考(六):Docker Swarm Mode
- Go游戏服务器开发的一些思考(九):Docker桥接网络及固定IP (二)
- Go游戏服务器开发的一些思考(十八):Docker内网环境搭建(备忘)
- Go游戏服务器开发的一些思考(八):Docker桥接网络及固定IP
- Go游戏服务器开发的一些思考(二十一):Go语言的两处脑残设定
- Go游戏服务器开发的一些思考(二十三):Go语言Log库封装技巧
- Go游戏服务器开发的一些思考(二十六):Go Redis ORM库
- Go游戏服务器开发的一些思考(十):goroutine和coroutine
- Go游戏服务器开发的一些思考(十四):IO游戏同步(二)
- Go游戏服务器开发的一些思考(二):综合考察(上)
- Go游戏服务器开发的一些思考(二十二):Godep包管理介绍
- Go游戏服务器开发的一些思考(二十四):命令行库封装技巧
- Go游戏服务器开发的一些思考(七):Redis
- Go游戏服务器开发的一些思考(十六):IO游戏服务器架构
- Go游戏服务器开发的一些思考(十七):IO游戏同步(三)
- Go游戏服务器开发的一些思考(十一):IO游戏同步
- VIM的高级配置一#VIM的安装
- nginx强制使用https访问(http跳转到https)
- 《软件开发者路线图—从学徒到高手》读书笔记
- 双重锁单例模式 观察者模式
- javaWeb--struts2框架之二解释
- Go游戏服务器开发的一些思考(二十):Docker Swarm部署Etcd示例
- Android studio 多渠道打包
- 生命的诠释
- 【笔记】内部排序算法
- stl中二分查找相关的函数
- leetcode 27.Remove Element
- 最全的vim图解教程
- C++读写文件
- Mybatis配置之<mappers>元素详述