乐趣区

关于etcd:etcd集群安装和单机安装

etcd 集群装置和单机装置

etcd 介绍

etcd 是基于 Raft 的分布式 key-value 存储系统,由 CoreOS 开发,罕用于服务发现、共享配置以及并发管制(如 leader 选举、分布式锁等)。kubernetes 应用 etcd 存储所有运行数据。etcd 基于 Go 语言实现。

etcd 作为服务发现零碎,有以下特点:

  • 简略:装置配置简略,而且提供了 HTTP API 进行交互,应用也很简略
  • 平安:反对 SSL 证书验证
  • 疾速:依据官网提供的 benchmark 数据,单实例反对每秒 2k+ 读操作
  • 牢靠:采纳 raft 算法,实现分布式系统数据的可用性和一致性

官网地址: http://www.etcd.cn/

源代码地址: https://github.com/coreos/etcd

1. 下载安装

curl -L https://github.com/coreos/etcd/releases/download/v3.0.6/etcd-v3.0.6-linux-amd64.tar.gz -o etcd-v3.0.6-linux-amd64.tar.gz

tar xzvf etcd-v3.0.6-linux-amd64.tar.gz

mv etcd-v3.0.6-linux-amd64 etcd

cd etcd

./etcd --version

2. 单机启动

etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://10.240.30.30:2379 &

3. 集群启动

别离在三台机器启动 etcd

cd /data/apps/etcd/
$ nohup /data/apps/etcd/etcd --name etcd0 --initial-advertise-peer-urls http://10.240.30.9:2380 \
  --listen-peer-urls http://10.240.30.9:2380 \
  --listen-client-urls http://10.240.30.9:2379,http://127.0.0.1:2379 \
  --advertise-client-urls http://10.240.30.9:2379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster etcd0=http://10.240.30.9:2380,etcd1=http://10.240.30.10:2380,etcd2=http://10.240.30.11:2380 \
  --initial-cluster-state new &
  
cd /data/apps/etcd/
$ nohup /data/apps/etcd/etcd --name etcd1 --initial-advertise-peer-urls http://10.240.30.10:2380 \
  --listen-peer-urls http://10.240.30.10:2380 \
  --listen-client-urls http://10.240.30.10:2379,http://127.0.0.1:2379 \
  --advertise-client-urls http://10.240.30.10:2379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster etcd0=http://10.240.30.9:2380,etcd1=http://10.240.30.10:2380,etcd2=http://10.240.30.11:2380 \
  --initial-cluster-state new &

cd /data/apps/etcd/
$ nohup /data/apps/etcd/etcd --name etcd2 --initial-advertise-peer-urls http://10.240.30.11:2380 \
  --listen-peer-urls http://10.240.30.11:2380 \
  --listen-client-urls http://10.240.30.11:2379,http://127.0.0.1:2379 \
  --advertise-client-urls http://10.240.30.11:2379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster etcd0=http://10.240.30.9:2380,etcd1=http://10.240.30.10:2380,etcd2=http://10.240.30.11:2380 \
  --initial-cluster-state new &

参考链接:
https://skyao.gitbooks.io/lea…

4.ETCD WEBUI

git clone https://github.com/henszey/etcd-browser.git
cd etcd-browser

sudo docker build -t etcd-browser .

sudo docker run --rm --name etcd-browser -p 0.0.0.0:8000:8000 --env ETCD_HOST=10.240.30.10 --env ETCD_PORT=2379 etcd-browser &

浏览器拜访: http://10.240.30.10:8000

退出移动版