前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >elasticsearchVMware集群搭建笔记

elasticsearchVMware集群搭建笔记

原创
作者头像
逆回十六夜
修改2019-08-07 17:58:58
7160
修改2019-08-07 17:58:58
举报
文章被收录于专栏:逆回十六夜逆回十六夜

今天试着在VMware上面搭建es的集群

首先在一个CentOS的虚拟机上安装es的环境,我采用的是桥接和dhcp的方式,在运行es的过程中报了一些错,我查询了一份较为完备的资料,目前来看有以下几类:

解决方案部分摘抄自

https://blog.csdn.net/lixiaohai_918/article/details/89569611

https://www.cnblogs.com/coder-lzh/p/9921827.html

异常1:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

解决方案:

vim /etc/security/limits.conf文件,添加以以下两行即可解决

* soft nofile 65535

* hard nofile 65535

异常2:

[2]: max number of threads [3818] for user [admin] is too low, increase to at least [4096]

解决方案:

vim /etc/security/limits.conf文件,添加以下两行即可解决

* soft nproc 4096

* hard nproc 4096

异常3

[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方案:

vim /etc/sysctl.conf 文件,添加以下一行即可解决

vm.max_map_count=262144

异常4

[4]: 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

解决方案:

vim /usr/local/elasticsearch/elasticsearch-7.0.0/config/elasticsearch.yml 文件,添加一下行即可解决

cluster.initial_master_nodes: ["node-1"]

异常5

外网访问不到问题

查看防火墙状态

代码语言:text
复制
firewall-cmd --state

停止firewall

代码语言:text
复制
systemctl stop firewalld.service

禁止firewall开机启动

代码语言:text
复制
systemctl disable firewalld.service 

注意:如果不禁止开机自启每次打开防火墙都会自动开启,因而每次都要执行相同操作

异常6

不允许root用户启动。

解决办法,创建子用户。

在linux下需要注意。es默认不能用root用户启动。我们需要新建一个用户来启动。

groupadd  es

adduser  es-user   -g 用户组  -p 密码    #新建一个es-user用户  密码可以省略

chown  -R   es-user:es /授予访问权限的文件/   #将这个用户赋予权限。

su es-user            # 切换es-user用户

./elasticsearch -d  #后台启动

可以看到绑定了两个端口:

  • 9300:集群节点间通讯接口
  • 9200:客户端访问接口 

解决了以上几个问题,es能够跑起来了,这时将VM克隆为3个,准备进行集群的搭建。

注:上面加粗字体会引发下文的异常7

异常7

VMWare操作的额外报错!!!!

在克隆虚拟机之前操作了es数据库,导致es data中存在了数据,同时把虚拟机克隆了,这是搭建集群就会报错,显示无法找到其他的节点。找出这个问题花了我一天的时间

elasticsearch.yml的配置(参考资料:从Lucene到Elasticsearch全文检索实战(姚攀))

在elasticsearch.yml配置的过程中,建议采用后台运行,观察logs,进行调试,elasticsearch后台运行的方法为-d作为参数,关闭的方法如下

1.查找ES进程

ps -ef | grep elastic

2.杀掉ES进程

kill -9 2382(进程号)

3.重启ES

sh elasticsearch -d

es的最简配置

Node1:

cluster.name:test

node.name: node1

node.master: true

node.data: true

network.host: 192.168.43.80

http.port: 9200

http.cors.enabled: true

http.cors.allow-origin: "*"

discovery.zen.ping.unicast.hosts: ["192.168.43.80","192.168.43.198"]

cluster.initial_master_nodes: ["node1", "node2"] //这个不能省,否则会报错(es7)

Node2:

cluster.name:test

node.name: node1

node.master: true

node.data: true

network.host: 192.168.43.198

http.port: 9200

http.cors.enabled: true

http.cors.allow-origin: "*"

discovery.zen.ping.unicast.hosts: ["192.168.43.80","192.168.43.198"]

node.name: node2master_nodes: ["node1", "node2"] //这个不能省,否则会报错(es7)2

Node3:

cluster.name:test

node.name: node2

node.master: false

node.data: false

network.host: 192.168.43.236

http.port: 9200

http.cors.enabled: true

http.cors.allow-origin: "*"

discovery.zen.ping.unicast.hosts: ["192.168.43.80","192.168.43.198"]

其他:

node3作为client节点(可以不添加,有助于处理高并发访问的需求)

head查看配置情况

集群搭建完成!

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 首先在一个CentOS的虚拟机上安装es的环境,我采用的是桥接和dhcp的方式,在运行es的过程中报了一些错,我查询了一份较为完备的资料,目前来看有以下几类:
  • 解决方案部分摘抄自
  • https://blog.csdn.net/lixiaohai_918/article/details/89569611
  • 异常1:
  • 异常2:
  • 异常3
  • 异常4
  • 异常5
  • 外网访问不到问题
  • 异常6
  • 不允许root用户启动。
  • 异常7
    • VMWare操作的额外报错!!!!
    • elasticsearch.yml的配置(参考资料:从Lucene到Elasticsearch全文检索实战(姚攀))
    • es的最简配置
      • Node1:
        • Node2:
          • Node3:
          • 其他:
          相关产品与服务
          Elasticsearch Service
          腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档