今天试着在VMware上面搭建es的集群
https://www.cnblogs.com/coder-lzh/p/9921827.html
[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]: 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]: 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]: 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"]
查看防火墙状态
firewall-cmd --state
停止firewall
systemctl stop firewalld.service
禁止firewall开机启动
systemctl disable firewalld.service
注意:如果不禁止开机自启每次打开防火墙都会自动开启,因而每次都要执行相同操作
解决办法,创建子用户。
在linux下需要注意。es默认不能用root用户启动。我们需要新建一个用户来启动。
groupadd es
adduser es-user -g 用户组 -p 密码 #新建一个es-user用户 密码可以省略
chown -R es-user:es /授予访问权限的文件/ #将这个用户赋予权限。
su es-user # 切换es-user用户
./elasticsearch -d #后台启动
可以看到绑定了两个端口:
解决了以上几个问题,es能够跑起来了,这时将VM克隆为3个,准备进行集群的搭建。
注:上面加粗字体会引发下文的异常7
在克隆虚拟机之前操作了es数据库,导致es data中存在了数据,同时把虚拟机克隆了,这是搭建集群就会报错,显示无法找到其他的节点。找出这个问题花了我一天的时间
在elasticsearch.yml配置的过程中,建议采用后台运行,观察logs,进行调试,elasticsearch后台运行的方法为-d作为参数,关闭的方法如下
ps -ef | grep elastic
kill -9 2382(进程号)
sh elasticsearch -d
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)
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
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 删除。