ElasticSearch6.1.1集群搭建

先去官网下载压缩包,自行解决。我的虚拟机【CentOS7:192.168.127.129、130、131

环境要求,最少Java8,推荐131以后的

解压到/usr/local

tar -zxvf elasticsearch-6.1.1.tar.gz -C /usr/local

进入主目录

cd /usr/local/elasticsearch-6.1.1/

创建两个文件夹data和logs,分别存放索引和日志

[root@localhost elasticsearch-6.1.1]# mkdir data logs

 

存放索引的目录:/usr/local/elasticsearch-6.1.1/data

存放日志的目录:/usr/local/elasticsearch-6.1.1/logs

进入config目录

[root@localhost logs]# cd ../config/
[root@localhost config]# ll
total 16
-rw-rw----. 1 root root 2853 Dec 18 04:22 elasticsearch.yml
-rw-rw----. 1 root root 2672 Dec 18 04:22 jvm.options
-rw-rw----. 1 root root 5091 Dec 18 04:22 log4j2.properties

 

扫描二维码关注公众号,回复: 2177305 查看本文章

 修改elasticsearch.yml文件

[root@localhost config]# vim elasticsearch.yml

修改jvm

[root@localhost config]# vim jvm.options

这里大家自定义的大小,我每个虚拟机分配1g内存,给jvm一半,资源比较稀缺,你们可以根据自身条件调整。

启动ES

[root@localhost elasticsearch-6.1.1]# ./bin/elasticsearch

更改elasticsearch为普通用户权限,然后切换普通用户启动

 

[root@localhost elasticsearch-6.1.1]# chown -R admin /usr/local/elasticsearch-6.1.1/
[root@localhost elasticsearch-6.1.1]# su admin
[admin@localhost elasticsearch-6.1.1]$ ./bin/elasticsearch

 

当你认为ok的时候,其实并不ok 

 报错:

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

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

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

 官方文档解释:

[1]

[2]

[3]

查看系统虚拟内存:sysctl -a | grep "vm.max_map_count"

 

除了上面的注意,生产环境要Disable swapping,不过这个对我们当前影响不大

设置虚拟内存

[root@localhost elasticsearch-6.1.1]# sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144

[root@localhost elasticsearch-6.1.1]# vim /etc/security/limits.conf 

 

 修改limits.conf文件,添加如下内容:

<用户名><类型><属性><值>
admin soft nofile 65536
admin hard nofile 65536

admin soft nproc 4096
admin hard nproc 4096

 

打开防火墙:9200是http访问端口,9300是集群通信端口

打开防火墙端口:
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=9300/tcp --permanent
重启防火墙:systemctl restart firewalld

 

 切换普通用户,启动集群,可能很慢,一个一个启动,反正我的是卡死了。

启动集群:
[admin@localhost elasticsearch-6.1.1]$ ./bin/elasticsearch

 

三个都启动成功,简单来看根据是否抛异常

查看集群状态:执行linux命令~
curl -XGET '192.168.127.129:9200/_cat/health?v&pretty'
curl -XGET '192.168.127.129:9200/_cat/nodes?v&pretty'
或者通过浏览器访问:
http://192.168.127.129:9200/
http://192.168.127.129:9200/_cat/nodes?v&pretty
http://192.168.127.129:9200/_cat/health?v&pretty

 

猜你喜欢

转载自blog.csdn.net/ryuenkyo/article/details/81061116
今日推荐