Search code examples
elasticsearchserviceinstallation

How to install elasticsearch as a service using brew


I want to use brew to install elasticsearch but I don't succeed to install it as a service to be able to start it like:

sudo service elasticsearch start

and to be able to stop it like:

sudo service elasticsearch stop

Do you know how I can do it?


Solution

  • EDIT: elasticsearch is no longer open source and so has been disabled in homebrew. Try opensearch instead. Thanks to the comments for pointing this out!


    In homebrew you don't need to install sth as a service in a special way. Install it as usual and start it as a service (if the formula supports it, which elasticsearch does).

    So to install:

    brew install elasticsearch
    

    and then to run as a service (with autostart on startup):

    brew services start elasticsearch
    

    Or, if you don't want/need a background service you can just run:

    elasticsearch
    

    To stop/kill, just press Ctrl+C on the terminal where you executed above command