1.软件环境
Linux服务器是CentOS 7.x
ElasticSearch版本:elasticsearch-7.2.0
JDK:JDK1.8
2.下载elasticsearch-7.2.0
链接:https://pan.baidu.com/s/1iIzZjw3TQV3MrZinVdp5Zg
提取码:34uv
3.解压到/opt目录下
tar -avxf elasticsearch-7.2.0-linux-x86_64.tar.gz
4.进入解压后的elasticsearch目录:
(1)新建data目录:
mkdir data
(2)修改config/elasticsearch.yml:
vim config/elasticsearch.yml
取消下列项注释并修改:
cluster.name: my-application #集群名称
node.name: node-1 #节点名称
#数据和日志的存储目录
path.data: /opt/elasticsearch-7.2.0/data
path.logs: /opt/elasticsearch-7.2.0/logs
#设置绑定的ip,设置为0.0.0.0以后就可以让任何计算机节点访问到了
network.host: 0.0.0.0
http.port: 9200 #端口
#设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前是单机,放入一个节点即可
cluster.initial_master_nodes: ["node-1"]
修改完毕后,:wq 保存退出vim
从5.0开始 elasticsearch 安全级别提高了 不允许采用root帐号启动 所以我们要添加一个用户用来启动 elasticsearch
5.新加一个用户用来启动elasticsearch
adduser es
passwd es
改一下es目录所属用户:
chown es /opt/elasticsearch-7.2.0/ -R
vim 编辑 /etc/security/limits.conf,在末尾加上:
es soft nofile 65536
es hard nofile 65536
es soft nproc 4096
es hard nproc 4096
vim 编辑 vim /etc/security/limits.d/20-nproc.conf,将* 改为用户名(es):
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
es soft nproc 4096
root soft nproc unlimited
vim 编辑 /etc/sysctl.conf,在末尾加上:
vm.max_map_count = 655360
执行:
sysctl -p
6.登录刚才新建的es用户,并启动elasticsearch,OK
su es
./bin/elasticsearch
或者后台启动:
./bin/elasticsearch -d
查看进程:
ps -ef|grep elasticsearch
验证是否启动成功:
curl http://192.168.16.137:9200
或者:
表示安装成功。