003.etcd集群部署-静态发现
一 etcd集群概述
1.1 概述
1.2 集群容错能力
集群大小
|
最大容错
|
1
|
0
|
2
|
1
|
4
|
1
|
5
|
2
|
6
|
2
|
7
|
3
|
8
|
3
|
9
|
4
|
1.3 集群基础
1.4 引导机制
- 静态的
- etcd Discovery
- DNS发现
二 集群部署-静态
2.1 环境准备
名称
|
地址
|
主机名
|
备注
|
etcd1
|
172.24.8.31
|
etcd1.example.com
|
|
etcd2
|
172.24.8.32
|
etcd2.example.com
|
|
etcd3
|
172.24.8.33
|
etcd3.example.com
|
1 # hostnamectl set-hostname etcd1.example.com
2 # hostnamectl set-hostname etcd2.example.com
3 # hostnamectl set-hostname etcd3.example.com
4 # vi /etc/hosts
5 #……
6 172.24.8.31 etcd1.example.com
7 172.24.8.32 etcd2.example.com
8 172.24.8.33 etcd3.example.com
2.2 安装etcd
1 # ETCD_VER=v3.3.9
2 # GITHUB_URL=https://github.com/coreos/etcd/releases/download
3 # DOWNLOAD_URL=${GITHUB_URL}
4 # rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
5 # rm -rf /tmp/etcd-download-test
6 # mkdir -p /tmp/etcd-download-test #创建下载保存目录
7 # curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
8 # tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1
9 # cp /tmp/etcd-download-test/etcd /usr/local/bin/
10 # cp /tmp/etcd-download-test/etcdctl /usr/local/bin/
11 # rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
12
13 # rm -rf /tmp/etcd-download-test/
14 # ETCDCTL_API=3
15 # etcd --version
16 # etcdctl --version #查看已安装版本
2.3 启动前准备
1 # mkdir -p /var/log/etcd/ #建议创建etcd日志保存目录
2 # mkdir -p /data/etcd #建议创建单独的etcd数据目录
2.4 启动集群
1 [root@etcd1 ~]# etcd --name etcd1 --data-dir /data/etcd \
2 --initial-advertise-peer-urls http://172.24.8.31:2380 \
3 --listen-peer-urls http://172.24.8.31:2380 \
4 --listen-client-urls http://172.24.8.31:2379,http://127.0.0.1:2379 \
5 --advertise-client-urls http://172.24.8.31:2379 \
6 --initial-cluster-token etcd-cluster-1 \
7 --initial-cluster etcd1=http://172.24.8.31:2380,etcd2=http://172.24.8.32:2380,etcd3=http://172.24.8.33:2380 \
8 --initial-cluster-state new
1 [root@etcd2 ~]# etcd --name etcd2 --data-dir /data/etcd \
2 --initial-advertise-peer-urls http://172.24.8.32:2380 \
3 --listen-peer-urls http://172.24.8.32:2380 \
4 --listen-client-urls http://172.24.8.32:2379,http://127.0.0.1:2379 \
5 --advertise-client-urls http://172.24.8.32:2379 \
6 --initial-cluster-token etcd-cluster-1 \
7 --initial-cluster etcd1=http://172.24.8.31:2380,etcd2=http://172.24.8.32:2380,etcd3=http://172.24.8.33:2380 \
8 --initial-cluster-state new
9
10 [root@etcd3 ~]# etcd --name etcd3 --data-dir /data/etcd \
11 --initial-advertise-peer-urls http://172.24.8.33:2380 \
12 --listen-peer-urls http://172.24.8.33:2380 \
13 --listen-client-urls http://172.24.8.33:2379,http://127.0.0.1:2379 \
14 --advertise-client-urls http://172.24.8.33:2379 \
15 --initial-cluster-token etcd-cluster-1 \
16 --initial-cluster etcd1=http://172.24.8.31:2380,etcd2=http://172.24.8.32:2380,etcd3=http://172.24.8.33:2380 \
17 --initial-cluster-state new
1 [root@etcd1 ~]# vi /root/startetcd.sh
2 #!/bin/sh
3 #****************************************************************#
4 # ScriptName: /root/startetcd.sh
5 # Author: Xiang Hongying
6 # Create Date: 2018-09-10 01:14
7 # Modify Author: Xiang Hongying
8 # E-Mail: x120952576@126.com
9 # Version:
10 #***************************************************************#
11 LOGFILE=/var/log/etcd/etcd.log
12 /usr/local/bin/etcd --name etcd1 --data-dir /data/etcd \
13 --initial-advertise-peer-urls http://172.24.8.31:2380 \
14 --listen-peer-urls http://172.24.8.31:2380 \
15 --listen-client-urls http://172.24.8.31:2379,http://127.0.0.1:2379 \
16 --advertise-client-urls http://172.24.8.31:2379 \
17 --initial-cluster-token etcd-cluster-1 \
18 --initial-cluster etcd1=http://172.24.8.31:2380,etcd2=http://172.24.8.32:2380,etcd3=http://172.24.8.33:2380 \
19 -initial-cluster-state new >> $LOGFILE 2>&1 &
20 [root@etcd1 ~]# chmod u+x startetcd.sh
2.5 集群健康检测
1 [root@etcd1 ~]# etcdctl cluster-health

