# Restart elasticsearch with Ansible

**URL:** <https://discuss.elastic.co/t/restart-elasticsearch-with-ansible/137382>\
**Category:** Elasticsearch\
**Created:** [June 26, 2018, 8:13am UTC](https://discuss.elastic.co/t/restart-elasticsearch-with-ansible/137382 "2018-06-26T08:13:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cedbale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cedbale/32/32687_2.png) [@cedbale](https://discuss.elastic.co/u/cedbale)\
**Post date:** [June 26, 2018, 8:13am UTC](https://discuss.elastic.co/t/restart-elasticsearch-with-ansible/137382/1 "2018-06-26T08:13:04Z")

</div>

Hello everybody,

I am using ES [Ansible's playbooks](https://github.com/elastic/ansible-elasticsearch) (on Debian 9 - I only have a single ES node) to install my environment and i am not able to restart the service after a process kill. I can not found any clear description on how to restart it with Ansible or directly from the machine.  
I had changed my network IPs so i need now to restart it to let ES listen on the appropriate IP.  
The commands i tried was :

command 1

```auto
sudo /etc/init.d/elasticsearch start
/etc/init.d/elasticsearch: command not found

```

command 2

```auto
sudo service elasticsearch start
Failed to start elasticsearch.service: Unit elasticsearch.service not found.

```

command 3

```auto
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sudo /bin/systemctl start elasticsearch.service
Failed to enable unit: File elasticsearch.service: No such file or directory

```

command 4, when i try to start it manually

```auto
cd /usr/share/elasticsearch/ && ./bin/elasticsearch -Epath.conf=/etc/elasticsearch/node1

2018-06-26 08:10:54,937 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:585)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:322)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
        at org.apache.logging.log4j.core.jmx.Server.register(Server.java:389)
        at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:167)
        at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:140)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:556)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:206)
        at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:220)
        at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:197)
        at org.elasticsearch.common.logging.LogConfigurator.configureStatusLogger(LogConfigurator.java:175)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:143)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:122)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:307)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)

Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.AccessDeniedException: /etc/elasticsearch/node1
Likely root cause: java.nio.file.AccessDeniedException: /etc/elasticsearch/node1
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
        at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
        at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
        at java.nio.file.Files.readAttributes(Files.java:1737)
        at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
        at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
        at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
        at java.nio.file.Files.walkFileTree(Files.java:2662)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:150)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:122)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:307)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)
Refer to the log for complete error details.

```

This last error seems to come from right file/folder access but i do not really know which files/folders i need to adapt.  
Do you have any suggestion to solve my problem on the process to apply ?

thx in advance

---

<div class="post-metadata">

**Author:** ![michael.russell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael.russell/32/27889_2.png) [@michael.russell](https://discuss.elastic.co/u/michael.russell)\
**Post date:** [June 27, 2018, 8:50am UTC](https://discuss.elastic.co/t/restart-elasticsearch-with-ansible/137382/2 "2018-06-27T08:50:22Z")

</div>

Hi @cedbale

This playbook uses a custom service name because it supports running multiple instances of elasticsearch on the same node. You can find the service name by running:

```auto
systemctl | grep elasticsearch

```

The name will be `{{ es_instance_name }}_elasticsearch`. So if your node is called `node1` the service name should be `node1_elasticsearch`.

Cheers,

Micky

---

<div class="post-metadata">

**Author:** ![cedbale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cedbale/32/32687_2.png) [@cedbale](https://discuss.elastic.co/u/cedbale)\
**Post date:** [June 27, 2018, 9:10am UTC](https://discuss.elastic.co/t/restart-elasticsearch-with-ansible/137382/3 "2018-06-27T09:10:52Z")

</div>

awesome !

I have restarted the service with this command : `sudo service node1_elasticsearch start`

thank you @michael.russell

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 25, 2018, 9:12am UTC](https://discuss.elastic.co/t/restart-elasticsearch-with-ansible/137382/4 "2018-07-25T09:12:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
