Installing and using Elasticsearch

Source: Internet
Author: User
Tags kibana

Elasticsearch is a new member of the open source search platform, the real-time data analysis artifact, developed rapidly, based on Lucene, RESTful, distributed, cloud-oriented design, real-time search, full-text search, stability, high reliability, extensible, installation + easy to use, introduction are said to be very pleasant, Good to take out for a walk.

Did a simple test, in two identical virtual machines, 20 million or so data, Elasticsearch inserted data speed than MongoDB much slower (can endure), but search/query faster than 10 times times, this is only a single case, multi-machine cluster case Elasticsearch a better performance. The following installation steps are completed on Ubuntu Server 14.04 LTS.

Installing Elasticsearch

After upgrading the system, install Oracle Java 7, since Elasticsearch officially recommends using Oracle JDK 7, do not try JDK 8 and OpenJDK:

$ sudo apt-get update$ sudo apt-get upgrade$ sudo apt-get install software-properties-common$ sudo add-apt-repository PPA: webupd8team/java$ sudo apt-get update$ sudo apt-get install Oracle-java7-installer

Join Elasticsearch official source after installing Elasticsearch:

$ wget-o-Http://packages.elasticsearch.org/GPG-KEY-elasticsearch | Apt-key add-$ sudo echo "Deb Http://packages.elasticsearch.org/elasticsearch/1.1/debian stable main" >>/etc/apt/ sources.list$ sudo apt-get update$ sudo apt-get install Elasticsearch

Join the system startup file and start the Elasticsearch service, and curl to test if the installation was successful:

$ sudo update-rc.d elasticsearch defaults 1$ sudo/etc/init.d/elasticsearch start$ curl-x GET ' http://localhost:9200 ' {  "status": $,  "name": "Fer-de-Lance",  "version": {    "number": "1.1.1",    "Build_hash": " F1585F096D3F3985E73456DEBDC1A0745F512BBC ",    " Build_timestamp ":" 2014-04-16t14:27:12z ",    " Build_snapshot ": False,    "lucene_version": "4.7"  },  "tagline": "You Know, for Search"}

Elasticsearch cluster and data management interface Marvel very good, but only for the development environment free, if the tool is also free of invincible, the installation is very simple, complete restart service access http://192.168.2.172:9200/_plugin/ Marvel/can see the interface:

$ sudo/usr/share/elasticsearch/bin/plugin-i elasticsearch/marvel/latest$ Sudo/etc/init.d/elasticsearch Restart * Stopping Elasticsearch server                                           [OK] * starting Elasticsearch server                                           [OK]

Installing the Python client driver

Like MongoDB, we typically interact with programs and Elasticsearch, Elasticsearch also support client-side drivers in multiple languages, where only Python drivers are installed, and other languages can refer to official documents.

$ sudo apt-get install python-pip$ sudo pip install Elasticsearch

Write a simple program to import gene_info.txt data into the Elasticsearch:

#!/usr/bin/python#-*-coding:utf-8-*-import os, Os.path, SYS, Reimport csv, time, stringfrom datetime import DATETIMEFR     Om elasticsearch import elasticsearchdef import_to_db (): data = Csv.reader (open (' gene_info.txt ', ' RB '), delimiter= ' \ t ') Data.next () es = Elasticsearch () for row in Data:doc = {' tax_id ': row[0], ' GeneID ': row[1], ' Symbol ': row[2], ' Locustag ': row[3], ' synonyms ': row[4], ' dbxrefs '            : row[5], ' chromosome ': row[6], ' map_location ': row[7], ' description ': row[8], ' Type_of_gene ': row[9], ' symbol_from_nomenclature_authority ': row[10], ' full_name_from_nomenclature _authority ': row[11], ' nomenclature_status ': row[12], ' other_designations ': row[13], ' Mod Ification_date ': row[14]} res = Es.index (index= "gene", doc_type= ' Gene_info ', Body=doc) def main (): Import _to_db () if __name__ = = "__main__ ": Main () 

Kibana is a powerful data display client, integrated through plug-ins and Elasticsearch, installation is easy, download unzip on it, and then restart the Elasticsearch service to access Http://192.168.2.172:9200/ _plugin/kibana/will be able to see the interface:

$ wget https://download.elasticsearch.org/kibana/kibana/kibana-3.0.1.tar.gz$ tar zxvf kibana-3.0.1.tar.gz$ sudo mv kibana-3.0.1/usr/share/elasticsearch/plugins/_site$ Sudo/etc/init.d/elasticsearch Restart

Installing and using Elasticsearch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.