日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

白话Elasticsearch73_ES生产集群中的索引管理02

發布時間:2025/3/21 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 白话Elasticsearch73_ES生产集群中的索引管理02 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 概述
  • 官方指導
  • 1、mapping管理
  • 2、索引別名管理
  • 3、index settings管理
    • 3.1 Update index settings API
    • 3.2 Get index settings API
  • 4、index template
    • 4.0 官方文檔
    • 4.1 新建/更新模板
    • 4.2 刪除模板
    • 4.3 查看模板
    • 4.4 使用模板創建索引
    • 4.5 模板的使用場景


概述

繼續跟中華石杉老師學習ES,第74篇

課程地址: https://www.roncoo.com/view/55


官方指導

Index APIs: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html


1、mapping管理

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html#mapping-management

put mapping命令可以讓我們給一個已有的索引添加一個新的type,或者修改一個type,比如給某個type加一些字段

put mapping: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

下面這個命令是在創建索引的時候,直接跟著創建一個type

curl -XPUT 'http://elasticsearch02:9200/twitter?pretty' -d ' {"mappings": {"tweet": {"properties": {"message": {"type": "text"}}}} }'

下面這個命令是給一個已有的索引添加一個type 。 7.x 已經取消這個功能了,了解即可。

curl -XPUT 'http://elasticsearch02:9200/twitter/_mapping/user?pretty' -d ' {"properties": {"name": {"type": "text"}} }'

下面這個命令是給一個已有的type添加一個field

curl -XPUT 'http://elasticsearch02:9200/twitter/_mapping/tweet?pretty' -d ' {"properties": {"user_name": {"type": "text"}} }'

curl -XGET 'http://elasticsearch02:9200/twitter/_mapping/tweet?pretty',上面這行命令可以查看某個type的mapping映射信息

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html


curl -XGET 'http://elasticsearch02:9200/twitter/_mapping/tweet/field/message?pretty',這行命令可以看某個type的某個field的映射信息

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html


Type exists API https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html

mapping管理是運維中,索引管理中,很基礎的一塊


2、索引別名管理

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html#alias-management


curl -XPOST 'http://elasticsearch02:9200/_aliases?pretty' -d ' {"actions" : [{ "add" : { "index" : "twitter", "alias" : "twitter_prod" } }] }' curl -XPOST 'http://elasticsearch02:9200/_aliases?pretty' -d ' {"actions" : [{ "remove" : { "index" : "twitter", "alias" : "twitter_prod" } }] }' POST /_aliases {"actions" : [{ "remove" : { "index" : "test1", "alias" : "alias1" } },{ "add" : { "index" : "test2", "alias" : "alias1" } }] } POST /_aliases {"actions" : [{ "add" : { "indices" : ["test1", "test2"], "alias" : "alias1" } }] }

上面是給某個index添加和刪除alias的命令,還有重命名alias的命令(先刪除再添加),包括將一個alias綁定多個index

POST /_aliases {"actions" : [{"add" : {"index" : "test1","alias" : "alias2","filter" : { "term" : { "user" : "kimchy" } }}}] } DELETE /logs_20162801/_alias/current_day GET /_alias/2016

索引別名,還是挺有用的,主要是什么呢,就是說,可以將一個索引別名底層掛載多個索引,比如說7天的數據

索引別名常常和之前講解的那個rollover結合起來,我們為了性能和管理方便,每天的數據都rollover出來一個索引,但是在對數據分析的時候,可能是這樣子的,有一個索引access-log,指向了當日最新的數據,用來計算實時數據的; 有一個索引access-log-7days,指向了7天的7個索引,可以讓我們進行一些周數據的統計和分析。


3、index settings管理

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html#index-settings

3.1 Update index settings API

語法

PUT /<index>/_settings

curl -XPUT 'http://elasticsearch02:9200/twitter/_settings?pretty' -d ' {"index" : {"number_of_replicas" : 1} }'

3.2 Get index settings API

curl -XGET 'http://elasticsearch02:9200/twitter/_settings?pretty'

經??赡芤獙ndex做一些settings的調整,常常和之前的index open和close結合起來使用


4、index template

4.0 官方文檔

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html#index-templates

我們可以定義一些index template,這樣template會自動應用到根據匹配規則( based on an index pattern)匹配到的新創建的索引上去。

template中可以包含settings和mappings,還可以包含一個pattern,決定了template會被應用到哪些index上。

而且template僅僅在index創建的時候會被應用,修改template,是不會對已有的index產生影響的。


4.1 新建/更新模板

語法:

PUT /_template/<index-template>

創建或者更新模板

