etcd跨机房部署方案
使用ETCD做为元数据方便快捷,但是谈到跨机房灾备可能就迷糊了,我们在做节日灾备的时候同样遇到了问题, 通过查阅官方文档找到了解决方案,官方提供make-mirror方法,提供数据镜像服务
注意: make-mirror 的使用需要依赖于API版本3, 使用API2的无法通过该工具做数据同步
有关ETCD的编译安装这里就不在说明了, 不明白的可以参考官方说明:https://github.com/coreos/etcd
1. 启动集群1
#!/bin/bash nohup etcd --name infra1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:12380 --initial-advertise-peer-urls http://127.0.0.1:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof & nohup etcd --name infra2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 --initial-advertise-peer-urls http://127.0.0.1:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof & nohup etcd --name infra3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 --initial-advertise-peer-urls http://127.0.0.1:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof &
通过命令向集群1中写入数据
export ETCDCTL_API=
etcdctl put t1 v1 --endpoints=127.0.0.1:,127.0.0.1:,127.0.0.1:
etcdctl put t2 v2 --endpoints=127.0.0.1:,127.0.0.1:,127.0.0.1:
etcdctl put t3 v3 --endpoints=127.0.0.1:,127.0.0.1:,127.0.0.1:
etcdctl put t4 v4 --endpoints=127.0.0.1:,127.0.0.1:,127.0.0.1:
2. 启动集群2
#!/bin/bash nohup etcd --name infra4 --listen-client-urls http://127.0.0.1:12479 --advertise-client-urls http://127.0.0.1:12479 --listen-peer-urls http://127.0.0.1:12480 --initial-advertise-peer-urls http://127.0.0.1:12480 --initial-cluster-token etcd-cluster-2 --initial-cluster 'infra4=http://127.0.0.1:12480,infra5=http://127.0.0.1:22480,infra6=http://127.0.0.1:32480' --initial-cluster-state new --enable-pprof & nohup etcd --name infra5 --listen-client-urls http://127.0.0.1:22479 --advertise-client-urls http://127.0.0.1:22479 --listen-peer-urls http://127.0.0.1:22480 --initial-advertise-peer-urls http://127.0.0.1:22480 --initial-cluster-token etcd-cluster-2 --initial-cluster 'infra4=http://127.0.0.1:12480,infra5=http://127.0.0.1:22480,infra6=http://127.0.0.1:32480' --initial-cluster-state new --enable-pprof & nohup etcd --name infra6 --listen-client-urls http://127.0.0.1:32479 --advertise-client-urls http://127.0.0.1:32479 --listen-peer-urls http://127.0.0.1:32480 --initial-advertise-peer-urls http://127.0.0.1:32480 --initial-cluster-token etcd-cluster-2 --initial-cluster 'infra4=http://127.0.0.1:12480,infra5=http://127.0.0.1:22480,infra6=http://127.0.0.1:32480' --initial-cluster-state new --enable-pprof &
3. 使用 make-mirror同步数据
#export ETCDCTL_API=;
#etcdctl make-mirror --no-dest-prefix=true 127.0.0.1: --endpoints=127.0.0.1:,127.0.0.1:,127.0.0.1: --insecure-skip-tls-verify=true
4. 查看集群2的数据
export ETCDCTL_API=;etcdctl get t1 t99 --endpoints=127.0.0.1:,127.0.0.1:,127.0.0.1:
通过以上命令发现集群1和集群2的数据已经完全同步了, etcdctl make-mirror 代码里面数据同步打印的周期是30s一次, 可以通过日志查看已经同步数据的数量。
etcd跨机房部署方案的更多相关文章
- Linux实战教学笔记48:openvpn架构实施方案(一)跨机房异地灾备
第一章VPN介绍 1.1 VPN概述 VPN(全称Virtual Private Network)虚拟专用网络,是依靠ISP和其他的NSP,在公共网络中建立专用的数据通信网络的技术,可以为企业之间或者 ...
- mongodb在双活(主备)机房的部署方案和切换方案设计
1. 概述 现在很多高可用系统为了应对极端情况,比如主机宕机.网络故障以及机房宕机等灾难的发生,通常会部署主备架构(双机房),或者双活架构(双机房),甚至多活架构(三个机房或者以上),mongodb天 ...
- vitess元数据跨机房灾备解决方案
测试使用vitess的时候发现vitess元数据的实现有多种方案,etcd, etcd2, zk,zk2, 由于刚开始测试的时候使用的是基于k8s集群+etcd的,以下就分步说明灾备实现方案: 1. ...
- 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目
最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...
- SQL Server 跨网段(跨机房)复制
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搭建过程(Process) 注意事项(Attention) 参考 ...
- 转: 微博的多机房部署的实践(from infoq)
转: http://www.infoq.com/cn/articles/weibo-multi-idc-architecture 在国内网络环境下,单机房的可靠性无法满足大型互联网服务的要求,如机房 ...
- Step4:SQL Server 跨网段(跨机房)复制
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搭建过程(Process) 注意事项(Attention) 参考 ...
- 禧云Redis跨机房双向同步实践
编者荐语: 2019年4月16日跨机房Redis同步中间件(Rotter)上线,团餐率先商用: 以下文章来源于云纵达摩院 ,作者杨海波 禧云信息/研发中心/杨海波 20191115 关键词:Rot ...
- 线上SpringCloud网关调用微服务跨机房了,咋整?
1.前言 公司内考虑到服务器资源成本的问题,目前业务上还在进行服务的容器化改造和迁移,计划将容器化后的服务,以及一些中间件(MQ.DB.ES.Redis等)尽量都迁移到其他机房. 那你们为什么不用阿里 ...
随机推荐
- linux任务计划cron
linux任务计划cron 1.crontab命令任务计划配置文件 [root@bogon ~]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/ ...
- offsetof宏的实现
1.c语言的结构体中,因为字节对齐的问题,导致成员地址并不能根据类型的大小进行计算.例如: struct test { char ch; int a; } printf("test的大小=% ...
- strlen函数实现
原型: int strlen(const char *s); 作用:返回字符串的长度. 方法1:利用中间变量 int strlen(const char *s){ ; while(s[i] != '\ ...
- delete void *
看代码的时候看到 typedef char xxx[sizeof(T) ? 1 : -1]; 这种语句 如:JavaScriptCore/wtf/OwnPtrCommon.h template < ...
- PHP QR Code - QR code generator, an LGPL PHP library
http://phpqrcode.sourceforge.net/examples/index.php http://phpqrcode.sourceforge.net/examples/index. ...
- root-me web server 20-30 writeup
Remote File Inclusion-远程文件包含 Get the PHP source code. ctrl+u 进行RFI攻击需要同时具备三个条件(被攻击机器): allow_url_fop ...
- shell变量自增 || Python脚本接收参数
一.shell变量自增a=1a=$(($a+1))a=$[$a+1]a=`expr $a + 1`let a++ let a+=1 ((a++)) echo $a 二.python脚本接收参数 fro ...
- node.js和前端js有什么区别
进行前端开发工作需要掌握技能有html. css.js以及各种前端框架,把这些技术玩6就可以成为一名合格的前端开发工作者 而进行nodejs开发,需要掌握js.web服务器原理.关系数据使用, 如果玩 ...
- android Bitmap用法总结(转载)
Bitmap用法总结1.Drawable → Bitmappublic static Bitmap drawableToBitmap(Drawable drawable) {Bitmap bitmap ...
- java 关键字static
在Java中static表示“全局”或者“静态”的意思,用来修饰成员变量和成员方法,当然也可以修饰代码块. Java把内存分为栈内存和堆内存, 栈内存用来存放一些基本类型的变量.数组和对象的引用, 堆 ...