centos下 etcd 简单使用

本文介绍了Etcd服务的配置文件设置,包括开机自动启动的步骤和服务管理命令,如启动、停止、重启及状态查看等操作。同时提供了etcdctl的主要命令用法,帮助读者更好地管理和使用Etcd。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

etcd开机自动启动

1、服务文件

/usr/lib/systemd/system/etcd.service

[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
# set GOMAXPROCS to number of processors
ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\" --data-dir=\"${ETCD_DATA_DIR}\" --listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\""
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
2、允许开机启动
systemctl enable etcd.service
3、启动
systemctl start etcd.service
4 、关闭
systemctl stop etcd.service
5、重启
systemctl restart etcd.service
6、查看运行状态
systemctl status etcd.service
7、etcdctl 主要命令
COMMANDS:
     backup          backup an etcd directory  备份目录
     cluster-health  check the health of the etcd cluster  检查集群状态
     mk              make a new key with a given value
     mkdir           make a new directory   新建目录
     rm              remove a key or a directory  删除key或目录
     rmdir           removes the key if it is an empty directory or a key-value pair
     get             retrieve the value of a key  获取制定key的值
     ls              retrieve a directory  目录列表
     set             set the value of a key   设值
     setdir          create a new directory or update an existing directory TTL
     update          update an existing key with a given value  更新指定key的值
     updatedir       update an existing directory  
     watch           watch a key for changes
     exec-watch      watch a key for changes and exec an executable
     member          member add, remove and list subcommands
     user            user add, grant and revoke subcommands
     role            role add, grant and revoke subcommands
     auth            overall auth controls
     help, h         Shows a list of commands or help for one command

参考:
对比表,以 apache / httpd 为例
任务 旧指令 新指令
使某服务自动启动 chkconfig –level 3 httpd on systemctl enable httpd.service
使某服务不自动启动 chkconfig –level 3 httpd off systemctl disable httpd.service
检查服务状态 service httpd status systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)
显示所有已启动的服务 chkconfig –list systemctl list-units –type=service
启动某服务 service httpd start systemctl start httpd.service
停止某服务 service httpd stop systemctl stop httpd.service
重启某服务 service httpd restart systemctl restart httpd.service
一个非常好的Linux命令学习网站

### 安装Kubernetes于CentOS上的简易指南 #### 准备工作 为了在CentOS 7.9上部署Kubernetes 1.26集群环境,需严格遵循特定步骤以确保快速而有效的设置过程[^1]。 #### 配置容器运行时 采用containerd作为各节点中的容器运行时工具。这一步骤对于构建稳定可靠的Kubernetes集群至关重要。 #### 节点软件准备 针对每台服务器(如server2和server3),执行如下操作来完成Node组件的安装: - 将下载好的二进制文件解压并移至指定路径: ```bash tar xf /root/kubernetes-node-linux-amd64.tar.gz mv /root/kubernetes/node/bin/{kubelet,kube-proxy} /usr/local/kubernetes/bin/ ``` - 设置`kubeconfig`配置文件以便后续服务能够正常连接API Server[^3]。 #### 启动顺序注意事项 特别需要注意的是,在启动各项服务之前应优先启动etcd数据库及其后的API Server;其余组件则无需考虑先后次序问题。 #### etcd配置实例 以下是etcd的一个基本配置样例,其中涉及到了监听地址和服务名称等参数设定: ```ini #[member] ETCD_NAME="etcd01" ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380" ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" ``` 此部分配置应当依据实际需求调整相应字段值[^4]。 #### 更新Kube-Proxy Pod 通过命令行方式可以轻松实现对现有Kube-Proxy Pods的即时更新: ```bash kubectl patch daemonset kube-proxy -p '{"spec":{"template":{"metadata":{"annotations":{"date":"'$(date +%s)'"}}}}}' -n kube-system ``` 上述指令会触发DaemonSet控制器重新创建所有受影响的工作负载单元[^5]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值