Skip to content

Instantly share code, notes, and snippets.

@jpalala
Created September 11, 2015 08:28
Show Gist options
  • Save jpalala/ab3c33dd9ee5a6efbdae to your computer and use it in GitHub Desktop.
Save jpalala/ab3c33dd9ee5a6efbdae to your computer and use it in GitHub Desktop.
setting up elasticsearch on your mac with brew

Install va homebrew

If you don't have homebrew installed - get homebrew here

Then run: brew install elasticsearch

Configuration

Update the elasticsearch configuration file in /usr/local/etc/elasticsearch/elasticsearch.yml.

Set the value below to false:

discovery.zen.ping.multicast.enabled: false #(it's true by default)

How to start it

Other sources say to use a removed brew services command. You get it via brew tap gapple/services. Then you're supposed to run brew services start <package-to-start>.

If brew services start elasticsearch doesn't work for you, check the instructions when you run brew info elasticsearch.

Mine says:

To have launchd start elasticsearch at login:
  ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents
Then to load elasticsearch now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
Or, if you don't want/need launchctl, you can just run:
  elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml

Sources

@mtvillwock
Copy link

Thank you to @JayRizzo and @demiurg for helping me debug this!

@zaidhaider9
Copy link

I had the same issue and it was resolved by the steps suggested by @nyaapass

Hi @JayRizzo, maybe the outdated elasticsearch plugin you have installed caused this problem.

Thanks for your guide to checkout the error.
I also got the Connection Refused Issue in brew services start elasticsearch.

Then I follow your way, simply ran elasticsearch, also got the Cannot open file logs/gc.log error (never mind this),
and when I continue to look through the error message, there is another error exception:

[WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [z0qDgIg] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: Plugin [analysis-smartcn] was built for Elasticsearch version 6.2.4 but version 6.5.4 is running
	at xxx
Caused by: java.lang.IllegalArgumentException: Plugin [analysis-smartcn] was built for Elasticsearch version 6.2.4 but version 6.5.4 is running
	at xxx

It seems like that I have upgraded elasticsearch by brew upgrade, but I nerver upgrade the analysis-smartcn plugin.
Then I upgrade the plugin by reinstall it:

sudo elasticsearch-plugin remove analysis-smartcn
sudo elasticsearch-plugin install analysis-smartcn

After that, not only simply run elasticsearch but also run brew services start elasticsearch can start elasticsearch successfully.

Thanks. This helped me.

@TheCorp
Copy link

TheCorp commented Aug 9, 2019

Just in case this helps anyone, you should make sure to update the correct JVM logging line depending on what version you have locally.

Most of the examples mention the JVM8 line but I had to modify the JVM9 line.

I also noticed that the jvm.properties.default file actually has the correct locally correct directories listed, I wonder why...

Incorrect in jvm.options
jvm.options:8:-Xloggc:/tmp/logs_gc.log
jvm.options:9-:-Xlog:gc*,gc+age=trace,safepoint:file=/tmp/logs_gc.log:utctime,pid,tags:filecount=32,filesize=64m

Correct in jvm.properties.default!
jvm.options.default:8:-Xloggc:/usr/local/var/log/elasticsearch/gc.log
jvm.options.default:9-:-Xlog:gc*,gc+age=trace,safepoint:file=/usr/local/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m

@daolvcntt
Copy link

If you add line discovery.zen.ping.multicast.enabled you won't be able to start the server so don't add that line

@TheCorp
Copy link

TheCorp commented Dec 25, 2019

Hah someone mentioned that back in 2017 - " FanaHOVA commented on Feb 6, 2017" - but worth repeating :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment