ElasticSearch 安装笔记
Jdk软件下载地址:https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
ElasticSearch软件下载地址:https://www.elastic.co/cn/start
Root用户下执行
1)创建elasticsearch用户组
groupadd elasticsearch
2)创建用户esuser并设置密码
useradd esuser
passwd espass
3)创建elasticsearch文件夹
mkdir -p /usr/local/elasticsearch
4)把所有权限给此文件夹
chmod -R 777 /usr/local/elasticsearch
5)用户esuser添加到elasticsearch用户组
usermod -G elasticsearch esuser
6)设置sudo权限,执行visudo命令,添加授权数据后保存
visudo
#在文档最后一行添加权限数据
esuser ALL=(ALL) ALL
esuser用户下执行
1)上传软件包到/usr/local/elasticsearch中并解压
tar -zxvf elasticsearch-7.11.1-linux-x86_64.tar.gz
2)解压完成后进入/usr/local/elasticsearch/elasticsearch-7.11.1创建文件夹
cd /usr/local/elasticsearch/elasticsearch-7.11.1
mkdir data
mkdir log
3)配置elasticsearch.yml添加数据后保存
cd /usr/local/elasticsearch/elasticsearch-7.11.1/config
vim elasticsearch.yml
#在文档最后添加如下数据 深坑一定注意 上下两个节点名请一致
cluster.name: es-user
node.name: 节点名
path.data: /usr/local/elasticsearch/elasticsearch-7.11.1/data
path.logs: /usr/local/elasticsearch/elasticsearch-7.11.1/log
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["服务器IP"]
cluster.initial_master_nodes: ["节点名"]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
http.cors.enabled: true
http.cors.allow-origin: "*"
4)修改jvm.options堆内存大小后保存
#由
-Xms1g
-Xmx1g
#修改为
-Xms2g
-Xmx2g
Root用户下执行
启动报如下错误
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
1)针对于第一个错误:
sudo vi /etc/security/limits.conf
#添加如下内容: 注意*不要去掉了保存后退出
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
2)针对于第二个错误
vim /etc/sysctl.conf
#追加如下内容并保存
vm.max_map_count=262144
#执行语句使配置文件生效
sysctl -p