gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 02:53:50 29 4
gpt4 key购买 nike

我正在尝试添加 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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com