I can not run elasticsearch command

OS: Manjaro

STEPS:

  1. I was following this tutorial in order to install elasticsearch

  2. If I'm trying to run elasticsearch I will get this error:

    /usr/bin/elasticsearch-env: line 128: cd: /usr/share/elasticsearch/config: Permission denied
    bin/elasticsearch-env: line 128: cd: /usr/share/elasticsearch/config: Permission denied

  3. I've checked the permissions via ls -l and there are all set to my user vlad

    [vlad@vlad-tuf ~]$ ls -l ../../usr/share/elasticsearch/        
    total 568
    drwxrwxrwx 1 vlad          vlad             872 dec 14 18:54 bin
    lrwxrwxrwx 1 vlad          vlad              18 oct 16 14:01 config -> /etc/elasticsearch
    lrwxrwxrwx 1 vlad          vlad              22 oct 16 14:01 data -> /var/lib/elasticsearch
    drwxrwxrwx 1 vlad          vlad            1938 dec 14 18:54 lib
    -rwxrwxrwx 1 vlad          vlad           13675 oct 16 14:01 LICENSE.txt
    lrwxrwxrwx 1 vlad          vlad              22 oct 16 14:01 logs -> /var/log/elasticsearch
    drwxrwxrwx 1 vlad          vlad            1306 dec 14 18:54 modules
    -rwxrwxrwx 1 vlad          vlad          544318 oct 16 14:01 NOTICE.txt
    drwxr-xr-x 1 elasticsearch elasticsearch      0 oct 16 14:01 plugins
    -rwxrwxrwx 1 vlad          vlad            7007 oct 16 14:01 README.asciidoc
  1. If I'm going to run with sudo elasticsearch I will get:
    Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: JsonParseException[Duplicate field 'http.cors.allow-origin'
     at [Source: (sun.nio.ch.ChannelInputStream); line: 91, column: 23]];
            at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1100)
            at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1073)
            at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:83)
            at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:100)
            at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:91)
            at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
            at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
            at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:91)
            at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
            at org.elasticsearch.cli.Command.main(Command.java:90)
            at org.elasticsearch.common.settings.KeyStoreCli.main(KeyStoreCli.java:43)
    Caused by: com.fasterxml.jackson.core.JsonParseException: Duplicate field 'http.cors.allow-origin'
     at [Source: (sun.nio.ch.ChannelInputStream); line: 91, column: 23]
            at com.fasterxml.jackson.core.json.JsonReadContext._checkDup(JsonReadContext.java:204)
            at com.fasterxml.jackson.core.json.JsonReadContext.setCurrentName(JsonReadContext.java:198)
            at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:399)
            at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:52)
            at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:645)
            at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:620)
            at org.elasticsearch.common.settings.Settings.access$400(Settings.java:82)
            at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1096)
            ... 10 more
    OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
    Exception in thread "main" 2020-12-15 01:10:54,611 main ERROR No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
    SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: JsonParseException[Duplicate field 'http.cors.allow-origin'
     at [Source: (sun.nio.ch.ChannelInputStream); line: 91, column: 23]];
            at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1100)
            at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1073)
            at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:83)
            at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:100)
            at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:91)
            at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
            at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
            at org.elasticsearch.cli.Command.main(Command.java:90)
            at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
            at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
    Caused by: com.fasterxml.jackson.core.JsonParseException: Duplicate field 'http.cors.allow-origin'
     at [Source: (sun.nio.ch.ChannelInputStream); line: 91, column: 23]
            at com.fasterxml.jackson.core.json.JsonReadContext._checkDup(JsonReadContext.java:204)
            at com.fasterxml.jackson.core.json.JsonReadContext.setCurrentName(JsonReadContext.java:198)
            at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:399)
            at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:52)
            at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:645)
            at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:620)
            at org.elasticsearch.common.settings.Settings.access$400(Settings.java:82)
            at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1096)

Can any of you help me to understand what I'm doing wrong in order to run this elastic search?

Welcome to our community! :smiley:

Did you check that?

