ruby-on-rails - Ruby on Rails - searchkick gem : cluster_block_exception - FORBIDDEN/12/index read-only/allow delete (api) - status":403

标签 ruby-on-rails ubuntu elasticsearch searchkick

我正在尝试添加 elasticsearch使用 searchkick gem 访问我的 Ruby on Rails 网站.我目前使用的操作系统是 Ubuntu 16.04 TLS。

我安装了 elasticsearch 6.2.2,到目前为止,默认配置没有改变。

当我运行 curl -X GET 'http://localhost:9200'我得到:

{
    "name" : "viTKcuN",
    "cluster_name" : "elasticsearch",
    "cluster_uuid" : "aHCpbpvoQd2sieJRWtqI7g",
    "version" : {
        "number" : "6.2.2",
        "build_hash" : "10b1edd",
        "build_date" : "2018-02-16T19:01:30.685723Z",
        "build_snapshot" : false,
        "lucene_version" : "7.2.1",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
    },
    "tagline" : "You Know, for Search"
}

我想这就是所需的输出。

然后我添加了 gem 'searchkick', '~> 3.0'到我的 Gemfile,运行 bundle install并添加了 searchkick到我的模型。

但是,运行 Activity.reindex在终端结果中:

Activity.reindex: command not found

正在运行 rake searchkick:reindex CLASS=Activity导致了愚蠢的错误:

rails searchkick earchkick::ImportError: {"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"} on item with id '1'

我尝试运行 curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

然后重新运行 rake searchkick:reindex CLASS=Activity再次导致以下结果:

Elasticsearch::Transport::Transport::Errors::Forbidden: [403] {"error":{"root_cause":[{"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}],"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"},"status":403}

我还尝试添加 searchkick settings: {blocks: {read_only: false}}到 Activity 模型,但在运行 rake searchkick:reindex CLASS=Activity 时出现相同的错误再次。

我该如何解决这个问题。

最佳答案

当我运行 rspec 测试时,以下对我有用,并且第一个 dB 插入设置测试 db env 失败并出现此 Elasticsearch 错误。从 here 中提取的修复程序, 关键观察:

By default, Elasticsearch installed with homebrew on Mac OS goes into read-only mode when you have less than 5% of free disk space.

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

关于ruby-on-rails - Ruby on Rails - searchkick gem : cluster_block_exception - FORBIDDEN/12/index read-only/allow delete (api) - status":403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49171265/

相关文章:

c++ - 如何在 Ubuntu Qt 中获取事件窗口标题?

elasticsearch - 使用 ElasticSearch 模拟 SQL LIKE 搜索

elasticsearch - ElasticSearch-Net NEST搜索

elasticsearch - ElasticSearch 6.8不会先按完全匹配进行排序

ruby-on-rails - Rails - 对 AJAX 和非 AJAX 请求使用相同的部分形式

ruby-on-rails - PG::UndefinedTable: 错误: 表 "table-name"不存在

c++ - 如何在vscode中设置 "include path"来编译c++

ruby-on-rails - 删除 Rails 中以特定字符串开头的 cookie

ruby-on-rails - Ynaqdhm 的含义?

ubuntu - 从 Ubuntu 构建 Unity3D