dutchcoders/slackarchive

nc: bad address 'elasticsearch'

psifertex opened this issue · 17 comments

When trying to docker-compose run according to the initial instruction setup.

I even tried adding elasticsearch to /etc/hosts for 127.0.0.1, but that didn't help either. Looks like it's actually a setting from within one of the instances?

For reference, I took a fresh AWS EC Linux 2 instance and:

sudo yum update
sudo yum install git
sudo yum install docker
sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
git clone https://github.com/dutchcoders/slackarchive-docker
cd slackarchive-docker #STEP IS MISSING FROM INSTRUCTIONS
cp slackarchive/config.yaml.sample slackarchive/config.yaml
cp slackarchive-bot/config.yaml.sample slackarchive-bot/config.yaml
vi -p */config.yaml #made up random values for bot: token that matched api-token updated tokens to contain the xoxp legacy slack token, changed the password for MONGO_INITDB_ROOT_PASSWORD though it's not clear if it needs to be changed elsewhere? made up random values for cookies: authentication_key and encryption_key
sudo service docker start #not in instructions, but possibly OS specific
sudo docker network create slackarchive
sudo /usr/local/bin/docker-compose run --rm wait_f_dependencies #where error occurs

hmm, did you miss the create network step?

No, though I did leave it out in my script above. Edited to fix. Here's what happens when I try again:

sudo docker network create slackarchive
Error response from daemon: network with name slackarchive already exists

Unfortunately no.

I haven't been able to make any more progress. I might try again tonight using Ubuntu in case there's some distribution differences that impact things.

ch4se commented

Cool, I sent an email 👍

docker network create slackarchive running multiple time gives that error because it already exists, and you only have to run that command once.

What version of docker are you running, and could you send your docker ps output? Bad address elasticsearch Elasticsearch isn't starting correctly. What do the Elasticsearch logs say?

also get same error
followed instructions word for word including creating the docker network
nc: bad address 'elasticsearch'

installed on ubuntu 16.04 with latest docker-ce

looks like this error occurs as ES fails to start
...error in docker logs from the ES container

[2018-05-05T15:37:46,926][INFO ][o.e.n.Node               ] [] initializing ...
[2018-05-05T15:37:46,953][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Failed to create node environment
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.4.jar:5.6.4]
Caused by: java.lang.IllegalStateException: Failed to create node environment
	at org.elasticsearch.node.Node.<init>(Node.java:268) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.node.Node.<init>(Node.java:245) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.4.jar:5.6.4]
	... 6 more
Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
	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.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384) ~[?:?]
	at java.nio.file.Files.createDirectory(Files.java:674) ~[?:1.8.0_141]
	at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781) ~[?:1.8.0_141]
	at java.nio.file.Files.createDirectories(Files.java:767) ~[?:1.8.0_141]
	at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:221) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.node.Node.<init>(Node.java:245) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.4.jar:5.6.4]

this is due to the local volume mapped to ./elasticsearch/data , being given root permissions
if I change permissions of that dir to local user (in this case 'ubuntu') it works..

however getting memory issues with ES after this..
I also needed to set this :

sudo sysctl -w vm.max_map_count=262144

Exactly, those are common issues when running Elasticsearch containers. The owner needs to be set to UID 1000 (this is the docker default user) and vm.max_map_count needs to be increased.

@psifertex the nc: bad address 'elasticsearch' is almost certainly because ES has failed to start.
if you look at the docker logs for the ES container:
docker logs slackarchive-docker_elasticsearch_1
you will see (if and) why it has failed
in my case this was due to a disk/directory permissions issue.. once I had fixed the disk perms so the ES instance was able to read/wite to the local dir mapped to the ES docker volume, this all worked fine

#  Out of Memory Error (os_linux.cpp:2651), pid=1, tid=0x00007fafae3c8700
#
# JRE version:  (8.0_141-b16) (build )
# Java VM: OpenJDK 64-Bit Server VM (25.141-b16 mixed mode linux-amd64 compressed oops)
# Core dump written. Default location: /usr/share/elasticsearch/core or core.1

The VM I created only had 1GB ram total. Oh, looking through the config:

      - "ES_JAVA_OPTS=-Xms2048m -Xmx2048m"

So yeah, that won't work. Apparently no swap by default either.

Any reason performance would really be an issue for an instance only logging one slack? I might just crank down the java heap size and try that.

(AWS does have dedicated ES instances I could pop up as well that appear to run with 1gb of ram but then I'd have to re-configure the config to use that)

yeah Elastic recommend 4Gb ram for ES 5.x but it will run on less, but 1Gb I think way too small, especially if you running mongo and other containers on same instance
I used a t2.medium (2 cpu , 4Gb ram) - and it runs perfectly fine

AWS itself has a t2.micro.elasticsearchwith only 1gb of ram, so it certainly should be doable.

ch4se commented

I'm getting this issue now as well... Also using 2cpu 4gb ram.

[INFO ][o.e.n.Node               ] [] initializing ...
[2018-07-08T23:57:14,106][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Failed to create node environment
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.4.jar:5.6.4]
Caused by: java.lang.IllegalStateException: Failed to create node environment
        at org.elasticsearch.node.Node.<init>(Node.java:268) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.node.Node.<init>(Node.java:245) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.4.jar:5.6.4]
        ... 6 more
Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
        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.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384) ~[?:?]
        at java.nio.file.Files.createDirectory(Files.java:674) ~[?:1.8.0_141]
        at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781) ~[?:1.8.0_141]
        at java.nio.file.Files.createDirectories(Files.java:767) ~[?:1.8.0_141]
        at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:221) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.node.Node.<init>(Node.java:245) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.4.jar:5.6.4]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.4.jar:5.6.4]
        ... 6 more

This is I am getting running docker logs slackarchivedocker_elasticsearch_1
Using Ubuntu Xenial 4x89 64 bit Cores with 4GB Memory in scaleway and banging head since whole night lol

Just solved it with chown -R 1000:1000 elasticsearch if anyone is stuck