ubuntu下安装lxml报错_ubuntu下etcd的安装部署

be177780a9fe9c432e365ba235949c96.png

一、简介

etcd是一个高可用的分布式键值(key-value)数据库。etcd内部采用raft协议作为一致性算法,etcd基于Go语言实现。

提供配置共享和服务发现的系统比较多,其中最为大家熟知的是[Zookeeper](后文简称ZK),而ETCD可以算得上是后起之秀了。在项目实现,一致性协议易理解性,运维,安全等多个维度上,ETCD相比Zookeeper都占据优势。

etcd是一个服务发现系统,具备以下的特点:

  • 简单:安装配置简单,而且提供了HTTP API进行交互,使用也很简单
  • 安全:支持SSL证书验证
  • 快速:根据官方提供的benchmark数据,单实例支持每秒2k+读操作
  • 可靠:采用raft算法,实现分布式系统数据的可用性和一致性

二、应用场景

和ZK类似,ETCD有很多使用场景,包括:

    配置管理
    服务注册于发现
    选主
    应用调度
    分布式队列
    分布式锁

安装

本文所使用的系统为: ubuntu-14.04.6-server-amd64

wget https://github.com/etcd-io/etcd/releases/download/v3.3.10/etcd-v3.3.10-linux-amd64.tar.gz
tar zxvf etcd-v3.3.10-linux-amd64.tar.gz
mv etcd-v3.3.10-linux-amd64 /opt/etcd-v3.3.10

解压后的文件如下所示:

root@ubuntu:cd /opt/etcd-v3.3.10
root@ubuntu:/opt/etcd-v3.3.10# ls
default.etcd  Documentation  etcd  etcdctl  README-etcdctl.md  README.md  READMEv2-etcdctl.md

其中etcd是server端,etcdctl是客户端,操作之后会生成一个default.etcd,主要用来存储etct数据。

启动一个单节点的etcd服务,只需要运行etcd命令就行。不过有可能会出现以下问题:

root@ubuntu:/opt/etcd-v3.3.10# ./etcd 
bash: ./etcd: 权限不够

如果出现权限,采用如下方法:

root@ubuntu:/opt/etcd-v3.3.10# chmod 755 etcd

启动成功后会出现如下内容:

