我是靠谱客的博主 忧郁红牛,最近开发中收集的这篇文章主要介绍(四)搭建容器云管理平台笔记—安装ETCD(不使用证书)一、参考介绍二、部署,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

一、参考介绍

etcd是什么?

A highly-available key value store for shared configuration and service discovery.

是一个用作分布式共享配置和服务发现的高可用键值对(强一致性)存储仓库

根据它的定义,它最主要场景在于:

1. 分布式系统的配置共享问题

2. 分布式系统的服务发现问题

 

二、部署

kubernetes使用etcd组件作为它状态控制组件,在部署的时候如果只单etcd模式,通常与master安装在一台机器

1. 下载

选择最新文档版Etcd v3.2.13 https://github.com/coreos/etcd/releases

CentOs75下载选择:

# wget https://github.com/coreos/etcd/releases/download/v3.2.13/etcd-v3.2.13-linux-amd64.tar.gz

解压缩后目录结构如下:

drwxrwxr-x. 11 1000 1000 4096 Jan 3 06:01 Documentation
-rwxrwxr-x. 1 1000 1000 17829696 Jan 3 06:01 etcd
-rwxrwxr-x. 1 1000 1000 15246720 Jan 3 06:01 etcdctl
-rw-rw-r--. 1 1000 1000 33849 Jan 3 06:01 README-etcdctl.md
-rw-rw-r--. 1 1000 1000 5801 Jan 3 06:01 README.md
-rw-rw-r--. 1 1000 1000 7855 Jan 3 06:01 READMEv2-etcdctl.md

将etcd、etcdctl复制到/usr/bin目录

# cp etcd /usr/bin
# cp etcdctl /usr/bin
#chmod 777 /usr/bin/etcd
#chmod 777 /usr/bin/etcdctl

注意:二进制安装没有etcd.conf文件,需要自己参考官方编写,如果是yum安装则会自动帮你生成一份conf文件。

#使用yum安装
yum install -y etcd
mkdir /opt/etcd

2. 修改环境变量

添加环境变量,指定客户端工具etcdctl使用api v3和服务器程序etcd进行通信。

#export ETCDCTL_API=3

 

3.设置systemd服务文件(单机模式,非集群模式)

在/etc/systemd/system/目录里创建etcd.service,其内容如下:

[Unit]
Description=etcd.service
[Service]
Type=notify
TimeoutStartSec=0
Restart=always
WorkingDirectory=/var/lib/etcd
EnvironmentFile=--/etc/etcd/etcd.conf
ExecStart=/usr/bin/etcd
[Install]
WantedBy=multi-user.target

其中WorkingDirectory为etcd数据库目录,需要在etcd安装前创建

# mkdir /var/lib/etcd

最好连/var/lib/etcd/etcd.conf一并创建,即便是空文件

注意:EnvironmentFile=--/etc/etcd/etcd.conf 这个路径,如果是yum安装也是默认这个路径

单机简版配置:

ETCD_NAME=ETCD Server
ETCD_DATA_DIR="/var/lib/etcd/"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.137.3:2379"

4. 设置开机启动

#systemctl daemon-reload
#systemctl enable etcd.service
#systemctl start etcd.service

 

问题:启动报“status=203/EXEC” 错误,启动报失败

操作:chmod 777 修改执行文件权限,预先创建好/var/lib/etcd目录及其/var/lib/etcd/etcd.conf文件

 

5. 检查是否成功启动

命令1:# systemctl status etcd

命令2:# etcdctl cluster-health

# etcdctl member list 查看集群状态

结果:member 8e9e05c52164694d is healthy: got healthy result from http://localhost:2379

注意:如果etcd.conf 为空文件,那么etcd使用默认配置

参考配置文件etcd.conf

#[Member]
ETCD_DATA_DIR="/var/lib/etcd/etcd1"
ETCD_LISTEN_PEER_URLS="http://192.168.80.130:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.80.130:2379,http://127.0.0.1:2379"
ETCD_NAME="member1"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.80.130:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.80.130:2379"
ETCD_INITIAL_CLUSTER="member1=http://192.168.80.130:2380,member2=http://192.168.80.131:2380,memb
er3=http://172.18.2.23:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
#etcd2与etcd3配置文同上,需修改ip为自己的ip

注意:Clustering 为集群配置

这里的 ETCD_DATA_DIR 与 etcd.service 的 WorkingDirectory 是不一样的

 

6. 搭建etcd集群

单机参考:http://blog.csdn.net/chen798213337/article/details/78501042 (经配置OK)

集群参考:http://blog.csdn.net/chenhaifeng2016/article/details/71122886

主要是通过配置etcd.service来实现节点之间的互相监听

例如:

# set GOMAXPROCS to number of processors
ExecStart=/usr/local/src/etcd-v3.1.7-linux-amd64/etcd 
--name infra0 
--initial-advertise-peer-urls http://10.0.0.201:2380 
--listen-client-urls http://10.0.0.201:2379,http://127.0.0.1:2379 
--listen-peer-urls http://10.0.0.201:2380 
--advertise-client-urls http://10.0.0.201:2379 
--initial-cluster-token etcd-cluster1 
--initial-cluster infra0=http://10.0.0.201:2380,infra1=http://10.0.0.202:2380,infra2=http://10.0.0.203:2380 
--initial-cluster-state new

从github可以看到 official etcd ports are 2379 for client requests, and 2380 for peer communication.

 

 

 

 

 

 

 

 

 

 

 

转载于:https://my.oschina.net/pagecorrect/blog/1635918

最后

以上就是忧郁红牛为你收集整理的(四)搭建容器云管理平台笔记—安装ETCD(不使用证书)一、参考介绍二、部署的全部内容,希望文章能够帮你解决(四)搭建容器云管理平台笔记—安装ETCD(不使用证书)一、参考介绍二、部署所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部