第一步安装es。
我的es版本是 6.6.1。centos 版本是 7.2
Elastic 的底层是开源库 Lucene。但是,你没法直接用 Lucene,必须自己写代码去调用它的接口。Elastic 是 Lucene 的封装,提供了 REST API 的操作接口,开箱即用。
还有就是 对java 的版本要求是1.8以上
新es不允许使用root启动,所以先创建 新用户,并把文件所属给他
- adduser esuser
- chown -R esuser elasticsearch-6.6.1
然后修养/config/elasticsearch.yml ;我只记录一些需要修改的地方
- cluster.name: my-application #你的集群name
- network.host: 0.0.0.0 # 允许远程访问
- http.cors.enabled: true # 允许跨域访问
- http.cors.allow-origin: "*" # 允许跨域访问
配置系统 vim /etc/security/limits.conf(在文件最后添加)
* soft nproc 4096
* hard nproc 4096
root soft nproc 4096
root hard nproc 4096
# 以下配置解决如下错误
# max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
# memory locking requested for elasticsearch process but memory is not locked
esuser hard nofile 65536
esuser soft nofile 65536
esuser soft memlock unlimited
esuser hard memlock unlimited
[root@localhost bin]# sysctl -w vm.max_map_count=262144
vm.max_map_count = 655360
[root@localhost bin]# more /proc/sys/vm/max_map_count
继续配置 vim /etc/sudoers
root ALL=(ALL) ALL
esuser ALL=(ALL) ALL
然后切换到 新建用户,启动
su esuser
../bin/elasticsearch
浏览器输入你的地址 xxx:9200,出现es信息,成功。
- es 扩容很容易完成 ,
yml中的cluster_name 为集群名字,所有es节点这个值要相同
name为本节点的名字