附录:使用systemd管理etcd。
1 [root@etcd1 ~]# vi /lib/systemd/system/etcd.service
2 [Unit]
3 Description=etcd
4 Documentation=https://github.com/coreos/etcd
5 Conflicts=etcd.service
6
7 [Service]
8 Type=notify
9 Restart=always
10 RestartSec=5s
11 LimitNOFILE=40000
12 TimeoutStartSec=0
13
14 ExecStart=/usr/local/bin/etcd --name etcd1 --data-dir /data/etcd \
15 --initial-advertise-peer-urls http://172.24.8.31:2380 \
16 --listen-peer-urls http://172.24.8.31:2380 \
17 --listen-client-urls http://172.24.8.31:2379,http://127.0.0.1:2379 \
18 --advertise-client-urls http://172.24.8.31:2379 \
19 --initial-cluster-token etcd-cluster-1 \
20 --initial-cluster etcd1=http://172.24.8.31:2380,etcd2=http://172.24.8.32:2380,etcd3=http://172.24.8.33:2380 \
21 --initial-cluster-state new
22
23 [Install]
24 WantedBy=multi-user.target
25 [root@etcd1 ~]# systemctl daemon-reload
26 [root@etcd1 ~]# systemctl start etcd.service
27 [root@etcd1 ~]# systemctl enable etcd.service
2.6 关闭集群
1 [root@etcd1 ~]# systemctl stop etcd
三 集群管理
3.1 集群成员检测
1 [root@etcd1 ~]# etcdctl member list

3.2 更新成员url
1 [root@etcd3 ~]# ifconfig eth0
2 inet 172.24.8.40
3 [root@etcd3 ~]# vi /lib/systemd/system/etcd.service #将所有旧IP改为最新IP。
1 [root@etcd3 ~]# systemctl restart etcd
2 [root@etcd1 ~]# etcdctl member list #在leader节点查看所有节点

1 [root@etcd1 ~]# etcdctl member update 14ff148c62a24fb2 http://172.24.8.40:2380 #更新对等url

3.3 添加新成员
1 [root@localhost ~]# hostnamectl set-hostname etcd4.example.com
1 [root@etcd1 ~]# etcdctl member add etcd4 http://172.24.8.34:2380

1 [root@etcd4 ~]# export ETCD_NAME="etcd4"
2 [root@etcd4 ~]# export ETCD_INITIAL_CLUSTER="etcd4=http://172.24.8.34:2380,etcd3=http://172.24.8.40:2380,etcd1=http://172.24.8.31:2380,etcd2=http://172.24.8.32:2380"
3 [root@etcd4 ~]# export ETCD_INITIAL_CLUSTER_STATE="existing"
4 [root@etcd4 ~]# etcd --listen-client-urls http://172.24.8.34:2379,http://127.0.0.1:2379 --advertise-client-urls http://172.24.8.34:2379 --listen-peer-urls http://172.24.8.34:2380 --initial-advertise-peer-urls http://172.24.8.34:2380 --data-dir /data/etcd
5 [root@etcd1 ~]# etcdctl member list
6 [root@etcd1 ~]# etcdctl cluster-health

1 # rm -rf /var/lib/etcd/default.etcd/
2 # systemctl start etcd
3.4 删除成员
1 [root@etcd1 ~]# etcdctl member remove 5a6397499417250
2 Removed member 5a6397499417250 from cluster

