Friday, October 23, 2015

Create ElasticSearch cluster on single machine

I wanted to figure out how to create a multi-node ElasticSearch cluster on single machine. So i followed these instructions


  1. First i did download elasticsearch zip file.
  2. Create 3 folders in  like node1, node2 and node3
  3. Unzip elasticsearch.zip in each one of these folders and name the folder node1,node2,node3
  4. Then i opened the node1/config/elasticsearch.yml and i did change value of cluster.name to samarcluster and value of node.name to node1,node2 and node 3  as shown below.

Typical setup done with 3 nodes on a single machine

node1: 
cluster.name: samarcluster
node.name: "node1"
node.master: true
node.data: true
node2 : 
cluster.name: samarcluster
node.name: "node2"
node.master: false
node.data: true
node3 : 
cluster.name: samarcluster
node.name: "node3"
node.master: false
node.data: false

Next step was to install below Plugins
Marvel on each of the nodes by executing bin/plugin -i elasticsearch/marvel/latest
ElasticSearch-HQ on each of the nodes by executing bin/plugin -install royrusso/elasticsearch-HQ

Once all the 3 nodes are started, i could see them in marvel and elasticHQ as shown below.









Thursday, October 8, 2015

Elastic Search MongoDB Integration

Follow below steps to install elastic search, assuming mongoldb is already installed.


2) export ES_HOME=/Users/samaraarkotti/Documents/elasticsearch-1.7.2  
3) $ES_HOME/bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/2.7.1   (  https://github.com/elastic/elasticsearch-mapper-attachments )
4) $ES_HOME/bin/plugin -install com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.9 ( https://github.com/richardwilly98/elasticsearch-river-mongodb/ )
5) $ES_HOME/bin/plugin --install mobz/elasticsearch-head
6) $ES_HOME/bin/plugin -i elasticsearch/marvel/latest
7) start elastic search bin/elasticsearch

Optional Plugin to install 

$ES_HOME/bin/plugin --install lukas-vlcek/bigdesk ( To access Inquisitor, open http://localhost:9200/_plugin/bigdesk)
$ES_HOME/bin/plugin -install polyfractal/elasticsearch-inquisitor   ( To access Inquisitor, open http://localhost:9200/_plugin/inquisitor/

curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{"type": "mongodb","mongodb": {"db": "analytics","collection": "Article"},"index": {"name": "articleindex","type": "article"}}'
curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{"type": "mongodb","mongodb": {"db": "analytics","collection": "ViewsAndRatingDetails"},"index": {"name": "viewindex","type": "views"}}'



-- DELETE Plugins using curl or directly on web both articleindex and _river , once done , run above curl command to index again .


Reference 



--- if getting any error's converting your standalone mongodb to replicaset , follow below steps
1)start the server in your usual way (single instance)
2)connect to the instance with a similar command : ./mongo --port 27017
3)look at your databases : show dbs
4)if there is a db called local, connect to it:  use local
drop that database : db.dropDatabase()



--- if you are getting error saying _mongodb RIVER FAILED to start ,
1) Then delete the _river plugin ( curl -XDELETE 'http://localhost:9200/_river/mongodb' )
2) shutdown ES and restart


-- disable dynamic mapping  -- NOT WORKING

curl -XDELETE localhost:9200/articleindex    --- First delete the index
curl -XPUT localhost:9200/articleindex -d '{"index.mapper.dynamic": false}'

--added below in elasticsearch.yml under config folder 
you will also need to configure elastic search to accept requests from the browser using CORS ( cross origin site scripting). To enable CORS, add the following to elasticsearch's config file. Usually, this file is located near the elasticsearch  at config/elasticsearch.yml

http.cors:
  enabled: true
  allow-origin: /https?:\/\/localhost(:[0-9]+)?/
  
  

  
  
  

Create ElasticSearch cluster on single machine

I wanted to figure out how to create a multi-node ElasticSearch cluster on single machine. So i followed these instructions First i did...