emTr0
emTr0

Reputation: 77

Unable to set up Elasticsearch for Wagtail

I used the following guide so far:

http://docs.wagtail.io/en/v1.9/advanced_topics/performance.html

I added:

WAGTAILSEARCH_BACKENDS = {
    'default': {
        'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch',
        'INDEX': '{{ project_name }}',
    },
}

to my base.py. When I run $ ./manage.py update_index, I get the following output:

Updating backend: default
default: Rebuilding index {{ project_name }}
Traceback (most recent call last):
  File "./manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/wagtail/wagtailsearch/management/commands/update_index.py", line 120, in handle
    self.update_backend(backend_name, schema_only=options.get('schema_only', False))
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/wagtail/wagtailsearch/management/commands/update_index.py", line 73, in update_backend
    index = rebuilder.start()
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/wagtail/wagtailsearch/backends/elasticsearch.py", line 613, in start
    self.reset_index()
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/wagtail/wagtailsearch/backends/elasticsearch.py", line 609, in reset_index
    self.index.reset()
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/wagtail/wagtailsearch/backends/elasticsearch.py", line 598, in reset
    self.delete()
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/wagtail/wagtailsearch/backends/elasticsearch.py", line 499, in delete
    self.es.indices.delete(self.name)
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 73, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/elasticsearch/client/indices.py", line 200, in delete
    params=params)
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 318, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/home/emtr0/Env/emtr0dotcom/local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 123, in perform_request
    raise ConnectionError('N/A', str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f3b708fa210>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f3b708fa210>: Failed to establish a new connection: [Errno 111] Connection refused)

Thanks in advance.

EDIT UPDATE:

It looks like my Linode might not have enough RAM. I get the following error when trying to run ES with ./bin/elasticsearch after global install:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/emtr0/elasticsearch-5.3.0/hs_err_pid24719.log

Thanks.

Upvotes: 1

Views: 1720

Answers (2)

hellogoodsir
hellogoodsir

Reputation: 11

For people still having issues with this, make sure your Elasticsearch version and elasticsearch-py version are the same. Both elasticsearch and the py versions need to be installed. That fixed it for me.

Upvotes: 1

fabienheureux
fabienheureux

Reputation: 400

sorry I don't have enough reputation to comment directly under your question, I hope this will help you to get things sorted out:

  • install elasticsearch locally, run it, and then check if it's running (should be on port 9200) using a simple curl http://localhost:9200. If you get a JSON response, it's running 🎉

OR

  • setup a bonsai (http://bonsai.io) instance in order to have a hosted elasticsearch server running, and just copy-paste the bonsai's server URL into your config, but it can need a bit more settings (SSL etc), and is more limited in term of elasticsearch version

Bonus: if you are a macOS user, installing/running Elastic Search is as easy as brew install elasticsearch (maybe set a specific version though), and then elasticsearch if you don't mind about having it running in the foreground.

Upvotes: 0

Related Questions