Elasticsearch deployment and use on NAS
Elasticsearch is an enterprise-class full-text search engine, based on the development of Lucene Library in Java, fully using the RESTful interface for users, distributed search support is very good!
Deployment Environment
In order to achieve distributed deployment, I used two synology Nas, x86 and ARM respectively, the architecture, the practice proved to be able to run.
Host: Synology ds415+,ds414j (https://www.synology.com)
Version: elasticsearch-1.5.0
Installation
Download the Elasticsearch package from Apache's official website first
Https://www.elastic.co/downloads/elasticsearch
There are 4 kinds of download packages, tar/zip/deb/rpm, I choose zip here, in the NAS after decompression can be executed directly.
It is important to note that because Elasticsearch is written in Java, the running environment must have a Java interpreter, which is not available by default on the Synology NAS, need to install the Java Manager, and then go to Oracle's official website to download the JRE to install to the NAS.
Run
After decompression, run./bin/elasticsearch, the service will start in a few seconds, if you want to run in background, use the./bin/elasticsearch-d way.
After running, you can go to the browser directly access http://localhost:9200/(here localhost please replace your server address)
To run successfully, you can see the following:
By the way,
If you want to manage elasticsearch more easily, then use the Marvel plug-in (too expensive 1000 knives a year, can not afford to own development) the plugin provides functionality: monitor your cluster status real-time and historical analysis Elasticsearch internal State, Storage history, performance monitoring, etc. provides a console for call Elasticsearch's REST API
bin/plugin-i elasticsearch/marvel/latest
Stop and Start Elasticsearch
Http://any-server-in-cluster:9200/_plugin/marvel
If you do not want to be monitored, then
./config/elasticsearch. Yml
If it is in the foreground open, then directly CTRL + C can close node, if not, then use
Http://localhost:9200/_shutdown, shut it down.
Relationship with the relational database if compared to the RDB, then relational Db⇒databases⇒tables⇒rows⇒columnselasticsearch⇒indices⇒types⇒documents⇒fi ELDs Data Read/write insert/Update data
You see? EMPLOYEE/1 to take 1, usually with key
Fetching data
Get/megacorp/employee/1*put insert data, get get data, delete deletes data, head queries for data, update data? Just cover it with a put.
Search data
If you are searching for all the records, then
Get/megacorp/employee/_search
If you are using a lightweight search, then
Get/megacorp/employee/_search?q=last_name:smith
If you want a more sophisticated search method, you can use the Domain-specific language (DSL)
For full-text search, it matches the correlation degree. Can be precisely matched, also can let the keyword highlight
Can even do aggregation analysis and search nesting
Cluster
Cluster is the highlight of this search engine, distributed search and disaster recovery backup can be done by Shard deployment on different node.
When you create an index, you can specify how many shard to be redundant.
This specifies the number of shards and replicas, shards is only specified at creation time, and replicas can be modified later, by default, is a rep
Directly start the second node of the Elasticsearch, and then will automatically find the master node for the replicas copy, completed as follows
If it's 1 copies, then 3 node is
But if we want to scale more, we can increase the number of reps.
If you use the URL method to close a node, the entire cluster is closed.
If you force a node to close, it will be downgraded to the following
The cluster will encounter some problems such as data update conflicts,
Elasticsearch is through _version this metadata to detect whether there is an update conflict, if the conflict will return to failure, the client's discretion
How to resolve conflicts, such as getting the latest data again, deciding whether to insert or not.
Because the engine is set up for each field by default, so if the document is partially updated, it is also the retrieve-change-reindex process, but using the API with its own update ensures that these steps are done in a shards , which reduces the time-to-network, and indirectly reduces the likelihood of an update conflict.
Client
The following are the currently supported client programs, usually packaged, and crud is as easy as working with relational databases.
Clients & Integrations
- Java Api-1.5-other Versions
- JavaScript Api-4.0-other Versions
- Groovy Api-1.5-other Versions
- . NET API
- PHP Api-1.0-other Versions
- Perl API
- Python API
- Ruby API
- Curator Index Management
- Rivers-1.5-other versions
- Community contributions
Elasticsearch deployment and basic usage on NAS