first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
30
ELK/es学习记录11-多索引.md
Normal file
30
ELK/es学习记录11-多索引.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
需要在不停服务的情况下增加容量时,下面有一些有用的建议。相较于将数据迁移到更大的索引中,你可以仅仅做下面这些操作:
|
||||
|
||||
创建一个新的索引来存储新的数据。
|
||||
同时搜索两个索引来获取新数据和旧数据。
|
||||
实际上,通过一点预先计划,添加一个新索引可以通过一种完全透明的方式完成,你的应用程序根本不会察觉到任何的改变。
|
||||
|
||||
使用索引别名来指向当前版本的索引。 举例来说,给你的索引命名为 tweets_v1 而不是 tweets 。你的应用程序会与 tweets 进行交互,但事实上它是一个指向 tweets_v1 的别名。 这允许你将别名切换至一个更新版本的索引而保持服务运转。
|
||||
|
||||
|
||||
可以使用一个类似的技术通过增加一个新索引来扩展容量。这需要一点点规划,因为你需要两个别名:一个用于搜索另一个用于索引数据:
|
||||
```
|
||||
PUT /tweets_1/_alias/tweets_search
|
||||
PUT /tweets_1/_alias/tweets_index
|
||||
```
|
||||
新文档应当索引至 tweets_index ,同时,搜索请求应当对别名 tweets_search 发出。目前,这两个别名指向同一个索引。
|
||||
|
||||
当我们需要额外容量时,我们可以创建一个名为 tweets_2 的索引,并且像这样更新别名
|
||||
```
|
||||
POST /_aliases
|
||||
{
|
||||
"actions": [
|
||||
{ "add": { "index": "tweets_2", "alias": "tweets_search" }}, # 添加索引 tweets_2 到别名 tweets_search
|
||||
{ "remove": { "index": "tweets_1", "alias": "tweets_index" }}, # 移除tweets的别名tweets_index
|
||||
{ "add": { "index": "tweets_2", "alias": "tweets_index" }} # 将别名 tweets_index 由 tweets_1 切换至 tweets_2
|
||||
]
|
||||
}
|
||||
```
|
||||
一个搜索请求可以以多个索引为目标,所以将搜索别名指向 tweets_1 以及 tweets_2 是完全有效的。 然而,索引写入请求只能以单个索引为目标。因此,我们必须将索引写入的别名只指向新的索引
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue