Restart elasticsearch with Ansible


(Cédric) #1

Hello everybody,

I am using ES Ansible's playbooks (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

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

command 2

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

command 3

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

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


(Michael Russell) #2

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:

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


(Cédric) #3

awesome !

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

thank you @michael.russell


(system) #4

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