curl -XPUT 'http://elasticsearch02:9200/_template/template_access_log?pretty' -d ' {"template": "access-log-*","settings": {"number_of_shards": 2},"mappings": {"log": {"_source": {"enabled": false},"properties": {"host_name": {"type": "keyword"},"created_at": {"type": "date","format": "EEE MMM dd HH:mm:ss Z YYYY"}}}},"aliases" : {"access-log" : {}} }'


4.2 刪除模板

curl -XDELETE 'http://elasticsearch02:9200/_template/template_access_log?pretty' # 刪除模板 DELETE _template/template_1

返回

{"acknowledged": true }

4.3 查看模板

curl -XGET 'http://elasticsearch02:9200/_template/template_access_log?pretty' # 查看所有的模板 GET _template# 查看特定的模板 GET _template/template_1


4.4 使用模板創建索引

curl -XPUT 'http://elasticsearch02:9200/access-log-01?pretty'

查看索引, 觀察模板是否被自動的關聯到了匹配的模板上了。

curl -XGET 'http://elasticsearch02:9200/access-log-01?pretty' # 新建索引 匹配模板的index_patterns PUT test GET test/_mapping


4.5 模板的使用場景

index template使用場景: 舉個例子你可能會經常創建不同的索引,比如說商品,分成了多種,每個商品種類的數據都很大,可能就是說,一個商品種類一個索引,但是每個商品索引的設置是差不多的,所以干脆可以搞一個商品索引模板,然后每次新建一個商品種類索引,直接綁定到模板,引用相關的設置。

簡言之,將公共的東西抽取到模板中,省去了一遍一遍設置的麻煩。

總結

以上是生活随笔為你收集整理的白话Elasticsearch73_ES生产集群中的索引管理02的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 一区二区三区欧美视频 | 日韩激情电影在线 | 日本肉体xxxⅹ裸体交 | 三上悠亚久久 | 卡一卡二卡三 | 放几个免费的毛片出来看 | 亚洲一区二区影院 | 欧美少妇激情 | 国产精品久久久久久吹潮 | 国产乱色精品成人免费视频 | 三级在线观看网站 | 麻豆成人91精品二区三区 | 欧美成人视屏 | 一级特黄特色的免费大片视频 | 一二三区精品 | 国产精品视频在线观看免费 | 懂色av一区二区 | 亚洲春色在线 | 99精彩视频 | 粗大的内捧猛烈进出在线视频 | 熟妇高潮一区二区三区 | 亚洲最新网址 | 欧美日韩免费一区 | 成年人看的网站 | 日批视频免费 | 日韩123区 | 亚洲天堂小视频 | 欧美午夜精品一区二区三区电影 | 99久久精品免费看国产 | 欧美黑粗大 | 免费视频网站在线观看入口 | 国产综合在线观看视频 | 亚洲国产极品 | 国产精品视频你懂的 | 久久久久美女 | 亚洲综合免费 | 色香蕉av | 亚洲天堂中文字幕在线观看 | 日本中文字幕在线播放 | 少妇性bbb搡bbb爽爽爽欧美 | 一区二区三区免费播放 | 国产精品7777 | 亚洲一级av无码毛片精品 | 一级做a爱| 亚洲福利视频网 | r级无码视频在线观看 | 亚洲精品高清在线观看 | jizz欧美性23 | 毛片美女 | 久久精品人人做人人爽 | av色噜噜| 亚洲天堂影院 | 国产哺乳奶水91在线播放 | 欧美日p视频 | 国产精品v欧美精品v日韩精品 | 欧美 日韩 高清 | 又黄又爽又色视频 | 天堂免费av | 国产精品自产拍高潮在线观看 | 亚洲精品国产精品国自产观看浪潮 | 99人妻碰碰碰久久久久禁片 | www.自拍偷拍 | av日韩不卡 | 久草视频免费在线观看 | 国产熟妇搡bbbb搡bbbb搡 | 激情春色网| 老色鬼av | 深夜影院在线观看 | 午夜操操| 天天爽天天摸 | 91色伦| 日本高清在线播放 | 97人妻精品视频一区 | 王者后宫yin肉h文催眠 | 国产精品久久久久久亚洲调教 | 性网站在线观看 | 意大利少妇愉情理伦片 | 欧美精品久久久 | 久色精品视频 | 中文字幕在线一区二区三区 | 久久久美女视频 | 婷婷四房综合激情五月 | 日本在线观看一区二区 | 99热在线观看精品 | 熟女自拍一区 | 天堂中文视频 | 精品国产无码AV | 3d动漫精品啪啪一区二区三区免费 | 91婷婷在线| 爱操影院 | 欧美在线一二三 | 欧美不卡影院 | 亚洲图片一区 | 青青草原伊人 | 欧美日韩亚洲二区 | 黄色网址www | 国产美女主播在线观看 | 日韩激情小说 | 欧美亚洲丝袜 |