无法设置Elasticsearch for Wagtail

时间:2017-03-16 17:36:08

标签: python linux django elasticsearch wagtail

到目前为止,我使用了以下指南:

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

我补充说:

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

到我的base.py.当我运行$ ./manage.py update_index时,我得到以下输出:

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)

提前致谢。

编辑更新:

看起来我的Linode可能没有足够的RAM。在全局安装后尝试使用./bin/elasticsearch运行ES时出现以下错误:

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

感谢。

2 个答案:

答案 0 :(得分:1)

对于仍有问题的人,请确保您的 Elasticsearch 版本和 elasticsearch-py 版本相同。 elasticsearch 和 py 版本都需要安装。那为我修好了。

答案 1 :(得分:0)

抱歉,我没有足够的声誉直接在您的问题下发表评论,我希望这有助于您解决问题:

  • 在本地安装elasticsearch,运行它,然后使用简单的curl http://localhost:9200检查它是否正在运行(应该在端口9200上)。如果您收到JSON响应,则表示正在运行

OR

  • 设置一个盆景(http://bonsai.io)实例,以便运行托管的弹性搜索服务器,只需将盆景的服务器URL复制粘贴到您的配置中,但它可能需要更多设置( SSL等),并且在弹性搜索版本方面更受限制

奖励:如果您是macOS用户,安装/运行Elastic Search就像brew install elasticsearch一样简单(虽然可能设置了特定版本),然后elasticsearch如果您不介意关于让它在前台运行。