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

猜你喜欢

转载自blog.csdn.net/jl_study_5/article/details/78515979