一、准备安装包
下载地址:https://www.elastic.co/cn/downloads/elasticsearch
或者是百度网盘:链接:下载elasticsearch安装包 提取码:khm2
二、将压缩包放到linux机器上(集群中的任意一台)
先安装jdk:
[root@qf01 ~]# yum install -y java-1.8.0-openjdk-devel
将安装包放到liunx的root目录下(可以自由放):
elasticsearch-8.1.1-linux-x86_64.tar.gz
接下来进行解压:
[root@qf01 ~]# tar ‐zvxf elasticsearch-8.1.1-linux-x86_64.tar.gz ‐C /usr/local/elasticsearch
三、配置yml文件
[root@qf01 ~]# cd /usr/local/elasticsearch
[root@qf01 ~]# mkdir data
[root@qf01 ~]# mkdir log
[root@qf01 ~]# cd config
[root@qf01 ~]# vi elasticsearch.yml
8.1.1对应版本的yml是这样配置的:
添加如下内容:这里的配置要小心了,不同版本的elasticsearch中的节点可能并不是跟我相同的,方法也比较简单,就是从上到下,看下yml,都是差不多的
四、配置jvm.option
[root@qf01 ~]# cd /usr/local/elasticsearch/config
[root@qf01 config]# vi jvm.options
修改jvm.option,调整jvm堆内存大小,这里因为我的是虚拟机,没有太大内存,所以我给了1g
以上是在一台电脑上,配置的elasticsearch,目前已经配置完毕,那其它电脑怎么办呢?
1、scp 命令进行分发
2、或者都按照1-4的命令其它节点进行操作,即也可以安装elasticsearch
两种方法任选一种,你认为可行的
每个节点都需要改动elasticsearch.yml
五、新增用户(所有集群机器)
1、elasticsearch 不能用root账号启动,所以需要新增用户
[root@qf01 ~]# groupadd elasticsearch
[root@qf01 ~]# useradd es1
[root@qf01 ~]# passwd es1
[root@qf01 ~]# usermod ‐G elasticsearch es1
[root@qf01 ~]# chown ‐R es1 /usr/local/elasticsearch
2、设置sudo权限
[es1@qf01 root]# visudo
#添加
es1 ALL=(ALL) ALL
六、为了避坑,需要先修改的一些地方(所有集群机器)
避坑1:max file descriptors [4096] for elasticsearch process likely too low,increase to at least [65536]
解释:解除linux系统当中打开文件最大数目的限制
[root@qf01 ~]# su es1
[es1@qf01 root]# sudo vi /etc/security/limits.conf
#添加:注意哦,这里是用新建的用户添加的,且一定要注意内容中间的空格什么的,最好,直接复制过去就行了,我反正是已经被坑过了
避坑2:max number of threads [1024] for user [es] likely too low, increase to at least [4096]
解释:修改普通用户可以创建的最大线程数
[root@qf01 ~]# su es1
[es1@qf01 root]# sudo vi /etc/security/limits.d/20‐nproc.conf
避坑3:max virtual memory areas vm.max_map_count [65530] likely too low,increase to at least [262144]
解释:调大普通用户虚拟内存
[root@qf01 ~]# su es1
[es1@qf01 root]# vi /etc/sysctl.conf
添加完后,执行:
[es1@qf01 root]# sysctl ‐p
坑1,坑2,坑3,注意都是在新建的账户下操作,都需要重新登录账号才能生效
避坑4:ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.bootstrap check failure [1] of [1]: Transport SSL must be enabled if security is enabled. Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting [xpack.security.enabled] to [false]
解释:按照这个错误来说,就是要设置个属性
[root@qf01 ~]# su es1
[es1@qf01 root]# cd /usr/local/elasticsearch/config
[es1@qf01 root]# vi elasticsearch.yml
添加:
七、启动elasticsearch
[es1@qf01 root]# cd /usr/local/elasticsearch/bin
[es1@qf01 root]# ./elasticsearch
启动起来,发现,报错:received plaintext traffic on an encrypted channel, closing connection Netty4TcpChannel{localAddress。。。。
[root@qf01 ~]# su es1
[es1@qf01 root]# cd /usr/local/elasticsearch/config
[es1@qf01 root]# vi elasticsearch.yml
重新启动:
[es1@qf01 root]# cd /usr/local/elasticsearch/bin
[es1@qf01 root]# ./elasticsearch
启动以后,用http://IP:9200/ 进行验证,如果出现如下画面,说明启动成功
启动成功以后,可以断开,改用后台启动:
[es1@qf01 root]# cd /usr/local/elasticsearch/bin
[es1@qf01 root]# ./elasticsearch -d