Centos使用Docker安装elasticsearch

2 篇文章 0 订阅

查看官网最新版本7.12.1 ,下载镜像文件

docker pull elasticsearch:7.12.1

创建es文件夹,es下再创建三个目录conf、data、plugins,准备做数据挂载
为es文件夹添加777权限(不添加启动时会报错)

chmod -R 777 es

conf文件夹中添加配置文件elasticsearch.yml

cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.port: 9200
node.name: node-1
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
cluster.initial_master_nodes: ["node-1"]
indices.fielddata.cache.size: 50%

生成创建容器

docker run -itd -p 9200:9200 --name elasticsearch -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -v /docker/es/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /docker/es/data:/usr/share/elasticsearch/data -v /docker/es/plugins:/usr/share/elasticsearch/plugins --privileged=true elasticsearch:7.12.1

elasticsearch启动的时候经常出现的两个原因错误

ERROR: [2] bootstrap checks failed. You must address the points described in the following [2] lines before starting Elasticsearch.
bootstrap check failure [1] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
bootstrap check failure [2] of [2]: 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

第一个问题就是配置问题,默认配置是无法启动elasticsearch的,配置文件没有设置如下两项,就会出现第一个错误

node.name: node-1
cluster.initial_master_nodes: ["node-1"]

第二个问题意思就是vm.max_map_count 太小了,请至少增加到262144

查看vm.max_map_count

sysctl -a|grep vm.max_map_count

修改文件

vim /etc/sysctl.conf

![在这里插入图片描述](https://img-blog.csdnimg.cn/20210522124414489.png在这里插入图片描述
从指定的文件加载系统参数,如不指定即从/etc/sysctl.conf中加载

sysctl -p

再次查看,修改成功
在这里插入图片描述
重新启等docker,成功
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值