将 es 的安装包下载并上传到 node01 服务器的/home/es 路径下,然后进行解压 使用 es 用户来执行以下操作(断开连接 linux 的工具,然后重新使用 es 用户连接上 三台 linux 服务器)
node01 服务器使用 es 用户执行以下命令
cd /home/es/
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.7.0. tar.gz
tar -zxvf elasticsearch-6.7.0.tar.gz -C /export/servers/es/
node01 使用 es 用户将安装包分发到其他服务器上面去
cd /export/servers/es/
scp -r elasticsearch-6.7.0/ node02:$PWD
scp -r elasticsearch-6.7.0/ node03:$PWD
第六步:node02 与 node03 修改 es 配置文件
node02 与 node03 也需要修改 es 配置文件
node02 使用 es 用户执行以下命令修改 es 配置文件
cd /export/servers/es/elasticsearch-6.7.0/config
vim elasticsearch.yml
配置内容:
cluster.name: myes
node.name: node02
path.data: /export/servers/es/elasticsearch-6.7.0/datas
path.logs: /export/servers/es/elasticsearch-6.7.0/logs
network.host: 192.168.227.20
http.port: 9200
discovery.zen.ping.unicast.hosts: ["node01", "node02", "node03"]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
http.cors.enabled: true
http.cors.allow-origin: "*"
node03 使用 es 用户执行以下命令修改配置文件
cd /export/servers/es/elasticsearch-6.0.0/config/
vim elasticsearch.yml
配置内容:
cluster.name: myes
node.name: node03
path.data: /export/servers/es/elasticsearch-6.7.0/datas
path.logs: /export/servers/es/elasticsearch-6.7.0/logs
network.host: 192.168.227.30
http.port: 9200
discovery.zen.ping.unicast.hosts: ["node01", "node02", "node03"]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
http.cors.enabled: true
http.cors.allow-origin: "*"
第七步:修改系统配置,解决启动时候的问题
由于现在使用普通用户来安装 es 服务,且 es 服务对服务器的资源要求比较多,包 括内存大小,线程数等。所以我们需要给普通用户解开资源的束缚
解决启动问题一:普通用户打开文件的最大数限制
问题错误信息描述:
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
ES 因为需要大量的创建索引文件,需要大量的打开系统的文件,所以我们需要解除 linux 系统当中打开文件最大数目的限制,不然 ES 启动就会抛错
三台机器使用 es 用户执行以下命令解除打开文件数据的限制
sudo vi /etc/security/limits.conf
添加如下内容: 注意*不要去掉了
![图片.png](https://upload-images.jianshu.io/upload_images/2284182-e1f8e72faedfcb3c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
解决启动问题二:普通用户启动线程数限制
问题错误信息描述
max number of threads [1024] for user [es] likely too low, increase to at least [4096]
修改普通用户可以创建的最大线程数
max number of threads [1024] for user [es] likely too low, increase to at least [4096]
原因:无法创建本地线程问题,用户最大可创建线程数太小
解决方案:修改 90-nproc.conf 配置文件。
三台机器使用 es 用户执行以下命令修改配置文件
sudo vi /etc/security/limits.d/90-nproc.conf
* soft nproc 1024
#修改为
* soft nproc 4096
解决启动问题三:普通用户调大虚拟内存
错误信息描述:
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
调大系统的虚拟内存
原因:最大虚拟内存太小
每次启动机器都手动执行下。
三台机器执行以下命令,注意每次启动 ES 之前都要执行
sudo sysctl -w vm.max_map_count=262144
备注:以上三个问题解决完成之后,重新连接 secureCRT 或者重新连接 xshell 生效 需要保存、退出、重新登录 xshell 才可生效。
第八步:启动 ES 服务
三台机器使用 es 用户执行以下命令启动 es 服务
nohup /export/servers/es/elasticsearch-6.7.0/bin/elasticsearch >/dev/null 2>&1 &
启动成功之后 jsp 即可看到 es 的服务进程,并且访问页面
http://node01:9200/?pretty
能够看到 es 启动之后的一些信息
注意:如果哪一台机器服务启动失败,那么就到哪一台机器的
/export/servers/es/elasticsearch-6.7.0/logs
这个路径下面去查看错误日志