四 集群部署-发现
003.etcd集群部署-静态发现的更多相关文章
- 004.etcd集群部署-动态发现
一 etcd发现简介 1.1 需求背景 在实际环境中,集群成员的ip可能不会提前知道.如使用dhcp自动获取的情况,在这些情况下,使用自动发现来引导etcdetcd集群,而不是指定静态配置,这个过程被 ...
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之自签TLS证书及Etcd集群部署(二)
0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.服务器设置 1.把每一 ...
- etcd集群部署与遇到的坑(转)
原文 https://www.cnblogs.com/breg/p/5728237.html etcd集群部署与遇到的坑 在k8s集群中使用了etcd作为数据中心,在实际操作中遇到了一些坑.今天记录一 ...
- 005.基于docker部署etcd集群部署
一 环境准备 ntp配置:略 #建议配置ntp服务,保证时间一致性 etcd版本:v3.3.9 防火墙及SELinux:关闭防火墙和SELinux 名称 地址 主机名 备注 etcd1 172.24. ...
- etcd集群部署
etcd是用于共享配置和服务发现的分布式KV存储系统,随着CoreOS和Kubernetes等项目在开源社区日益火热,它们都用到了etcd组件作为一个高可用.强一致性的服务发现存储仓库.操作系统版本: ...
- Kubernetes集群部署之三ETCD集群部署
kuberntes 系统使用 etcd 存储所有数据,本文档介绍部署一个三节点高可用 etcd 集群的步骤,这三个节点复用 kubernetes 集群机器k8s-master.k8s-node-1.k ...
- K8s集群部署(一)------ETCD集群部署
环境说明 三台主机: k8s-master 10.0.3.225 k8s-node1 10.0.3.226 k8s-node2 10.0.3.227 配置主机名解析 [root@k8s- ...
- etcd集群部署与遇到的坑
在k8s集群中使用了etcd作为数据中心,在实际操作中遇到了一些坑.今天记录一下,为了以后更好操作. ETCD参数说明 —data-dir 指定节点的数据存储目录,这些数据包括节点ID,集群ID,集群 ...
- etcd 集群部署
etcd web管理 https://nikfoundas.github.io/etcd-viewer/ # git clone https://github.com/nikfoundas/etcd- ...
随机推荐
- Confluence 6 为空白空间重置原始默认内容
希望重置为原始的默认内容: 在屏幕的右上角单击 控制台按钮 ,然后选择 General Configuration 链接. 在左侧的面板中选择 全局模板和蓝图(Global Templates and ...
- 简化版的AXI-LITE4和配合使用的RTL
////////////////////////////////////////////////////////////////////////////////// // // The ZYNQ FI ...
- Android 基础 二 四大组件 Activity
Activity Intent IntentFilter 一理论概述 一. Activity 用来提供一个能让用户操作并与之交互的界面. 1.1 启动 startActivity(Intent int ...
- PDF如何添加水印,PDF添加水印工具的使用方法
PDF文件在编辑修改的时候是需要借助工具才可以编辑,PDF文件不像普通的文件可以直接打开编辑,PDF编辑工具是PDF文件进行编辑的重要工具,就以添加水印为例,能够在PDF中添加水印的工具有哪些呢?要怎 ...
- lightoj 1282 取对数的操作
/* 前三位 len=log10n^k(乘积的长度) len=klog10n n^k=x*10^(len-1) x=n^k/10^(len-1) log10x = k*log10n - (len-1) ...
- 阿里云服务器配置SSL证书成功开启Https(记录趟过的各种坑)
环境: 阿里云云服务器 Windows Server 2008 标准版 SP2 中文版(趁1212优惠买的一年的水货配置) 阿里云购买的域名(已备案.已解析) 服务器:phpstudy:php5 ...
- XMind思维导图使用笔记
首先新建一个空白的图 以组织结构图(向下) 为例 1.双击组织结构图 创建一个空白的页面 2.随便选择一个风格 这时候出现工作台 现在里面只有一个中心主题 正文部分开始 1.如果想要添加一个子主题 ...
- Centos7搭建dhcp服务器
实验拓扑: 实验步骤如下: 1.挂载本地镜像,并安装dhcp组件. 2.更改配置文件,并重启服务. . 3.配置dhcp地址池范围 4.配置防火墙 结果:在客户端上,重启网卡,后查看ip
- chart API笔记
1. 参数说明 http://chart.apis.google.com/chart? chs=250x100 &chd=t:60,40 &cht=p3 &chl=Hello| ...
- dump增加的表数据
备份mysql数据库表中,增加的部分 前提条件: 备份库和正式库表结构一样: 表名不一样可以改: 备份库:192.168.1.10 正式库:192.168.1.11 获取当前"备份" ...