ã¯ããã«
æ¬ç¨¿ã¯Amazon OpenSearch Serviceãå©ç¨ããä¸ã§ã®indexã®éç¨ã®åºæ¬ç¥èãç´¹ä»ãã¦ããé£è¼ã®ç¬¬äºå¼¾ã§ãã
å稿ã§ã¯OpenSearchã®indexããããåºæ¬æ¦å¿µã»åºæ¬ç¥èã«ã¤ãã¦èª¬æãã¾ããã
ç¹ã«1shardãããã§ç®¡çãããã¼ã¿å®¹éãé©åã«ä¿ã¤ãã¨ãå¿ è¦ã§ãããã¨ãã話ããã¾ããã
æ¬ç¨¿ã§ã¯æ¥ã å¢ããããã¼ã¿ã«å¯¾ãã¦OpenSearchã§ç¨æããã¦ããéç¨ã®èªååã»å¹çåæ©æ§ã«ã¤ãã¦ãç´¹ä»ãããã¨æãã¾ãã
ãªããæ¬ç¨¿ã¯ãµã¼ãã¼ã¯ã¼ã¯ã¹ã¢ããã³ãã«ã¬ã³ãã¼18æ¥ç®ã®æ稿ã§ãããã¾ãã
- ã¯ããã«
- Index State Managementã«ã¤ãã¦
- rolloverã»aliasã»index template
- å°æ¬
- ãããã«
â» ä¸è¨ç« ç«ã¦ã®ã4.å°æ¬ãã®ãå³ã«ããã¾ã¨ãããã覧ããã ãã¨ãæ¬ç¨¿ã§ã話ãããæ©è½ã®å¤§ã¾ããªå ¨ä½åãæ´ãã¾ãã
Index State Managementã«ã¤ãã¦
æ¦è¦
OpenSearchã§ã¯1 shardãããã§ç®¡çãããã¼ã¿å®¹éãè¥å¤§åããããªãããã«æ³¨æããããã¹ãã¬ã¼ã¸ã溢ãã¦ãã¾ããªãããã«æ³¨æãããããå¿ è¦ãããã»ã»ã»ã¨è¿°ã¹ã¾ããã
å®éã®éç¨ã§ãé¾å¤ãå®æçã«äººåã§ãã§ãã¯ãã¦èª¿æ´ä½æ¥ãå®æ½ããã®ã¯ãã¾ãç¾å®çãªãªãã¬ã¼ã·ã§ã³ã§ã¯ããã¾ããã
幸ãOpenSearch Serviceã§ã¯Index State Management (以ä¸ISM)ã¨å¼ã°ããæ©æ§ãããã¾ãã
ãããindexãããç¹å®ã®ç¶æ ã«éãããã¨ãã«èµ·å ãã¦ãç¹å®ã®ã¢ã¯ã·ã§ã³ããèªåã§ããªã¬ã¼ããããã«è¦å®ã§ããèªåå¶å¾¡ã®ããã®ãã©ã°ã¤ã³æ©è½ã§ãã
Amazon OpenSearch Serviceã«ã¤ãã¦ã¯ããã©ã«ãã§çµã¿è¾¼ã¾ãã¦ãããã©ã°ã¤ã³ã¨ãªã£ã¦ãã¾ãã
ããå³å¯ã«è¨ãã°ä»¥ä¸ã®ãããªä»çµã¿ã§ãã
- ç¹å®ã®å½åè¦åã®indexã«å¯¾ãã¦stateãå¿ è¦åæ°åå®ç¾©ãã¦ãããããã種å¥ã®indexã«é¢ãã¦æ³å®ãããã©ã¤ããµã¤ã¯ã«ãã®åã¹ãããã示ãå½¹å²ãæã¤
- åstateå
ã§ã¯ããã«ä»¥ä¸ã®ãããªé
ç®ãå®ç¾©ãããã¨ã§ãindexãæå³ããã¿ã¤ãã³ã°ã§å¥ã®stateã«é·ç§»ãã¦é©åãªå¦ç½®ãèªåã§æ½ãããããã«æ§æãããã¨ãã§ãã
- actionï¼ãã®stateã«é·ç§»ããéã«ã©ã®ãããªå¦çãè¡ãããå®ç¾©ããã
- 失ææã®ãªãã©ã¤ã®è«¸æ¡ä»¶çã«ã¤ãã¦ãè¦å®å¯è½
- transitionï¼æ¬¡ã®stateã«é·ç§»ããããã®æ¡ä»¶ãå®ç¾©ãããããstateã«ã¤ãã¦ä»®ã«æ¬é
ç®ãå®ç¾©ããã¦ããªãå ´åã ISMã¯ä¸éãã®é·ç§»ãå®äºããã¨ã¿ãªãã¦indexã®ç®¡çãåæ¢ãã
- é·ç§»ã®æ¡ä»¶ã«ã¤ãã¦ã¯indexã®å®¹éã»ä½æããã¦ããã®çµéæ¥æã»documentã®æ°éçãè¦å®å¯è½
- actionï¼ãã®stateã«é·ç§»ããéã«ã©ã®ãããªå¦çãè¡ãããå®ç¾©ããã
ä¾ãã°ã以ä¸ã®ãããªå ·åã«ç¨ãããã¨ãã§ãã¾ãã
- currentã»oldã»deleteã¨ãã3ã¤ã®statusãå®ç¾©
- indexã¯ä½æå½åã¯currentã¨ããstatusã«ç½®ããããã«ãã
- 30æ¥ãçµéããã¿ã¤ãã³ã°ã§ã¯æ¤ç´¢å¯¾è±¡ã«ããããã¨ãæ¸ããããã®ã¿ã¤ãã³ã°ã§oldã¨ããstatusã«é·ç§»ããã¦replica shardã®åæ°ã2ãã1ã«å¤æ´ãã¦èªã¿è¾¼ã¿ãã£ãã·ãã£ã®ä½ä¸ã¨å¼ãæãã«å®¹éãç¯ç´ãã
- ããã«åå¹´ãçµéããã¿ã¤ãã³ã°ã§deleteã«ç§»è¡ããã¦indexèªä½ãåé¤ãã¦ãã¾ã
å ·ä½å®ç¾©ä¾
ISMã¯å®éã«ã¯jsonå½¢å¼ã§å®ç¾©ããã¾ããããã§ãå ã»ã©ä¾ç¤ºãããããªã©ã¤ããµã¤ã¯ã«ãjsonã«è½ã¨ãè¾¼ãã¨ã©ã®ãããªå½¢ã«ãªãã以ä¸ã«å ·ä½ä¾ãã示ããã¾ãããã
{ "policy": { "description": "Changes replica count and deletes.", "schema_version": 1, "default_state": "current", "states": [{ "name": "current", "actions": [], "transitions": [{ "state_name": "old", "conditions": { "min_index_age": "30d" } }] }, { "name": "old", "actions": [{ "replica_count": { "number_of_replicas": 1 } }], "transitions": [{ "state_name": "delete", "conditions": { "min_index_age": "90d" } }] }, { "name": "delete", "actions": [{ "delete": {} }], "transitions": [] } ], "ism_template": [ { "index_patterns": [ "index-*" ], "priority": 100 } ] } }
ãããã®é·ç§»ã«ã¤ãã¦ã¯index_patternsã«ç¤ºããã¦ããéããindex-*ãã®æ¡ä»¶ã«å½ã¦ã¯ã¾ãindexãããªãã¡index-000001ã»index-typeA-000001çã®å称ã®indexãé©ç¨ã®å¯¾è±¡ã¨ãªããã¨ã示ãã¦ãã¾ãã
ã¾ããããindexã«ã¤ãã¦ãåISMããªã·ã¼ã®index_patternsã®å®ç¾©å 容次第ã§ã¯ãè¤æ°ã®ISMããªã·ã¼ãé©ç¨å¯¾è±¡ã«ãªããã¨ããããã¾ãã
ãã®å ´åã¯è¤æ°ã®ISMããªã·ã¼ãå½è©²indexã«é©ç¨ããããã¨ã¯ãªããåä¸ã®ISMããªã·ã¼ãé¸æããã¾ãã
ãã®éã®é¸æã®å¤å®åºæºã¨ãªãã®ãpriorityã§ãããä»åã®ä¾ã®å ´åãpriorityã100ããé«ãISMããªã·ã¼ãä»ã«ãªãã£ãå ´åã¯æ¬ããªã·ã¼ãindexã«é©ç¨ããããã¨ã¨ãªãã¾ãã
ãã詳細ãªè¨å®å 容ãå¦ã³ããæ¹ã«ã¤ãã¦ã¯ä»¥ä¸ã®ããã¥ã¡ã³ãããæéãããæã«èªãã§ã¿ã¦ãã ããã
Index State Management - OpenSearch documentation
Amazon OpenSearch Service ã§ã®ã¤ã³ããã¯ã¹ã¹ãã¼ã管ç - Amazon OpenSearch Service
rolloverã»aliasã»index template
ãã¦ãå ã»ã©ã®èª¬æã§ãã種å¥ã»ããå½åè¦åã®indexãISMããªã·ã¼ã®é©ç¨å¯¾è±¡ã«ãªãã¨è¿°ã¹ã¾ããã
åå¦è ã®æ¹ããããã¨AOSã§ã¯ç°ãªã種å¥ã®indexã»ä¼¼ããããªå½åè¦åã®indexãè¤æ°ä½µåããã®ãï¼ã¨ããã¨ããããã¾ãã¡ãã³ã¨ããªãããããã¾ããã
çµè«ã¨ãã¦ã¯ä½µåãããã¨ã¯ããã¾ãã
ãã®ç¹ãç解ããããã«ISMã§å®ç¾©ã§ããactionã®ä¸ã§ãæãéè¦ãªactionã®ä¸ã¤ã§ããrolloverã¨ãrolloverã®éç¨ã¨ã¨ã¦ãå¯æ¥ãªé¢ä¿ãæã¤æ©è½ã§ããaliasã¨index templateã«ã¤ãã¦è§¦ãã¦
æ¬ç¨¿ãçµãããã¨ã«ãã¾ããã(é£è¼èªä½ã¯ã¾ã ç¶ãã¾ã)
rolloverã«ã¤ãã¦(ç²ã )
ã¾ããrolloverã¨ã¯ãã£ããè¨ãã¨ãããindexããã¼ã¿ãåãå ¥ãç¶ãã¦è¥å¤§åããããªãããã«ãæ°ãã空ã®indexãçºè¡ãã¦æ°è¦ã«ãã¼ã¿ãåãä»ããããã«ãããæ©è½ã§ãã
aliasã«ã¤ãã¦
ããã§éãæ¹ã¯ãæ°ãã空ã®indexãä½ã£ãã®ã¯ããããã©ããä»ã¾ã§ãã¼ã¿ãæå ¥ãã¦ããããã°ã©ã å´ã§indexåã®åãæ¿ããå¿ è¦ã«ãªã£ã¦ãã¾ãã®ã§ã¯ï¼ãã¨æã£ãããããã¾ããã
ãã®ãããªæéãçãããã«OpenSearchã®indexã«ã¯aliasã¨ããæ©æ§ãããã¾ãã
alias( = å¥å)ã¨ã¯ãã®åã®éããä¾ãã°sample-index-000001ã¨ããindexã«ã¤ãã¦sampleã¨ããå¥åãã¤ãã¦ããã¦
å¥åï¼ä»åã®ä¾ã§ããã°sampleï¼ã®æå®ã§ãã£ã¦ç®å½ã¦ã®indexï¼sample-index-000001ï¼ã«ã¢ã¯ã»ã¹ããããã¨ãã§ããæ©è½ã§ãã
rolloverã«ã¤ãã¦(詳細)
rolloverã®æåã«ã¤ãã¦ãããå³å¯ã«ãã®å 容ã説æããã¨ä»¥ä¸ã®ãããªãªãã¬ã¼ã·ã§ã³ãå®æ½ãã¦ããã¦ãã¾ãã
- 対象ã®indexã«ã¤ãã¦ãaliasãä»ä¸ããã¦ãããã¨ãã¨ãindexåã®ãµãã£ãã¯ã¹ã«é£çªãã¤ãã¦ãããã¨ããåæã¨ãã¦
-ããµãã£ãã¯ã¹ãã¤ã³ã¯ãªã¡ã³ãããindexãæ°è¦ä½æããã¤ã¤
- sample-index-000001ãrolloverã®å¯¾è±¡ã¨ãªã£ãå ´åã¯ãsample-index-000002ã¨ããindexãæ°è¦ä½æããã¾ã -ãaliasã®åãå ãæ°è¦ä½æããindexã«åãæ¿ãããå¦çãå®æ½
ã¤ã¾ããã¼ã¿ãæå ¥ããããã°ã©ã å´ããããã°ãæ®æ®µã¯aliasã®sampleã¨ããå称ã®indexã«å¯¾ãã¦documentãæå ¥ããããã«ãã¦ããããããã°
rolloverã«ããè£å´ã§ã¯sample-index-000001ããæ°è¦ä½æã®sample-index-000002ã«aliasã®åãå ãåãæ¿ãã£ã¦ããã¨ãã¦ãç¹ã«æèãããã¨ãªãæå ¥å¦çãç¶ç¶ã§ããã¨ãããã¨ã«ãªãããã§ãã
rolloverãå®æ½ããããã®ISMããªã·ã¼ã®ä¾
ããã§ãrolloverãæ±ãISMããªã·ã¼ã®ä¾ãè¦ã¦ã¿ã¾ããã
{ "policy": { "policy_id": "Roll_over_policy", "description": "A test policy. DO NOT USE FOR PRODUCTION!", "schema_version": 1, "error_notification": null, "default_state": "hot", "states": [ { "name": "hot", "actions": [ { "rollover": { "min_size": "30gb" } } ], "transitions": [ { "state_name": "warm" } ] }, { "name": "warm", "actions": [ { "replica_count": { "number_of_replicas": 2 } } ], "transitions": [] } ] } }
対象ã®indexã®å®¹é(min_size)ã30GBã«éããå ´åã«rolloverãå®æ½ããããããªããªã·ã¼ã§ãã
ããã§ãã対象ã®indexã®å®¹é = primary shardã®åè¨å®¹éã§ãï¼replica shardã®å®¹éã¯èæ ®ããã¾ããï¼ã
ä»®ã«ã1 shardãããã®ç®¡ç容éã30GBã«éãã段éã§rolloverãçºçãããããã±ã¼ã¹ãèããå ´åãprimary shardæ°ã1ã®indexã®å ´åã§ã¯ä»åã®ä¾ã®è¨å®ã§OKã§ãã
primary shardæ°ã3ã®indexã§ãã£ãå ´åã¯ãmin_sizeã«ã¯90gbãæå®ããã®ã妥å½ã¨ãããã¨ã«ãªãã¾ãã
rolloverãèªåå®è¡ããã«ã¯å¯¾è±¡ã®aliasãæ示çã«ææ¡ã§ããªããã°ãããªã
ä¸è¿°ã®rolloverå®è¡ç¨ã®ããªã·ã¼ä¾ã«ã¤ãã¦ã¯index_patternsï¼ã©ã®indexã«ISMã®ããªã·ã¼ãé©ç¨ãããï¼ã¨ããè¨å®é ç®ã追è¨ãã¦ããããããã°åé¡ãªãåä½ããã¯ãã§ãã
ç¹ã«rolloveræã«åãæ¿ããè¡ãaliasã«ã¤ãã¦ã¯æ¡ä»¶ãè¨ããã¦ãã¾ããã
1ã¤ã®indexã«ã¯è¤æ°ã®aliasãã¤ãããã®ã§ãä»®ã«è¤æ°ãã£ãå ´åã¯å¤æã«å°ã£ã¦ãã¾ãããã§ãã
å®ã¯rolloveræã«åãæ¿ããaliasã«ã¤ãã¦ã¯ãISMããªã·ã¼ã§ç®¡çããindexã«å¯¾ãã¦äºåã«æå®ã»å®ç¾©ãã¦ããå¿ è¦ãããã¾ãã
index templateã«ã¤ãã¦
ã§ã¯ãrolloverã§æ°è¦ä½æãããindexã«ã¯é½åº¦æåã§aliasã«é¢ããå®ç¾©ãä»ã足ãæéãçããã®ã§ããããã»ã»ã»ï¼
ãã®ãããªãã¨ã¯ãªãæ°è¦ä½æãããindexã«ã¤ãã¦ã¯ã諸ã ã®è¨å®ãèªåã§é©ç¨ããããã®æ©æ§ãOpenSearchã«ã¯åãã£ã¦ãã¾ãããã®æ©æ§ãindex templateã§ãã
以ä¸ãindex templateã®ä½æä¾ã§ãã
PUT _template/sample_template { "index_patterns": "sample-*", "priority": 100, "template": { "settings": { "number_of_shards": 3, "number_of_replicas": 1, "index.opendistro.index_state_management.rollover_alias": "sample" }, "mappings": { "properties": { "id": { "type": "keyword" }, "temperature": { "type": "float" }, "timestamp": { "type": "date", "format": "yyyy-MM-dd'T'HH:mm:ss" } } } } }
ISMããªã·ã¼ã¨åããããªå½¢ã§ãé©ç¨ã®å¯¾è±¡ã¨ããindexã®ãã¿ã¼ã³(index_patterns)ãã¨ãé©ç¨ããªã·ã¼åè£ãè¤æ°ãã£ãå ´åã®åªå 度(priority)ããè¦å®ãã¦ãã
å®éã«å¯¾è±¡ã¨ãªã£ãindexã«å¯¾ãã¦åfieldã®ãã¼ã¿å(template.mappings)ããã®ä»è«¸ã ã®è¨å®(template.settings)ãèªåé©ç¨ãããã¨ãã§ãã¾ãã
ä¸è¨ã®ä¾ã§ããã¨ããã®template.settings.index.opendistro.index_state_management.rollover_aliasãrolloverç¨ã®aliasãæå®ããããã®è¨å®ã§ãã
index templateã®è¨å®ã¯rolloverã®æºå以å¤ã®æ§ã ãªè¦³ç¹ã§ãéè¦ãªå½¹å²ãæã£ã¦ãã
primaryã»replicaã®shardæ°ãrefresh(æ¸ãè¾¼ã¿ãã¼ã¿ã«ã¤ãã¦ãããã¡ã¡ã¢ãªããå®éã«ã¹ãã¬ã¼ã¸ã«åæ ããå¦ç)ã®intervalãªã©å¤æ§ãªè¨å®ãæå®å¯è½ã§ãã
ãããã®è¨å®é ç®ã®ããã¤ãã«ã¤ãã¦ã¯å¾ç¶ã®è¨äºã§ããããã触ãããã¨ã«ãªãã¨ã¯æãã¾ãã
ç¾æç¹ã§template.settingsãtempate.mappingsã®è¨å®ã®å¹ ã«ã¤ãã¦æ°ã«ãªãæ¹ã¯é©å®ä»¥ä¸ã®ããã¥ã¡ã³ããåç §ãã¦ã¿ã¦ãã ããã
Index settings - OpenSearch documentation
Mapping - OpenSearch documentation
å°æ¬
æ¹ãã¦index templateãISMããªã·ã¼ã®å¿ è¦æ§ã«ã¤ãã¦
ã©ã®ãããªãã¼ã¿ãã©ã®ãããªæéä¿åããå¿ è¦ããããã©ã®ãããªæ¸ãè¾¼ã¿ã»èªã¿è¾¼ã¿å¦çãã©ã®ç¨åº¦ã®é »åº¦çºçããããã»ã»ã»ããããæ§è³ªã¯ä¿ç®¡ãããã¼ã¿ã®ç¨®å¥ã«ãã£ã¦ç°ãªãã¯ãã§ãã
ããã§OpenSearchã§ã¯æ§è³ªãç°ãªããã¼ã¿ãå¥ã ã®indexã§ç®¡çãã¦ãããããããã«åå¥ã®index templateãISMããªã·ã¼ãé©ç¨ãã¦æé©ãªéç¨ãå®ç¾ããå¿ è¦ãããã®ã§ãã
ãã£ã¨ããä¾ãã°ä¼ç¤¾ã®ãã¬ãã¸ãã¼ã¹ãOpenSearchã®indexã§ç®¡çããã¨ãããããªå ´åã«ã¯çæéã«æ¥µç«¯ã«ãã¼ã¿ãå¢ãããã¨ã¯ãªã
1ã¤ã®indexã§è³ãã¦ãã¾ããã¨ãå¤ãã§ãããããè¾¼ã¿å ¥ã£ãISMããªã·ã¼ã¯å¿ è¦ã§ã¯ãªãããããã¾ããã
ããããå種ãã°ãã¼ã¿ãã»ã³ãµã¼ãã¼ã¿ã®ãããªæç³»åãæ±ããããªindexã®å ´åã§ããç¨åº¦ã®æéã®ä¿åãå¿ è¦ãªå ´åã¯
ãããããã-000001ãã¨ãããããªãµãã£ãã¯ã¹ã®ä½ã£ãindexãåææ§ç¯ãã¦ãã
ISMããªã·ã¼ã®rolloverãã¯ããã¨ããå種actionã§indexãé©æ£ã«ç®¡çããã¨ã¨ãã«ãrolloverã«ããæ°è¦ä½æãããindexã«å¯¾ãã¦ãèªåã§è¨å®ãé©ç¨ãããããã«
index templateãäºåã«èãã¦æ´åãã¦ãããã¨ãå¿ è¦ã¨è¨ããã§ãããã
å³ã«ããã¾ã¨ã
ä»æ¥ã®ããã°ã®å 容ãç²ã ã§ç¤ºããæ¦å¿µå³ã以ä¸ã«æ·»ä»ãã¦ããã¾ããç解ã®è£å©ã«ãå©ç¨ãã ããã
ãããã«
æ¬ç¨¿ã§ã¯èªåéç¨ã®èã¨ãªãISMããªã·ã¼ã¨ããã®ä¸»è¦ãªactionã®ä¸ã¤ã§ããrolloverã«ã¤ãã¦èª¬æãã¾ããã
次é ã§ã¯ãã®ä»ã®ISMããªã·ã¼ã®actionã«ã¤ãã¦ãããã¤ã¾ãã§èª¬æãããã¨æãã¾ãã
ç°æ çå¾ (è¨äºä¸è¦§)
ã¢ããªã±ã¼ã·ã§ã³ãµã¼ãã¹é¨
2016å¹´æ°åå ¥ç¤¾ãçç¡ç²¾ã§å ¥ç¤¾ä»¥éä¸åããã°ãæ¸ãã¦ããªãã£ãã®ã§ãããè²ã ããããç¨ã«æ¸ããã¨ã«ãã¾ããï¼ç¾¤é¦¬ããçå¿ãããã¦ãå±ããã¾ãï¼