CentOS 部署Etcd集群

一、环境介绍

操作系统信息:CentOS 7 64位

服务器信息:

192.168.80.130  Etcd-master

192.168.80.131  Etcd-node1

192.168.80.132  Etcd-node2

二、部署前准备


1、设置免密登录

  [Master]

[[email protected] ~]# ssh-keygen

[[email protected] ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub Etcd-node1

[[email protected] ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub Etcd-node2

2、所有机器上操作

    a、添加hosts

[[email protected] ~]# 192.168.80.130  Etcd-master

[[email protected] ~]# 192.168.80.131  Etcd-node1

[[email protected] ~]# 192.168.80.132  Etcd-node2

b、同步时间

[[email protected] ~]# yum -y lrzsz git wget python-devel ntp net-tools curl cmake epel-release rpmdevtools openssl-devel kernel-devel gcc redhat-rpm-config bridge-utils

[[email protected] ~]# yum groupinstall "Development Tools" -y

[[email protected] ~]# cp -Rf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

[[email protected] ~]# ntpdate 133.100.11.8

[[email protected] ~]# sed -i ‘s#ZONE="America/New_York"#ZONE="Asia/Shanghai"#g‘ /etc/sysconfig/clock

[[email protected] ~]# hwclock -w

[[email protected] ~]# date -R

三、部署Etcd

[Master]

1、安装及配置Master节点

[[email protected] ~]# yum -y install etcd

[[email protected] ~]# cat /etc/etcd/etcd.conf

# [member]

ETCD_NAME="etcd-master"

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

#ETCD_WAL_DIR=""

#ETCD_SNAPSHOT_COUNT="10000"

#ETCD_HEARTBEAT_INTERVAL="100"

#ETCD_ELECTION_TIMEOUT="1000"

ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:4001,http://0.0.0.0:2379"

#ETCD_MAX_SNAPSHOTS="5"

#ETCD_MAX_WALS="5"

#ETCD_CORS=""

#

#[cluster]

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://etcd-master:2380"

# if you use different ETCD_NAME (e.g. test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test=http://..."

ETCD_INITIAL_CLUSTER="etcd-node1=http://etcd-node1:2380,etcd-node2=http://etcd-node2:2380,etcd-master=http://etcd-master:2380"

ETCD_INITIAL_CLUSTER_STATE="new"

ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"

ETCD_ADVERTISE_CLIENT_URLS="http://Etcd-master:2379,http://Etcd-master:4001"

[Node]

2、安装及配置Node1节点

[[email protected] ~]# yum -y install etcd

[[email protected] ~]# cat /etc/etcd/etcd.conf

# [member]

ETCD_NAME="etcd-node1"

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

#ETCD_WAL_DIR=""

#ETCD_SNAPSHOT_COUNT="10000"

#ETCD_HEARTBEAT_INTERVAL="100"

#ETCD_ELECTION_TIMEOUT="1000"

ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:4001,http://0.0.0.0:2379"

#ETCD_MAX_SNAPSHOTS="5"

#ETCD_MAX_WALS="5"

#ETCD_CORS=""

#

#[cluster]

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://etcd-node1:2380"

# if you use different ETCD_NAME (e.g. test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test=http://..."

ETCD_INITIAL_CLUSTER="etcd-node1=http://etcd-node1:2380,etcd-node2=http://etcd-node2:2380,etcd-master=http://etcd-master:2380"

ETCD_INITIAL_CLUSTER_STATE="new"

ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"

ETCD_ADVERTISE_CLIENT_URLS="http://etcd-node1:2379,http://etcd-node1:4001"

3、安装及配置Node2节点:

[[email protected] ~]# yum -y install etcd

[[email protected] ~]# cat /etc/etcd/etcd.conf

# [member]

ETCD_NAME="etcd-node2"

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

#ETCD_WAL_DIR=""

#ETCD_SNAPSHOT_COUNT="10000"

#ETCD_HEARTBEAT_INTERVAL="100"

#ETCD_ELECTION_TIMEOUT="1000"

ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:4001,http://0.0.0.0:2379"

#ETCD_MAX_SNAPSHOTS="5"

#ETCD_MAX_WALS="5"

#ETCD_CORS=""

#

#[cluster]

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://etcd-node2:2380"

# if you use different ETCD_NAME (e.g. test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test=http://..."

ETCD_INITIAL_CLUSTER="etcd-node1=http://etcd-node1:2380,etcd-node2=http://etcd-node2:2380,etcd-master=http://etcd-master:2380"

ETCD_INITIAL_CLUSTER_STATE="new"

ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"

ETCD_ADVERTISE_CLIENT_URLS="http://etcd-node2:2379,http://etcd-node2:4001"

4、启动Etcd服务

[master]

[[email protected] ~]# systemctl restart etcd

[node1]

[[email protected] ~]# systemctl restart etcd

[node2]

[[email protected] ~]# systemctl restart etcd

5、查看服务状态

[master]

[[email protected] ~]# etcdctl member list

6c74f3fd7534bb5: name=etcd-node1 peerURLs=http://etcd-node1:2380 clientURLs=http://etcd-node1:2379,http://etcd-node1:4001 isLeader=false

a57a17f287dbe7bb: name=etcd-node2 peerURLs=http://etcd-node2:2380 clientURLs=http://etcd-node2:2379,http://etcd-node2:4001 isLeader=true

ffe21a7812eb7c5f: name=etcd-master peerURLs=http://etcd-master:2380 clientURLs= isLeader=false

[node1]

[[email protected] ~]# etcdctl member list

6c74f3fd7534bb5: name=etcd-node1 peerURLs=http://etcd-node1:2380 clientURLs=http://etcd-node1:2379,http://etcd-node1:4001 isLeader=false

a57a17f287dbe7bb: name=etcd-node2 peerURLs=http://etcd-node2:2380 clientURLs=http://etcd-node2:2379,http://etcd-node2:4001 isLeader=true

ffe21a7812eb7c5f: name=etcd-master peerURLs=http://etcd-master:2380 clientURLs= isLeader=false

[node2]

[[email protected] ~]# etcdctl member list

6c74f3fd7534bb5: name=etcd-node1 peerURLs=http://etcd-node1:2380 clientURLs=http://etcd-node1:2379,http://etcd-node1:4001 isLeader=false

a57a17f287dbe7bb: name=etcd-node2 peerURLs=http://etcd-node2:2380 clientURLs=http://etcd-node2:2379,http://etcd-node2:4001 isLeader=true

ffe21a7812eb7c5f: name=etcd-master peerURLs=http://etcd-master:2380 clientURLs= isLeader=false

四、测试集群同步情况

[master]

[[email protected] ~]# etcdctl set zlyangdir/zlyangkeys0 0

0

[[email protected] ~]# etcdctl ls zlyangdir

zlyangdir/zlyangkeys0

[[email protected] ~]# etcdctl get zlyangdir/zlyangkeys0

0

[node1]

[[email protected] ~]# etcdctl ls zlyangdir

zlyangdir/zlyangkeys0

[[email protected] ~]# etcdctl get zlyangdir/zlyangkeys0

0

[node2]

[[email protected] ~]# etcdctl ls zlyangdir

zlyangdir/zlyangkeys0

[[email protected] ~]# etcdctl get zlyangdir/zlyangkeys0

0

官方部署方案:https://coreos.com/etcd/docs/latest/op-guide/clustering.html

至此Etcd集群搭建已经完成,如有问题请联系:[email protected]

时间: 2024-10-19 12:37:05

CentOS 部署Etcd集群的相关文章

部署etcd集群

部署etcd集群 第一步:先拉取etcd二进制压缩包 wget https://github.com/coreos/etcd/releases/download/v3.3.2/etcd-v3.3.2-linux-amd64.tar.gz //解压压缩包 tar zxvf etcd-v3.3.2-linux-amd64.tar.gz 第二步:建立一个文件,分别存放bin文件,cfg配置文件,ssl验证文件 mkdir /opt/kubernetes/{bin,cfg,ssl} //然后将etcd,

基于已有集群动态发现方式部署 Etcd 集群

etcd提供了多种部署集群的方式,在「通过静态发现方式部署etcd集群」 一文中我们介绍了如何通过静态发现方式部署集群. 不过很多时候,你只知道你要搭建一个多大(包含多少节点)的集群,但是并不能事先知道这几个节点的ip,从而无法使用--initial-cluster参数. 这个时候,你就需要使用discovery的方式来搭建etcd集群.discovery方式有两种:etcd discovery和DNS discovery. 这里我们先介绍下etcd discovery方式.这种启动方式依赖另外

基于 DNS 动态发现方式部署 Etcd 集群

使用discovery的方式来搭建etcd集群方式有两种:etcd discovery和DNS discovery.在 「基于已有集群动态发现方式部署etcd集群」一文中讲解了etcd discovery这种方式,今天我们就来讲讲DNS discovery这种方式的实现. etcd在基于DNS做服务发现时,实际上是利用DNS的SRV记录不断轮训查询实现的.DNS SRV是DNS数据库中支持的一种资源记录的类型,它记录了哪台计算机提供了哪个服务这么一个简单信息. 本文采用dnsmasq作为dns服

部署k8s ssl集群实践4:部署etcd集群

参考文档:https://github.com/opsnull/follow-me-install-kubernetes-cluster感谢作者的无私分享.集群环境已搭建成功跑起来.文章是部署过程中遇到的错误和详细操作步骤记录.如有需要对比参考,请按照顺序阅读和测试. 4.1下载和分发二进制安装包 [[email protected] kubernetes]# wget https://github.com/coreos/etcd/releases/download/v3.3.7/etcd-v3

k8s部署etcd集群

1.k8s部署高可用etcd集群时遇到了一些麻烦,这个是自己其中一个etcd的配置文件 例如: [Unit] Description=Etcd Server After=network.target After=network-online.target Wants=network-online.target Documentation=https://github.com/coreos [Service] User=k8s Type=notify WorkingDirectory=/var/l

kubernetes容器集群部署Etcd集群

安装etcd 二进制包下载地址:https://github.com/etcd-io/etcd/releases/tag/v3.2.12 [[email protected] ~]# GOOGLE_URL=https://storage.googleapis.com/etcd [[email protected] ~]# GITHUB_URL=https://github.com/coreos/etcd/releases/download [[email protected] ~]# DOWNL

kubernetes 基础-安装部署etcd集群

HDSS7-200上: ~]# wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 -O /usr/bin/cfssl ~]# wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 -O /usr/bin/cfssl-json ~]# wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 -O /usr/bin/cfssl-cert

kubernetes部署etcd集群

部署环境: CentOS Linux release 7.2 64位 10.10.0.103 etcd master 10.10.0.49   etcd follower master安装过程: # yum update # yum install -y etcd # [member] ETCD_NAME=etcd1 ETCD_DATA_DIR="/var/lib/etcd/default.etcd" #ETCD_WAL_DIR="" #ETCD_SNAPSHOT_

centos7部署etcd集群

实验环境:centos7.4纯净版 192.168.216.130 node1 master 192.168.216.132 node2 slave 192.168.216.134 node3 slave yum安装etcd yum install etcd yum list installed |grep -i etcd node1 etcd 配置 cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak cd /etc/etcd/ [[email prot