Skip to content

Instantly share code, notes, and snippets.

@scalabl3
Last active September 26, 2019 12:09
Show Gist options
  • Save scalabl3/8046965 to your computer and use it in GitHub Desktop.
Save scalabl3/8046965 to your computer and use it in GitHub Desktop.
Install Elasticsearch 90.5 for Couchbase Integration on Mac via homebrew
These instructions are on Mac OS X, but it can easily be translated for any linux os too. The only differences will be to use default in elasticsearch.yml for vbuckets of 1024 (comment or take that line out). Also the paths to plugins, config, bin, etc. might be different as far as copying the couchbase_template.json over to config/templates.

On Mac I highly recommend just permanently increasing the max number of file descriptors allowed (unlimited is no longer a valid parameter):

$ cd /etc
$ vi launchd.conf
$ limit maxfiles 1000000 1000000

You can also do it temporarily (not saved for next reboot)

$ sudo launchctl limit maxfiles 1000000 1000000

To view the filedescriptor settings:

$ ulimit -n

Setup Elastic Search 90.5

Current version is 90.7, but I am not certain the plugin has been tested against it yet, so I am going to go with what the github repo says (https://github.com/couchbaselabs/elasticsearch-transport-couchbase).

$ cd /usr/local
$ brew update
$ brew versions elasticsearch | grep 90.5
$ git checkout 7a522af /usr/local/Library/Formula/elasticsearch.rb
$ brew install elasticsearch

Note: Since you did the git checkout on an older branch, in order to do a brew update in the future, it can be helpful to run $ git stash stash away the older checkout after the brew install, at least I find that to be simple enough

Elasticsearch version 90.5 should be installed now. You don't need to launch it yet, nor set it to launch automatically. First let's install plugin and set everything up.

Setup Elastic Search Config

Of course you can use any text editor you want (instead of vi)...

$ cd /usr/local/Cellar/elasticsearch/0.90.5
$ vi config/elasticsearch.yml

Insert this information at the bottom, remember Mac uses 64 vbuckets (partitions), you can put any password you want too, doesn't matter. You will use this in the Couchbase Admin console when you setup the Remote Cluster Reference.

couchbase.username: Administrator
couchbase.password: asdfasdf
couchbase.num_vbuckets: 64
couchbase.port: 9091
couchbase.maxConcurrentRequests: 1024

Install Elastic Search Plugins

  • Couchbase Transport
  • Elasticsearch-Head (browser based ElasticSearch explorer)
$ cd /usr/local/Cellar/elasticsearch/0.90.5
$ bin/plugin -install transport-couchbase -url http://packages.couchbase.com.s3.amazonaws.com/releases/elastic-search-adapter/1.2.0/elasticsearch-transport-couchbase-1.2.0.zip
$ bin/plugin -install mobz/elasticsearch-head

Add Template

By adding folder under config, it will automatically insert template on elasticsearch start, and if you change it, on restart.

$ cd cd /usr/local/Cellar/elasticsearch/0.90.5/config
$ mkdir templates
$ cd templates
$ cp /usr/local/var/lib/elasticsearch/plugins/transport-couchbase/couchbase_template.json .

Start up Elasticsearch

$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist

To Restart Elasticsearch

$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist

If you forget the load/unload (start/stop) commands

$ brew info elasticsearch

Browse Elasticsearch

Elastisearch Port

http://localhost:9200/

Elastisearch-Head Plugin

http://localhost:9200/_plugin/head/

Create a destination Index ("bucket") in Elasticsearch

Browse to http://localhost:9200/_plugin/head/
Click "New Index" button next to Cluser Overview
Enter a Index name (you will use this in the Couchbase Admin Console for setting up replication)

You can also do it manually via curl:

$ curl -XPUT http://localhost:9200/indexname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment