1.下载ElasticSearch 地tar包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.tar.gz
1.1 解压
tar xf elasticsearch-6.4.1.tar.gz
1.2 进入elasticsearch目录
cd elasticsearch-6.4.1
1.3 进入bin目录运行
cd bin
./elasticsearch
报错:不能以root 用户地方式启动创建用户和组
2. 创建es组
groupadd eszu
2.1 创建es用户
useradd chaopeng
2.2 指定用户密码
passwd chaopeng
2.3 修改文件所属用户
chown -R chaopeng elasticsearch-6.4.1
2.4 修改文件所属组
chgrp -R eszu elasticsearch-6.4.1
3. 切换用户启动elasticsearch
su chaopeng
./elasticsearch
这时候elasticsearch已经成功启动,我们来测试一下curl localhost:9200,如果得到了这些数据就说明成功了,但是在浏览器里面并不能访问,需要修改配置文件
3.1 配置elasticsearch端口和ip
进入config文件夹,里面有一个elasticsearch.yml文件,添加如下内容
network.host: 192.168.1.53
http.port: 9200
3.2 再次启动elasticsearch,报错如下
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3802] for user [esyonghu] 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]
第一个错误需要将当前用户的软硬调用限制调大
切换到root用户配置/etc/security/limits.conf
文件末尾添加:
chaopeng soft nofile 65536
chaopeng hard nofile 131072
chaopeng soft nproc 2048
chaopeng hard nproc 4096
第二个错误修改/etc/security/limits.d/20-nproc.conf 文件
chaopeng soft nproc 4096
第三个错误需要修改/etc/sysctl.conf,添加如下
vm.max_map_count=262144
需要使改文件生效,执行sysctl -p
切换到chaopeng用户启动elasticsearch
以后台方式启动
./bin/elasticsearch -d
结束elasticsearch
输入jps命令,杀死elasticsearch进程
如果绑定本地ip失败,那么在elasticsearch.yml里面加上
bootstrap.memory_lock: false
bootstrap.system_call_filter: false