Update title style

Signed-off-by: Kang HuaiShuai <khs1994@khs1994.com>
This commit is contained in:
Kang HuaiShuai
2019-11-06 14:53:09 +08:00
parent 99e470eb2a
commit 5cb92f63cf
60 changed files with 224 additions and 232 deletions

View File

@@ -1,4 +1,4 @@
## etcd 集群
# etcd 集群
下面我们使用 [Docker Compose](../compose/) 模拟启动一个 3 节点的 `etcd` 集群

View File

@@ -1,4 +1,4 @@
## 使用 etcdctl v2
# 使用 etcdctl v2
`etcdctl` 是一个命令行客户端它能提供一些简洁的命令供用户直接跟 `etcd` 服务打交道而无需基于 `HTTP API` 方式这在某些情况下将很方便例如用户对服务进行测试或者手动修改数据库内容我们也推荐在刚接触 `etcd` 时通过 `etcdctl` 命令来熟悉相关的操作这些操作跟 `HTTP API` 实际上是对应的
@@ -46,14 +46,14 @@ GLOBAL OPTIONS:
--version, -v print the version
```
### 数据库操作
## 数据库操作
数据库操作围绕对键值和目录的 CRUD 符合 REST 风格的一套操作Create完整生命周期的管理
etcd 在键的组织上采用了层次化的空间结构类似于文件系统中目录的概念用户指定的键可以为单独的名字 `testkey`此时实际上放在根目录 `/` 下面也可以为指定目录结构 `cluster1/node2/testkey`则将创建相应的目录结构
*CRUD Create, Read, Update, Delete是符合 REST 风格的一套 API 操作*
#### set
### set
指定某个键的值例如
```bash
$ etcdctl set /testdir/testkey "Hello world"
@@ -66,7 +66,7 @@ Hello world
--swap-with-index '0' 若该键现在的索引值是指定索引,则进行设置操作
```
#### get
### get
获取指定键的值例如
```bash
$ etcdctl set testkey hello
@@ -87,7 +87,7 @@ Error: 100: Key not found (/testkey2) [1]
--consistent 将请求发给主节点,保证获取内容的一致性
```
#### update
### update
当键存在时更新值内容例如
```bash
$ etcdctl set testkey hello
@@ -107,7 +107,7 @@ Error: 100: Key not found (/testkey2) [1]
--ttl '0' 超时时间(单位为秒),不配置(默认为 0则永不超时
```
#### rm
### rm
删除某个键值例如
```bash
$ etcdctl rm testkey
@@ -127,7 +127,7 @@ Error: 100: Key not found (/testkey2) [8]
--with-index '0' 检查现有的 index 是否匹配
```
#### mk
### mk
如果给定的键不存在则创建一个新的键值例如
```bash
$ etcdctl mk /testdir/testkey "Hello world"
@@ -146,7 +146,7 @@ Error: 105: Key already exists (/testkey) [2]
--ttl '0' 超时时间(单位为秒),不配置(默认为 0则永不超时
```
#### mkdir
### mkdir
如果给定的键目录不存在则创建一个新的键目录例如
```bash
$ etcdctl mkdir testdir
@@ -162,7 +162,7 @@ Error: 105: Key already exists (/testdir) [7]
--ttl '0' 超时时间(单位为秒),不配置(默认为 0则永不超时
```
#### setdir
### setdir
创建一个键目录无论存在与否
@@ -171,14 +171,14 @@ Error: 105: Key already exists (/testdir) [7]
--ttl '0' 超时时间(单位为秒),不配置(默认为 0则永不超时
```
#### updatedir
### updatedir
更新一个已经存在的目录
支持的选项为
```bash
--ttl '0' 超时时间(单位为秒),不配置(默认为 0则永不超时
```
#### rmdir
### rmdir
删除一个空目录或者键值对
若目录不空会报错
@@ -189,7 +189,7 @@ $ etcdctl rmdir /dir
Error: 108: Directory not empty (/dir) [13]
```
#### ls
### ls
列出目录默认为根目录下的键或者子目录默认不显示子目录中内容
例如
@@ -212,9 +212,9 @@ $ ./etcdctl ls dir
-p 对于输出为目录,在最后添加 `/` 进行区分
```
### 非数据库操作
## 非数据库操作
#### backup
### backup
备份 etcd 的数据
支持的选项包括
@@ -222,7 +222,7 @@ $ ./etcdctl ls dir
--data-dir etcd 的数据目录
--backup-dir 备份到指定路径
```
#### watch
### watch
监测一个键值的变化一旦键值发生更新就会输出最新的值并退出
例如用户更新 testkey 键值为 Hello world
@@ -237,7 +237,7 @@ Hello world
--after-index '0' 在指定 index 之前一直监测
--recursive 返回所有的键值和子键值
```
#### exec-watch
### exec-watch
监测一个键值的变化一旦键值发生更新就执行给定命令
例如用户更新 testkey 键值
@@ -258,7 +258,7 @@ README.md
--recursive 返回所有的键值和子键值
```
#### member
### member
通过 listaddremove 命令列出添加删除 etcd 实例到 etcd 集群中
@@ -269,7 +269,7 @@ $ etcdctl member list
ce2a822cea30bfca: name=default peerURLs=http://localhost:2380,http://localhost:7001 clientURLs=http://localhost:2379,http://localhost:4001
```
### 命令选项
## 命令选项
* `--debug` 输出 cURL 命令显示执行命令的时候发起的请求
* `--no-sync` 发出请求之前不同步集群信息
* `--output, -o 'simple'` 输出内容的格式 (`simple` 为原始信息`json` 为进行json格式解码易读性好一些)

View File

@@ -1,4 +1,4 @@
## 使用 etcdctl
# 使用 etcdctl
`etcdctl` 是一个命令行客户端它能提供一些简洁的命令供用户直接跟 `etcd` 服务打交道而无需基于 `HTTP API` 方式这在某些情况下将很方便例如用户对服务进行测试或者手动修改数据库内容我们也推荐在刚接触 `etcd` 时通过 `etcdctl` 命令来熟悉相关的操作这些操作跟 `HTTP API` 实际上是对应的
@@ -81,7 +81,7 @@ OPTIONS:
-w, --write-out="simple" set the output format (fields, json, protobuf, simple, table)
```
### 数据库操作
## 数据库操作
数据库操作围绕对键值和目录的 CRUD 符合 REST 风格的一套操作Create完整生命周期的管理
@@ -89,14 +89,14 @@ etcd 在键的组织上采用了层次化的空间结构(类似于文件系统
>CRUD Create, Read, Update, Delete是符合 REST 风格的一套 API 操作
#### put
### put
```bash
$ etcdctl put /testdir/testkey "Hello world"
OK
```
#### get
### get
获取指定键的值例如
@@ -114,7 +114,7 @@ hello
`--consistent` 将请求发给主节点保证获取内容的一致性
#### del
### del
删除某个键值例如
@@ -123,9 +123,9 @@ $ etcdctl del testkey
1
```
### 非数据库操作
## 非数据库操作
#### watch
### watch
监测一个键值的变化一旦键值发生更新就会输出最新的值
@@ -138,7 +138,7 @@ testkey
2
```
#### member
### member
通过 `list``add``update``remove` 命令列出添加更新删除 etcd 实例到 etcd 集群中

View File

@@ -1,10 +1,10 @@
## 安装
# 安装
`etcd` 基于 `Go` 语言实现因此用户可以从 [项目主页](https://github.com/etcd-io/etcd) 下载源代码自行编译,也可以下载编译好的二进制文件,甚至直接使用制作好的 `Docker` 镜像文件来体验。
>注意本章节内容基于 etcd `3.4.x` 版本
### 二进制文件方式下载
## 二进制文件方式下载
编译好的二进制文件都在 [github.com/etcd-io/etcd/releases](https://github.com/etcd-io/etcd/releases/) 页面,用户可以选择需要的版本,或通过下载工具下载。
@@ -56,7 +56,7 @@ hello world
说明 etcd 服务已经成功启动了
### Docker 镜像方式运行
## Docker 镜像方式运行
镜像名称为 `quay.io/coreos/etcd`可以通过下面的命令启动 `etcd` 服务监听到 `2379` `2380` 端口
@@ -84,7 +84,7 @@ quay.io/coreos/etcd:v3.4.0 \
打开新的终端按照上一步的方法测试 `etcd` 是否成功启动
### macOS 中运行
## macOS 中运行
```bash
$ brew install etcd

View File

@@ -1,4 +1,4 @@
## 什么是 etcd
# 什么是 etcd
![](_images/etcd_logo.png)