root@ubuntu:/opt/etcd-v3.3.10# ./etcd
2020-04-24 10:22:44.631034 I | etcdmain: etcd Version: 3.3.10
2020-04-24 10:22:44.631114 I | etcdmain: Git SHA: 27fc7e2
2020-04-24 10:22:44.631122 I | etcdmain: Go Version: go1.10.4
2020-04-24 10:22:44.631128 I | etcdmain: Go OS/Arch: linux/amd64
2020-04-24 10:22:44.631134 I | etcdmain: setting maximum number of CPUs to 2, total number of available CPUs is 2
2020-04-24 10:22:44.631142 W | etcdmain: no data-dir provided, using default data-dir ./default.etcd
2020-04-24 10:22:44.631734 I | embed: listening for peers on http://localhost:2380
2020-04-24 10:22:44.631820 I | embed: listening for client requests on localhost:2379
2020-04-24 10:22:44.633281 I | etcdserver: name = default
2020-04-24 10:22:44.633323 I | etcdserver: data dir = default.etcd
2020-04-24 10:22:44.633356 I | etcdserver: member dir = default.etcd/member
2020-04-24 10:22:44.633366 I | etcdserver: heartbeat = 100ms
2020-04-24 10:22:44.633372 I | etcdserver: election = 1000ms
2020-04-24 10:22:44.633377 I | etcdserver: snapshot count = 100000
2020-04-24 10:22:44.633391 I | etcdserver: advertise client URLs = http://localhost:2379
2020-04-24 10:22:44.633400 I | etcdserver: initial advertise peer URLs = http://localhost:2380
2020-04-24 10:22:44.633411 I | etcdserver: initial cluster = default=http://localhost:2380
2020-04-24 10:22:44.636967 I | etcdserver: starting member 8e9e05c52164694d in cluster cdf818194e3a8c32
2020-04-24 10:22:44.637013 I | raft: 8e9e05c52164694d became follower at term 0
2020-04-24 10:22:44.637025 I | raft: newRaft 8e9e05c52164694d [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
2020-04-24 10:22:44.637031 I | raft: 8e9e05c52164694d became follower at term 1
2020-04-24 10:22:44.640746 W | auth: simple token is not cryptographically signed
2020-04-24 10:22:44.641951 I | etcdserver: starting server... [version: 3.3.10, cluster version: to_be_decided]
2020-04-24 10:22:44.642508 I | etcdserver: 8e9e05c52164694d as single-node; fast-forwarding 9 ticks (election ticks 10)
2020-04-24 10:22:44.642868 I | etcdserver/membership: added member 8e9e05c52164694d [http://localhost:2380] to cluster cdf818194e3a8c32
2020-04-24 10:22:45.537814 I | raft: 8e9e05c52164694d is starting a new election at term 1
2020-04-24 10:22:45.537903 I | raft: 8e9e05c52164694d became candidate at term 2
2020-04-24 10:22:45.537934 I | raft: 8e9e05c52164694d received MsgVoteResp from 8e9e05c52164694d at term 2
2020-04-24 10:22:45.537951 I | raft: 8e9e05c52164694d became leader at term 2
2020-04-24 10:22:45.538000 I | raft: raft.node: 8e9e05c52164694d elected leader 8e9e05c52164694d at term 2
2020-04-24 10:22:45.539042 I | etcdserver: published {Name:default ClientURLs:[http://localhost:2379]} to cluster cdf818194e3a8c32
2020-04-24 10:22:45.539650 I | etcdserver: setting up the initial cluster version to 3.3
2020-04-24 10:22:45.540372 N | etcdserver/membership: set the initial cluster version to 3.3
2020-04-24 10:22:45.540701 I | embed: ready to serve client requests
2020-04-24 10:22:45.541113 I | etcdserver/api: enabled capabilities for version 3.3
2020-04-24 10:22:45.542200 N | embed: serving insecure client requests on 127.0.0.1:2379, this is strongly discouraged!

从上面的输出中,我们可以看到很多信息。以下是几个比较重要的信息:

2020-04-24 10:22:44.633281 I | etcdserver: name = default

name表示节点名称,默认为default。

2020-04-24 10:22:44.633323 I | etcdserver: data dir = default.etcd

data-dir 保存日志和快照的目录,默认为当前工作目录default.etcd/目录下。

etcdserver: advertise client URLs = http://localhost:2379

在[http://localhost:2379](http://localhost:2379/)提供HTTP API服务,供客户端交互。

etcdserver/membership: added member 8e9e05c52164694d [http://localhost:2380] to cluster cdf818194e3a8c32

在[http://localhost:2380](http://localhost:2380/)和集群中其他节点通信。

2020-04-24 10:22:44.633366 I | etcdserver: heartbeat = 100ms

heartbeat为100ms,该参数的作用是leader多久发送一次心跳到followers,默认值是100ms。

2020-04-24 10:22:44.633372 I | etcdserver: election = 1000ms

election为1000ms,该参数的作用是重新投票的超时时间,如果follow在该时间间隔没有收到心跳包,会触发重新投票,默认为1000ms。

2020-04-24 10:22:44.633377 I | etcdserver: snapshot count = 100000

snapshot count为10000,该参数的作用是指定有多少事务被提交时,触发截取快照保存到磁盘。

集群和每个节点都会生成一个uuid。

启动的时候会运行raft,选举出leader。

采用这种方式启动的etcd只是一个程序,如果启动etcd的窗口被关闭的话则etcd便会被关闭

,所以如果要长期使用的话最好是为etcd开启一个服务。

使用如下指令:

root@ubuntu:/opt/etcd-v3.3.10# ./etcd &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值