下载安装
https://www.elastic.co/downloads/past-releases 官网的现在下载页面。进入以后选择对应的产品和版本进行下载。
上传安装文件并解压到centos
修改配置文件
修改elasticsearch.yml配置文件
里面修改如下:
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
修改/etc/sysctl.conf
切换回root 用户 执行
vim /etc/sysctl.conf
在文件最后面添加内容:
vm.max_map_count=262144
保存退出后,使用sysctl -p 刷新生效。
修改文件/etc/security/limits.conf
vim /etc/security/limits.conf
添加如下内容:
* hard nofile 65536
* soft nofile 65536
* soft nproc 2048
* hard nproc 4096
启动elasticesearch 可能还会报如下错误
max number of threads [1024] for user [lish] likely too low, increase to at least [4096]
解决:切换到root用户,进入limits.d目录下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
修改如下内容:
soft nproc 1024
#修改为
soft nproc 4096
创建非root用户
启动es需要使用非root用户,并且附有es安装文件的权限
创建 elasticsearch 用户组
groupadd elasticsearch
创建用户 es 并设置密码为es
useradd es
passwd es
用户es 添加到 elasticsearch 用户组
usermod -G elasticsearch es
设置sudo权限
visudo
在root ALL=(ALL) ALL 一行下面如下:es ALL=(ALL) ALL
添加成功保存后切换到es用户操作
su es
sudo chown -R es:elasticsearch 解压的安装es安装文件路径
启动
去换到安装文件的bin目录
启动时回显日志,关闭cenos对话框也会关闭es
./elasticsearch