Elasticsearch安装
- 解压缩
tar -zxf /opt/elasticsearch-7.4.2-no-jdk-linux-x86_64.tar.gz -C /usr/local/
- 修改环境变量
vi /etc/profile
配置环境变量
export ES_HOME=/usr/local/elasticsearch-7.4.2
export PATH=$PATH:$ES_HOME/bin
使环境变量生效
source /etc/profile
- 切换到es的安装路径的config下
cd /usr/local/elasticsearch-7.4.2/config/
- vi elasticsearch.yml
每一个节点的node.name和network.host需要进行修改
cluster.name: es_cluster
node.name: master
path.data: /usr/local/es/data
path.logs: /usr/local/es/logs
network.host: master
http.port: 9200
cluster.initial_master_nodes: ["master"]
discovery.seed_hosts: ["master","slave1","slave2","slave3"]
node.master: true
若要调整内存,修改配置文件jvm.options
1g改成512m
- 复制到其他节点
scp -r /usr/local/elasticsearch-7.4.2 slave1:/usr/local/
scp -r /usr/local/elasticsearch-7.4.2 slave2:/usr/local/
scp -r /usr/local/elasticsearch-7.4.2 slave3:/usr/local/
- 每个节点创建相关文件夹
mkdir -p /usr/local/es/data
mkdir -p /usr/local/es/logs
- 各节点启动
es不能以root用户启动,所以要先切换成用户es,启动后输出日志
su es
/usr/local/elasticsearch-7.4.2/bin/elasticsearch
启动后日志打印到后台
/usr/local/elasticsearch-7.4.2/bin/elasticsearch -d
若出现java.lang.RuntimeException: can not run elasticsearch as root错误的话,
则每个节点以root用户身份为elaticsearch创建用户并赋予相应权限
adduser es
passwd es
chown -R es:es /usr/local/elasticsearch-7.4.2/
chmod 770 /usr/local/elasticsearch-7.4.2/
chown -R es:es /usr/local/es/
chmod 770 /usr/local/es/
ll /usr/local/
chmod a+w /etc/security/limits.conf
chmod a+w /etc/sysctl.conf
#################主节点根据报错进行文件配置修改
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [1024] for user [es] 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]
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
每个进程最大同时打开文件数太小,可通过下面命令查看当前数量
ulimit -Hn
ulimit -Sn
查看能打开的最大线程个数
ulimit -Hu
ulimit -Su
解决①②vim /etc/security/limits.conf
es soft nofile 65536
es hard nofile 65536
es hard nproc 4096
es soft nproc 4096
后面数字根据实际情况修改后xshell重新登录连接
解决③vi /etc/sysctl.conf
vm.max_map_count = 262144
执行sysctl -p
解决④vim /usr/local/elasticsearch-7.4.2/config/elasticsearch.yml
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#################3个子节点根据报错进行文件配置修改
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [1024] for user [es] 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]
解决①②vim /etc/security/limits.conf
es soft nofile 65535
es hard nofile 65535
es hard nproc 4096
es soft nproc 4096
后面数字根据实际情况修改后xshell重新连接
解决③vim /etc/sysctl.conf
vm.max_map_count = 262144
回到root用户身份执行sysctl -p
###############启动成功后的jps
主节点的jps有4个
Nimbus
Jps
LogviewerServer
UIServer
子节点的jps有3个
Supervisor
QuorumPeerMain
Jps
################关闭
kill -9 进程号
################监控
master:9200
网页端查看节点信息
master:9200/_cat/nodes?v
master:9200/_cluster/health?pretty
master:9200/_cat/health?v
查找ES进程
ps -ef | grep elastic