Elastic Stack 8 : Elasticsearch स्थापित करें2023/09/26 |
पूर्ण-पाठ खोज इंजन [Elasticsearch] स्थापित करें।
|
|
[1] | स्थापित करें और Elasticsearch चलाएँ। Java को स्थापित करना आवश्यक नहीं है क्योंकि एकीकृत Java Elasticsearch में शामिल है। |
root@dlp:~# wget -O - https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --dearmor -o /etc/apt/keyrings/elasticsearch-keyring.gpg root@dlp:~# echo "deb [signed-by=/etc/apt/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-8.x.list root@dlp:~# apt update root@dlp:~# apt -y install elasticsearch
..... ..... --------------------------- Security autoconfiguration information ------------------------------ Authentication and authorization are enabled. TLS for the transport and HTTP layers is enabled and configured. The generated password for the elastic built-in superuser is : ErHQaG33QeEFNSer2odU If this node should join an existing cluster, you can reconfigure this with '/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here>' after creating an enrollment token on your existing cluster. You can complete the following actions at any time: Reset the password of the elastic built-in superuser with '/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'. Generate an enrollment token for Kibana instances with '/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'. Generate an enrollment token for Elasticsearch nodes with '/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'. -------------------------------------------------------------------------------------------------
root@dlp:~#
systemctl enable --now elasticsearch
# स्थिति सत्यापित करें # पासवर्ड वह है जो ऊपर इंस्टालेशन के दौरान दिखाया गया है root@dlp:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200 Enter host password for user 'elastic': { "name" : "dlp.srv.world", "cluster_name" : "elasticsearch", "cluster_uuid" : "M9nrqhXsTR694D0Olok-HQ", "version" : { "number" : "8.5.0", "build_flavor" : "default", "build_type" : "deb", "build_hash" : "c94b4700cda13820dad5aa74fae6db185ca5c304", "build_date" : "2022-10-24T16:54:16.433628434Z", "build_snapshot" : false, "lucene_version" : "9.4.1", "minimum_wire_compatibility_version" : "7.17.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "You Know, for Search" } |
[2] |
यदि आप अन्य होस्ट से Elasticsearch का उपयोग करते हैं, क्लस्टरिंग के लिए सेटिंग देखें।
अन्य होस्ट से अनुरोध प्राप्त करने पर एकल नोड का उपयोग करने पर भी इसे क्लस्टरिंग के साथ समान सेटिंग्स को कॉन्फ़िगर करने की आवश्यकता होती है। |
[3] | यह Elasticsearch का मूल उपयोग है। पहले एक इंडेक्स बनाएं, यह आरडीबी पर डेटाबेस की तरह है। |
# सूचकांक सूची दिखाएं ([pretty] का अर्थ है कि यह मानव पठनीय के साथ JSON दिखाता है) root@dlp:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200/_aliases?pretty Enter host password for user 'elastic': { ".security-7" : { "aliases" : { ".security" : { "is_hidden" : true } } } } # सूचकांक बनाएं root@dlp:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt -X PUT "https://127.0.0.1:9200/test_index" Enter host password for user 'elastic': {"acknowledged":true,"shards_acknowledged":true,"index":"test_index"} # सत्यापित करें root@dlp:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200/_aliases?pretty Enter host password for user 'elastic': { ".security-7" : { "aliases" : { ".security" : { "is_hidden" : true } } }, "test_index" : { "aliases" : { } } }root@dlp:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200/test_index/_settings?pretty Enter host password for user 'elastic': { "test_index" : { "settings" : { "index" : { "routing" : { "allocation" : { "include" : { "_tier_preference" : "data_content" } } }, "number_of_shards" : "1", "provided_name" : "test_index", "creation_date" : "1667873808441", "number_of_replicas" : "1", "uuid" : "v54rKGamQHaDWzwtwjxeEA", "version" : { "created" : "8050099" } } } } } |
[4] | मैपिंग को परिभाषित करें और परीक्षण डेटा डालें। मैपिंग सूचकांक की संरचना को परिभाषित करता है। यदि डेटा डाला जाता है, तो मैपिंग स्वचालित रूप से परिभाषित हो जाएगी, लेकिन निश्चित रूप से इसे मैन्युअल रूप से परिभाषित करना संभव है। |
# डेटा डालें root@dlp:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt \
-H "Content-Type: application/json" \ -X PUT "https://127.0.0.1:9200/test_index/_doc/001" -d '{ "subject" : "Test Post No.1", "description" : "This is the initial post", "content" : "This is the test message for using Elasticsearch." }' {"_index":"test_index","_id":"001","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1} # मैपिंग दिखाएं root@dlp:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt "https://127.0.0.1:9200/test_index/_mapping/?pretty" Enter host password for user 'elastic': { "test_index" : { "mappings" : { "properties" : { "content" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "description" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "subject" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } } } } } } # डेटा दिखाओ root@dlp:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt "https://127.0.0.1:9200/test_index/_doc/001?pretty" Enter host password for user 'elastic': { "_index" : "test_index", "_id" : "001", "_version" : 1, "_seq_no" : 0, "_primary_term" : 1, "found" : true, "_source" : { "subject" : "Test Post No.1", "description" : "This is the initial post", "content" : "This is the test message for using Elasticsearch." } } # डेटा खोजें # नीचे दी गई खोज स्थितियों के उदाहरण का अर्थ है [description] फ़ील्ड में एक शब्द शामिल है [initial] root@dlp:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt "https://127.0.0.1:9200/test_index/_search?q=description:initial&pretty=true" Enter host password for user 'elastic': { "took" : 13, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 1, "relation" : "eq" }, "max_score" : 0.2876821, "hits" : [ { "_index" : "test_index", "_id" : "001", "_score" : 0.2876821, "_source" : { "subject" : "Test Post No.1", "description" : "This is the initial post", "content" : "This is the test message for using Elasticsearch." } } ] } } |
Sponsored Link |