centos下 etcd 简单使用

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

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命令学习网站

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值