Yes, and I've fix that but now I'm having another error:

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[2020-12-15T11:52:41,626][INFO ][o.e.n.Node               ] [vlad-tuf] version[7.9.2], pid[11831], build[default/tar/unknown/2020-10-16T11:11:08.982855Z], OS[Linux/5.8.18-1-MANJARO/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/11.0.8/11.0.8+10]
[2020-12-15T11:52:41,628][INFO ][o.e.n.Node               ] [vlad-tuf] JVM home [/usr/lib/jvm/java-11-openjdk]
[2020-12-15T11:52:41,629][INFO ][o.e.n.Node               ] [vlad-tuf] JVM arguments [-Xshare:auto, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dio.netty.allocator.numDirectArenas=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.locale.providers=SPI,COMPAT, -Xms6g, -Xmx6g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Djava.io.tmpdir=/tmp/elasticsearch-7163940377662335192, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -XX:MaxDirectMemorySize=3221225472, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config, -Des.distribution.flavor=default, -Des.distribution.type=tar, -Des.bundled_jdk=false]
[2020-12-15T11:52:43,949][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [aggs-matrix-stats]
[2020-12-15T11:52:43,949][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [analysis-common]
[2020-12-15T11:52:43,950][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [constant-keyword]
[2020-12-15T11:52:43,951][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [flattened]
[2020-12-15T11:52:43,951][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [frozen-indices]
[2020-12-15T11:52:43,952][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [ingest-common]
[2020-12-15T11:52:43,952][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [ingest-geoip]
[2020-12-15T11:52:43,953][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [ingest-user-agent]
[2020-12-15T11:52:43,953][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [kibana]
[2020-12-15T11:52:43,954][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [lang-expression]
[2020-12-15T11:52:43,954][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [lang-mustache]
[2020-12-15T11:52:43,955][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [lang-painless]
[2020-12-15T11:52:43,955][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [mapper-extras]
[2020-12-15T11:52:43,955][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [parent-join]
[2020-12-15T11:52:43,956][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [percolator]
[2020-12-15T11:52:43,956][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [rank-eval]
[2020-12-15T11:52:43,957][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [reindex]
[2020-12-15T11:52:43,957][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [repository-url]
[2020-12-15T11:52:43,958][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [search-business-rules]
[2020-12-15T11:52:43,958][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [searchable-snapshots]
[2020-12-15T11:52:43,959][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [spatial]
[2020-12-15T11:52:43,959][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [systemd]
[2020-12-15T11:52:43,960][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [tasks]
[2020-12-15T11:52:43,960][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [transform]
[2020-12-15T11:52:43,961][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [transport-netty4]
[2020-12-15T11:52:43,961][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [vectors]
[2020-12-15T11:52:43,961][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [wildcard]
[2020-12-15T11:52:43,962][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-analytics]
[2020-12-15T11:52:43,962][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-async]
[2020-12-15T11:52:43,963][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-async-search]
[2020-12-15T11:52:43,963][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-autoscaling]
[2020-12-15T11:52:43,964][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-ccr]
[2020-12-15T11:52:43,964][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-core]
[2020-12-15T11:52:43,965][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-data-streams]
[2020-12-15T11:52:43,965][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-deprecation]
[2020-12-15T11:52:43,966][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-enrich]
[2020-12-15T11:52:43,966][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-eql]
[2020-12-15T11:52:43,967][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-graph]
[2020-12-15T11:52:43,967][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-identity-provider]
[2020-12-15T11:52:43,968][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-ilm]
[2020-12-15T11:52:43,968][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-logstash]
[2020-12-15T11:52:43,969][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-ml]
[2020-12-15T11:52:43,969][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-monitoring]
[2020-12-15T11:52:43,969][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-ql]
[2020-12-15T11:52:43,970][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-rollup]
[2020-12-15T11:52:43,970][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-security]
[2020-12-15T11:52:43,971][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-sql]
[2020-12-15T11:52:43,971][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-stack]
[2020-12-15T11:52:43,971][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-voting-only-node]
[2020-12-15T11:52:43,971][INFO ][o.e.p.PluginsService     ] [vlad-tuf] loaded module [x-pack-watcher]
[2020-12-15T11:52:43,972][INFO ][o.e.p.PluginsService     ] [vlad-tuf] no plugins loaded
[2020-12-15T11:52:44,029][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [vlad-tuf] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:174) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127) ~[elasticsearch-cli-7.9.2.jar:7.9.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.9.2.jar:7.9.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.9.2.jar:7.9.2]
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
        at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:301) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.node.Node.<init>(Node.java:344) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.node.Node.<init>(Node.java:277) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:227) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:227) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) ~[elasticsearch-7.9.2.jar:7.9.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.9.2.jar:7.9.2]
        ... 6 more
uncaught exception in thread [main]
java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
        at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:301)
        at org.elasticsearch.node.Node.<init>(Node.java:344)
        at org.elasticsearch.node.Node.<init>(Node.java:277)
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:227)
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:227)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
For complete error details, refer to the log at /usr/share/elasticsearch/logs/elasticsearch.log

Could you help me also with this?

A node is already running or /usr/share/elasticsearch/data is not writable:

failed to obtain node locks, tried [[/usr/share/elasticsearch/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?

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