elasticsearch常见错误解决办法

1、elasticsearch 启动报错 max virtual memory areas vm.max_map_count [65530] is too low, increase to at leas

1.1、问题原因

字面意思,vm.max_map_count这个参数太小,应该至少调整到262144,首先看一下这个参数是干啥的吧。这个参数的解释,来自
https://www.jianshu.com/p/4f031b5366df
的原文:
“This file contains the maximum number of memory map areas a process may have. Memory map areas are used as a side-effect of calling malloc, directly by mmap and mprotect, and also when loading shared libraries.

While most applications need less than a thousand maps, certain programs, particularly malloc debuggers, may consume lots of them, e.g., up to one or two maps per allocation.
The default value is 65536.”
翻译:
max_map_count文件包含限制一个进程可以拥有的VMA(虚拟内存区域)的数量。虚拟内存区域是一个连续的虚拟地址空间区域。在进程的生命周期中,每当程序尝试在内存中映射文件,链接到共享内存段,或者分配堆空间的时候,这些区域将被创建。调优这个值将限制进程可拥有VMA的数量。限制一个进程拥有VMA的总数可能导致应用程序出错,因为当进程达到了VMA上线但又只能释放少量的内存给其他的内核进程使用时,操作系统会抛出内存不足的错误。如果你的操作系统在NORMAL区域仅占用少量的内存,那么调低这个值可以帮助释放内存给内核用。

1.2、解决办法

解决办法来自
https://blog.csdn.net/jiankunking/article/details/65448030

1、切换到root用户修改配置sysctl.conf

vi /etc/sysctl.conf 

2、添加 vm.max_map_count=655360,并运行如下命令

sysctl -p

3、然后,重新启动elasticsearch,即可启动成功。

2、Elasticsearch exception [type=cluster_block_exception, reason=blocked by: [FORBIDDEN/12/index read-only/ allow delete (api)];]

或者类似如下错误

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

2.2、问题原因

索引是只读状态。需要变更为非只读状态

2.2、解决办法

执行

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/你的索引名称/_settings -d '{"index.blocks.read_only_allow_delete": null}' 

或者直接在postman发送http请求如下:

PUT http://127.0.0.1:9200/索引名称/_settings
{
"index.blocks.read_only_allow_delete": null
}

3、bootstrap checks failed

the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

3.1 解决办法

elasticsearch.yml 配置文件中 添加:

cluster.initial_master_nodes: ["node-1"]

其中 node-1 为elasticsearch.yml 配置文件上面配置的 node.name 的值

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值