ElasticSearch安装文档

Elasticsearch下载地址
https://www.elastic.co/cn/downloads/elasticsearch

Elasticsearch官网:
https://www.elastic.co/cn/elasticsearch/

Elasticsearch使用文档:
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

Elasticsearch安装步骤:

1.上传安装包到服务器上

elasticsearch-7.13.2-linux-x86_64.tar.gz

2.将ES解压到当前目录

tar -zxvf elasticsearch-7.13.2-linux-x86_64.tar.gz 

3.修改配置文件

cd config
vim elasticsearch.yml 

3.1集群名称,同一集群名称必须相同,可以选择不配置
在这里插入图片描述

3.2 单个节点名称
在这里插入图片描述

设置节点是否为master节点(true or false)(可选)

node.master: true

设置节点存储数据(true or false)(可选)

node.data: true

3.3 把bootstrap自检程序关掉,因为Centos不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动
在这里插入图片描述

3.4 网络部分 改为当前的ip地址 ,端口号保持默认9200就行
在这里插入图片描述

3.5 自发现配置:新节点向集群报到的主机名,主节点必须配置
在这里插入图片描述

3.6 在末尾增加两行配置,添加跨域

http.cors.enabled: true
http.cors.allow-origin: "*"

3.7 JVM参数修改(可选)

cd config
vim jvm.options
- Xms *********
- Xmx *********

3.8 拷贝elasticsearch 到其他机器上,修改配置

scp -r  elasticsearch-7.13.2/ root@10.0.0.77:/data/soft
修改配置文件
node.name: node-2
network.host: 10.0.0.77
scp -r  elasticsearch-7.13.2/ root@10.0.0.78:/data/soft
修改配置文件
node.name: node-3
network.host: 10.0.0.78

4.其它配置

在搭建过程中有碰到很多问题,如下:
问题1:Caused by: java.lang.RuntimeException: can not run elasticsearch as root
解决方案:启动es的时候不能用root用户起,需要使用其他用户操作,添加用户如下:

groupadd es
useradd es -g es
passwd es
chown -R es:es elasticsearch-7.13.2
su es

问题2:max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
原因:系统允许 Elasticsearch 打开的最大文件数需要修改成65536
解决方案:

sudo vim /etc/security/limits.conf

添加如下内容

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 65536

注意:“*” 不要省略掉,每台机器必须设置
重启机器生效

问题3:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
原因:一个进程可以拥有的虚拟内存区域的数量。
解决方案:

sudo vim /etc/sysctl.conf  

添加如下内容

vm.max_map_count=262144

执行命令,使配置生效

sysctl -p

注意:每台机器都必须设置

问题4:如果出现该报错failed to obtain node locks, tried [[/data/soft/elasticsearch-7.1.1/data/my-application]] with lock
解决方案:elasticsearch进程被占用,杀掉重启即可

5.Elasticsearch的后台启动(每台节点)

[root@76-yace-es elasticsearch-7.13.2]# bin/elasticsearch -d

出现如下截图则证明启动成功
在这里插入图片描述

6.Elasticsearch的启停脚本

#!/bin/bash 
es_home=/opt/module/elasticsearch
case $1  in
 "start") {
  for i in node1 node2 node3
  do
        echo "==============$i上ES启动=============="
    ssh $i  "source /etc/profile;${es_home}/bin/elasticsearch >/dev/null 2>&1 &"
 done
 };;
 "stop") {
  for i in node1 node2 node3
  do
          echo "==============$i上ES停止=============="
      ssh $i "ps -ef|grep $es_home |grep -v grep|awk '{print \$2}'|xargs kill" >/dev/null 2>&1
  done
  };;
esac

插件es-head安装及使用

环境要求

es-head需要nodejs环境编译,先看看机器中是否已经有nodejs环境,如果没有的话我们先要安装nodejs环境

nodejs下载及配置

下载地址:https://nodejs.org/en/download/

#解压
tar xvJf node-v12.17.0-linux-x64.tar.xz 

#配置nodejs环境变量
vim /etc/profile

#新增下面的内容
export NODE_HOME=/opt/app/node-v12.17.0-linux-x64
export PATH=$NODE_HOME/bin:$PATH

#刷新环境变量
source /etc/profile

出现如下截图则配置成功
在这里插入图片描述

es-head下载及配置

下载地址:https://codechina.csdn.net/mirrors/mobz/elasticsearch-head?utm_source=csdn_github_accelerator

1.解压

[root@76-yace-es soft]# unzip elasticsearch-head-master.zip 

2.编译安装

cd elasticsearch-head-master/
[root@76-yace-es elasticsearch-head-master]# npm install

3.修改npm源

如果npm install一直卡在fetchMetadata: sill 不动的话,是因为访问的npm registry网络不行,我们可以修改为淘宝的仓库:

#查看npm仓库
npm config get registry
#或
npm info express
#修改为淘宝的源
npm config set registry https://registry.npm.taobao.org
这时候再执行npm install 速度就快很多了

4.解决问题
注意:如果这时候出现下面这个错误

> phantomjs-prebuilt@2.1.16 install /home/wyk/elasticsearch-head-master/node_modules/phantomjs-prebuilt
> node install.js
 
internal/modules/cjs/loader.js:969
  throw err;
  ^
 
Error: Cannot find module '/home/wyk/elasticsearch-head-master/node_modules/phantomjs-prebuilt/install.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
 
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-05-27T03_40_09_380Z-debug.log

忽略phantomjs-prebuilt@2.1.16,修改安装命令再安装就行了

[root@76-yace-es elasticsearch-head-master]# npm install phantomjs-prebuilt@2.1.16 --ignore-scripts

es-head启动

上面修改完es配置后,重启所有es节点,在es-head目录下使用下面的命令启动es-head

[root@76-yace-es elasticsearch-head-master]# npm start  >/dev/null 2>&1 &

访问http://10.0.0.76:9100/该地址出现如下截图,表示配置成功
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值