「Centos7」kubernetes — etcd

版本:etcd-v3.2.6-linux-amd64
下载地址:https://github.com/etcd-io/etcd/releases/tag/v3.2.6

etcd 核心算法 raft 算法:

应该没有比这个小动画更形象的介绍了

配置信息:(均采用 https)

conf.yml

# 节点名称
name:                    etcd-1     
# 数据存放目录
data-dir:                /data-path

#snapshot-count          # 触发快照到硬盘的已提交的事物数量,默认 10000
#heartbeat-interval		 # 心跳间隔时间(ms)默认 100
#election-timeout        # 选举超时时间(ms)默认 1000
#listen-peer-urls        # 监听伙伴通讯的 URL,默认 http://localhost:2380

# 监听地址   需注意 ip 地址的设置,如 localhost 和 0.0.0.0 的区别
# 默认 http://localhost:2379
listen-client-urls:      https://0.0.0.0:2379 
#max-snapshots           # 保持的快照文件最大数量(0 无限)    默认 5
# 成员客户端 URL  默认 http://localhost:2379
advertise-client-urls:   https://0.0.0.0:2379
# 初始化集群配置   默认 default=http://localhost:2380
# name=URL
initial-cluster:         etcd-1=https://0.0.0.0:2379
# 初始化集群的状态   (new 或者 existing)   默认 new 
initial-cluster-state:   new
# 启动期间用于 etcd 集群初始化的标识
# 默认 etcd-cluster
initial-cluster-token:   etcd-cluster-token
initial-advertise-peer-urls:     https://0.0.0.0:2379
# 客户端传输 ssl 路径
client-transport-security:

        cert-file: /etc/kubernetes/ssl/kubernetes.pem

        key-file: /etc/kubernetes/ssl/kubernetes-key.pem
# 监听 ssl 证书路径
peer-transport-security:

        cert-file: /etc/kubernetes/ssl/kubernetes.pem

        key-file: /etc/kubernetes/ssl/kubernetes-key.pem

运行 etcd:

etcd --config-file conf.yml

etcdctl put test 123
OK
etcdctl get test
test
123

可用常见的比如 systemd,supervisord 进行进程的托管
以下介绍 systemd 方式

cat /etc/systemd/system/etcd.service
[Unit]
Description=Etcd
Documentation=https://github.com/doczhcn/etcd

[Service]
#EnvironmentFile=-/path-to-env-file
ExecStart=etcd --config-file /path-to-env-file/conf.yml # 自行修改可执行文件及配置文件目录
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
systemctl daemon-reload # 在 /etc/systemd/system/ 下新增配置文件后需要重载所有修改过的配置文件
systemctl enable etcd # 开机启动
systemctl start etcd # 启动
systemctl status etcd # 检查状态

相关日志信息可在 /var/log/message 查看,或者通过 journalctl 命令查看 systemd 的日志信息

阮老师的 systemd 使用教程

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值