Cluster, Index
11438 ワード
フレキシブル韓国語ドキュメントhttps://www.elastic.co/guide/kr/index.htmlを読み、作成 ElasticSearch取付 Elasticsearch 7.15インストールガイド(Linux)
https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html
実験は7.15バージョンで行われた.クラスタ状態チェック HTTP/REST呼び出しをサポートするツールはすべて使用できます(ここではcurlを使用します).
cat APIを使用してクラスタのステータスを確認する
statusがredの場合も一部実行されますが、データが失われています.ノードリスト cat APIのノードを使用してクラスタ内のノードリストを表示するすべてのインデックス が一覧表示されます.
cat APIのインデックスは、すべてのインデックスをチェックするために使用できます.インデックス を作成
PUTを使用してインデックスを作成し、cat APIのインデックスを使用してインデックスをチェックします.
Elasticsearchのデフォルトではcustomerインデックスにコピーが作成されているため、statusは黄色で、クラスタに他のノードが含まれている場合はstatus greenとして割り当てられます.
-ドキュメントインデックスとquery
putを使用してcustomerの不正確なドキュメントをインデックスする
インデックスの例を実行するときにcustomerインデックスがない場合、customerインデックスが自動的に生成されます.
GETを使用してインデックスされたドキュメントを検索
「ソース」はインデックスのJSONドキュメント全体を返します
削除インデックス すべてのインデックスを検索
削除後の確認は Elasticsearchを介してデータ にアクセス
https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html
実験は7.15バージョンで行われた.
cat APIを使用してクラスタのステータスを確認する
curl -XGET http://localhost:9200/_cat/health?v
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1633840629 04:37:09 elasticsearch yellow 1 1 2 2 0 0 1 0 - 66.7%
クラスタのステータスは、緑(クラスタが正常に動作している)、黄色(クラスタが正常に動作しているが、一部のコピーが割り当てられていない)、赤(一部のデータは使用できない)で表示されます.statusがredの場合も一部実行されますが、データが失われています.
curl -XGET http://localhost:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
127.0.0.1 26 95 0 0.00 0.00 0.00 cdfhilmrstw * mastername
ノードの名前がmasternameであり、クラスタ内で唯一のノードであることを確認します.cat APIのインデックスは、すべてのインデックスをチェックするために使用できます.
curl -XGET http://localhost:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases 5bDnwbNMTRGA6OdRftwUfw 1 0 41 41 40.1mb 40.1mb
yellow open classes RpMiZlEDQlOXV-fmnhSg7w 1 1 0 0 208b 208b
2つのインデックスが作成されたことを確認PUTを使用してインデックスを作成し、cat APIのインデックスを使用してインデックスをチェックします.
curl -XPUT http://localhost:9200/customer?pretty
curl -XGET http://localhost:9200/_cat/indices?v
PUTを使用して「customer」という名前のインデックスを作成し、最後に?JSON応答を実行するためにprettyを追加するprerry-print{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "customer"
}
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases 5bDnwbNMTRGA6OdRftwUfw 1 0 41 41 40.1mb 40.1mb
yellow open classes RpMiZlEDQlOXV-fmnhSg7w 1 1 0 0 208b 208b
yellow open customer SBxddo1RS3uITMmILhzd8g 1 1 0 0 208b 208b
customerインデックスには0個のドキュメントが含まれており、statusは黄色(一部のコピーが割り当てられていない)と判断できます.Elasticsearchのデフォルトではcustomerインデックスにコピーが作成されているため、statusは黄色で、クラスタに他のノードが含まれている場合はstatus greenとして割り当てられます.
-ドキュメントインデックスとquery
putを使用してcustomerの不正確なドキュメントをインデックスする
curl -XPUT http://localhost:9200/customer/external/1?pretty -d '{ "name" : "John Doe" }' -H 'Content-Type:
application/json'
{
"_index" : "customer",
"_type" : "external",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
-H 'Content-Type: application/json'
オプションが指定されていない場合は、次のエラーが発生します.{
"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported",
"status" : 406
}
https://abc2080.tistory.com/entry/%EC%97%90%EB%9F%AC-ContentType-header-applicationxwwwformurlencoded-is-not-supported インデックスの例を実行するときにcustomerインデックスがない場合、customerインデックスが自動的に生成されます.
GETを使用してインデックスされたドキュメントを検索
curl -XGET http://localhost:9200/customer/external/1?pretty
{
"_index" : "customer",
"_type" : "external",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"name" : "John Doe"
}
}
「find」:trueは、要求されたID 1に対応する文書が見つかったことを示す「ソース」はインデックスのJSONドキュメント全体を返します
削除
curl -XGET http://localhost:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases 5bDnwbNMTRGA6OdRftwUfw 1 0 41 41 40.1mb 40.1mb
yellow open classes RpMiZlEDQlOXV-fmnhSg7w 1 1 0 0 208b 208b
yellow open customer SBxddo1RS3uITMmILhzd8g 1 1 1 0 3.8kb 3.8kb
インデックスの削除(classes、customer)curl -XDELETE http://localhost:9200/customer?pretty
curl -XDELETE http://localhost:9200/classes?pretty
{
"acknowledged" : true
}
確認削除が「確認済」削除後の確認は
curl -XGET http://localhost:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases 5bDnwbNMTRGA6OdRftwUfw 1 0 41 41 40.1mb 40.1mb
curl -X<REST Verb> http://localhost:9200/<Index>/<Type>/<ID>
このRESTアクセスモードは、すべてのAPIコマンドで使用されます.Reference
この問題について(Cluster, Index), 我々は、より多くの情報をここで見つけました https://velog.io/@joohyuk99/Cluster-Indexテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol