centos7安装etcd

本次系统环境了是在vmware下安装了2个centos7系统(使用NAT方式,ip分别是192.168.174.128和192.168.174.129)。登录用户用root。

1.下载安装

     https://github.com/coreos/etcd/releases  在这网页,你可以看到有多个版本共选择,也有不同OS下的下载方式例子,点击进去看就OK了。

    使用curl -L下载curl -L https://github.com/coreos/etcd/releases/download/v3.1.0-alpha.1/etcd-v3.1.0-alpha.1-linux-amd64.tar.gz -o etcd-v3.1.0-alpha.1-linux-amd64.tar.gz   3.1.0是目前最新版本。


   解压后,会看到etcd,etcdctl,将它们复制到/usr/local/bin或/usr/bin下


运行 etcd,将默认组建一个两个节点的集群。数据库服务端默认监听在 2379 和 4001 端口,etcd 实例监
听在 2380 和 7001 端口。显示类似如下的信息:



   检查etcd是否正常了,那就通过etcdctl操作一些命令。注意操作前请先看看READ-etcdctl.ME和READv2-etcdctl.ME文件,其中READ-etcdctl.ME开头有句话。


    就是说,要在环境变量中设置ETCDCTL_API=3.否则使用etcdctl时会报错(我一开始就没注意)


  通过etcdctl --help查看有哪些命令

[html]  view plain  copy
  1. [root@localhost etcd-v3.1.0-alpha.1-linux-amd64]# etcdctl --help  
  2. NAME:  
  3.         etcdctl - A simple command line client for etcd3.  
  4.   
  5. USAGE:  
  6.         etcdctl  
  7.   
  8. VERSION:  
  9.         3.1.0-alpha.1  
  10.   
  11. COMMANDS:  
  12.         get                     Gets the key or a range of keys  
  13.         put                     Puts the given key into the store  
  14.         del                     Removes the specified key or range of keys [key, range_end)  
  15.         txn                     Txn processes all the requests in one transaction  
  16.         compaction              Compacts the event history in etcd  
  17.         alarm disarm            Disarms all alarms  
  18.         alarm list              Lists all alarms  
  19.         defrag                  Defragments the storage of the etcd members with given endpoints  
  20.         endpoint health         Checks the healthiness of endpoints specified in `--endpoints` flag  
  21.         endpoint status         Prints out the status of endpoints specified in `--endpoints` flag  
  22.         watch                   Watches events stream on keys or prefixes  
  23.         version                 Prints the version of etcdctl  
  24.         lease grant             Creates leases  
  25.         lease revoke            Revokes leases  
  26.         lease timetolive        Get lease information  
  27.         lease keep-alive        Keeps leases alive (renew)  
  28.         member add              Adds a member into the cluster  
  29.         member remove           Removes a member from the cluster  
  30.         member update           Updates a member in the cluster  
  31.         member list             Lists all members in the cluster  
  32.         snapshot save           Stores an etcd node backend snapshot to a given file  
  33.         snapshot restore        Restores an etcd member snapshot to an etcd directory  
  34.         snapshot status         Gets backend snapshot status of a given file  
  35.         make-mirror             Makes a mirror at the destination etcd cluster  
  36.         migrate                 Migrates keys in a v2 store to a mvcc store  
  37.         lock                    Acquires a named lock  
  38.         elect                   Observes and participates in leader election  
  39.         auth enable             Enables authentication  
  40.         auth disable            Disables authentication  
  41.         user add                Adds a new user  
  42.         user delete             Deletes a user  
  43.         user get                Gets detailed information of a user  
  44.         user list               Lists all users  
  45.         user passwd             Changes password of user  
  46.         user grant-role         Grants a role to a user  
  47.         user revoke-role        Revokes a role from a user  
  48.         role add                Adds a new role  
  49.         role delete             Deletes a role  
  50.         role get                Gets detailed information of a role  
  51.         role list               Lists all roles  
  52.         role grant-permission   Grants a key to a role  
  53.         role revoke-permission  Revokes a key from a role  
  54.         help                    Help about any command  
  55.   
  56. OPTIONS:  
  57.       --cacert=""                               verify certificates of TLS-enabled secure servers using this CA bundle  
  58.       --cert=""                                 identify secure client using this TLS certificate file  
  59.       --command-timeout=5s                      timeout for short running command (excluding dial timeout)  
  60.       --dial-timeout=2s                         dial timeout for client connections  
  61.       --endpoints=[127.0.0.1:2379]              gRPC endpoints  
  62.       --hex[=false]                             print byte strings as hex encoded strings  
  63.       --insecure-skip-tls-verify[=false]        skip server certificate verification  
  64.       --insecure-transport[=true]               disable transport security for client connections  
  65.       --key=""                                  identify secure client using this TLS key file  
  66.       --user=""                                 username[:password] for authentication (prompt if password is not supplied)  
  67.   -w, --write-out="simple"                      set the output format (json, proto, simple, table)  
  68.   
  69. [root@localhost etcd-v3.1.0-alpha.1-linux-amd64]#   

   

通过查看.md文件,里面有非常多关于etcdctl相关的操作命令,并且举例子说明,内容很多,这里就不贴了.测试

[html]  view plain  copy
  1. [root@localhost etcd-v3.1.0-alpha.1-linux-amd64]# etcdctl put testkey 'hello word'  
  2. OK  
  3. [root@localhost etcd-v3.1.0-alpha.1-linux-amd64]# etcdctl get testkey  
  4. testkey  
  5. hello word  
说明安装成功了。

再另一台机器也是如此安装。

2.集群配置

   上面的安装都是在单台服务上的。下面说说集群的安装。

   转载自http://blog.csdn.net/u010511236/article/details/52386229

 


原文

猜你喜欢

转载自blog.csdn.net/fishinhouse/article/details/80577530