转载自: http://tecadmin.net/install-elasticsearch-on-linux/#
Elasticsearch is flexible and powerful open source, distributed real-time search and analytic engine. Using a simple set of APIs, it provides the ability for full-text search. Elastic search is freely available under the Apache 2 license, which provides most flexibility.
This tutorial will help you to setup Elasticsearch single node cluster on CentOS, Red Hat, Ubuntu, Debian and LinuxMint systems.
1. Verify Java
Java is the primary requirement for installing Elasticsearch. So make sure you have Java installed on your system.
# java -version java version "1.8.0_31" Java(TM) SE Runtime Environment (build 1.8.0_31-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
If you don’t have Java installed on your system, use one of following link to install it first.
2. Download Elasticsearch Archive
Now download the latest Elasticsearch archive from its official download page. At the time of last update of this article Elasticsearch 2.3.1 version is latest version available to download.
$ /tmp $ wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.3.1.tar.gz
Now extract downloaded Elasticsearch archive on your system.
$ tar xzf elasticsearch-2.3.1.tar.gz
3. Configure Elasticsearch
Now we need to setup Elasticsearch cluster and node name. Elasticsearch uses “elasticsearch” as default cluster name, We recommend to change it as per your setup.
$ mv elasticsearch-2.3.1 /usr/share/elasticsearch $ cd /usr/share/elasticsearch
To change cluster named edit config/elasticsearch.yml file and update following values. Node names are dynamically generated, but to keep a fixed user-friendly name change it also. You may also need to change network host to access elasticsearch from remote hosts.
$ vim config/elasticsearch.yml
network.host: 192.168.10.100 cluster.name: TecAdmin_Cluster1 node.name: "California DataCenter"
4. Install Elasticsearch-Head Plugin
elasticsearch-head is a web front end for browsing and interacting with an Elastic Search cluster. Use the following command to install it.
$ bin/plugin install mobz/elasticsearch-head
5. Starting Elasticsearch Cluster
As the Elasticsearch setup is completed. Let the start Elasticsearch cluster using following command.
$ ./bin/elasticsearch &
6. Verify Setup
You have all done, just need to verify setup. Elasticsearch works on port default port 9200, open your browser to point your server on port 9200, You will find some thing like below output
http://localhost:9200/_plugin/head/
http://svt1.tecadmin.net:9200/
7. Basic Examples of Elasticsearch Uses
Following examples will help you to add, fetch and search data in Elasticsearch cluster.
Creating Bucket
curl -XPUT http://localhost:9200/mybucket
Output:
{"acknowledged":true}
Adding Data to Elasticsearch
Use following commands to add some data in Elasticsearch.
Command 1:
curl -XPUT 'http://localhost:9200/mybucket/user/johny' -d '{ "name" : "Rahul Kumar" }'
Output:
{"_index":"mybucket","_type":"user","_id":"johny","_version":1,"created":true}
Command 2:
curl -XPUT 'http://localhost:9200/mybucket/post/1' -d ' { "user": "Rahul", "postDate": "01-15-2015", "body": "This is Demo Post 1 in Elasticsearch" , "title": "Demo Post 1" }'
Output:
{"_index":"mybucket","_type":"post","_id":"1","_version":1,"created":true}
Command 3:
curl -XPUT 'http://localhost:9200/mybucket/post/2' -d ' { "user": "TecAdmin", "postDate": "01-15-2015", "body": "This is Demo Post 2 in Elasticsearch" , "title": "Demo Post 2" }'
Output:
{"_index":"mybucket","_type":"post","_id":"2","_version":1,"created":true}
Fetching Data from Elasticsearch
Use following command to GET data from ElasticSearch and read the output.
curl -XGET 'http://localhost:9200/mybucket/user/johny?pretty=true' curl -XGET 'http://localhost:9200/mybucket/post/1?pretty=true' curl -XGET 'http://localhost:9200/mybucket/post/2?pretty=true'
Searching in Elasticsearch
Use following command to search data from elastic search. Below command will search all data associated with user johny.
curl 'http://localhost:9200/mybucket/post/_search?q=user:TecAdmin&pretty=true'
Output:
{ "took" : 145, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 0.30685282, "hits" : [ { "_index" : "mybucket", "_type" : "post", "_id" : "2", "_score" : 0.30685282, "_source": { "user": "TecAdmin", "postDate": "01-15-2015", "body": "This is Demo Post 2 in Elasticsearch" , "title": "Demo Post 2" } } ] } }
Congratulation’s! You have successfully configured elasticsearch single node cluster on your Linux system.
相关推荐
You will see how to install Elasticsearch and Kibana and learn how to index and update your data. We will use an e-commerce site as an example to explain how a search engine works and how to query ...
You will then see how to install and configure ElasticSearch and the ElasticSearch monitoring plugins. Then, you will proceed to install and use the Marvel dashboard to monitor ElasticSearch. You ...
You will then see how to install and configure ElasticSearch and the ElasticSearch monitoring plugins. Then, you will proceed to install and use the Marvel dashboard to monitor ElasticSearch. You ...
This book will be your hands-on guide as you explore and put to use the features of Elasticsearch 5.0. You will install and set up Elasticsearch and its related plugins, and handle documents using ...
一键安装elasticsearch脚本,Elasticsearch 是位于 Elastic Stack 核心的分布式搜索和分析引擎。Logstash 和 Beats 有助于收集、聚合和丰富您的数据并将其存储在 Elasticsearch 中。Kibana 使您能够以交互方式探索、...
ElasticSearch is a distributed search server similar to Apache Solr with a focus on large datasets, a schema-less setup, and high availability. This schema-free architecture allows ElasticSearch to ...
If you’re a newcomer to both search and distributed systems, you’ll quickly learn how to integrate Elasticsearch into your application. More experienced users will pick up lots of advanced ...
Monitor your Elasticsearch cluster's health, and diagnose and solve its performance and reliability issuesElasticSearch is a distributed search server similar to Apache Solr with a focus on large ...
elasticsearch_node模块,npm下载的模块,没网可以用下
CentOS 7 部署 Elasticsearch7.4 集群并进行安全认证.docx
elasticsearch 全文搜索引擎在centOs8.x环境下 安装配置服务搭建
CentOS 7 elasticsearch service 开机自启
This course aims to create a smooth learning path that will teach you how to effectively use Elasticsearch with other de facto components and get the most out of Elasticsearch. Through this ...
If you're a newcomer to both search and distributed systems, you'll quickly learn how to integrate Elasticsearch into your application. More experienced users will pick up lots of advanced techniques....
ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索...
You will get an understanding of how you can scale your ElasticSearch cluster to contextualize it and improve its performance. We'll also show you how you can create your own analysis plugin in ...
CentOS7下搭建多节点Elasticsearch集群
Elasticsearch的官方Node.js客户端库
Get the latest guide on ElasticSearch 2.0.0, which contains concise and adequate information on handling all the issues a developer needs to know while handling data in bulk with search relevancy ...
Beginning with an overview of the way ElasticSearch stores data, you'll begin to extend your knowledge to tackle indexing and mapping, and learn how to configure ElasticSearch to meet your users' ...