美文网首页
Centos7下安装Elasticsearch

Centos7下安装Elasticsearch

作者: 空城空忆亦空心 | 来源:发表于2018-10-18 22:30 被阅读0次

1.下载软件elasticsearch-5.6.12.tar.gz到/home/resources目录下

2.解压文件到/home/software目录下

tar -xf elasticsearch-5.6.12.tar.gz -C /home/software

3.启动Elasticsearch

  • 1.注意不能使用root用户启动


    image.png
  • 2.创建用户组和用户
    groupadd es
    useradd es -g es(用户组) -p es()密码
  • 3.修改新用户权限
    chown -R es:es /home/software/elasticsearch-5.6.12
  • 4 启动
    su es : 切换用户
    cd /home/software/elasticsearch-5.6.12/bin : 进去启动文件所在文件夹
    ./elasticsearch 启动
  • 5.问题解决
  • 5.1:内存不足问题


    image.png
  • 解决方案:修改配置文件/home/software/elasticsearch-5.6.12/config/jvm.options
    vim /home/software/elasticsearch-5.6.12/config/jvm.options


    image.png
  • 5.2.bootstrap加载失败


    image.png
  • 解决方案:修改配置文件/home/software/elasticsearch-5.6.12/config/elasticsearch.yml
    vim /home/software/elasticsearch-5.6.12/config/elasticsearch.yml
    修改完成之后,需要重启服务器


    image.png

    6.测试启动成功与否
    curl localhost:9200


    image.png
    7.后台启动(如有需要)
    ./elasticsearch -d 后台启动
    tail -f xxxx.log 动态观察日志

4.对外提供访问

  • 1 修改配置文件vim /home/software/elasticsearch-5.6.12/config/elasticsearch.yml
image.png
image.png
image.png
image.png
  • 2 此时启动会报错,
image.png
  • 原因1:默认的最大可创建线程数是1024,不满足es程序的要求,设置为2048即可
  • 解决方案:vim /etc/security/limits.d/90-nproc.conf
image.png
  • 原因二:虚拟内存太小
  • 解决方案:修改配置文件vim /etc/sysctl.conf,末尾添加一行,改完后重启系统
image.png
  • 3 启动依旧有问题:
image.png

解决方案:修改配置文件vim /etc/security/limits.conf 末尾添加两行
* hard nofile 65536
* soft nofile 65536

  • 4 浏览器访问

对外访问ip:9200


image.png

5.安装HEAD插件,方便查看Elasticsearch中保存的数据

1.安装node.js环境

链接: https://pan.baidu.com/s/1InI9Cf9SqV2a2pgFryL_VA 提取码: 5y1v

  • 1.1 解压

tar -xf ../resources/node-v8.12.0-linux-x64.tar.xz -C /home/software

  • 1.2 安装npm

yum install npm

  • 1.3 进入到node.js根目录下的bin目录,执行npm命令

npm install -g grunt-cli

1.4 验证安装是否成功

image.png
2.安装HEAD插件

unzip elasticsearch-head-master.zip -d ../software/

  • 2.2 允许外部插件访问Elasticsearch,修改配置文件

vim /home/software/elasticsearch-5.6.12/config/elasticsearch.yml
末尾添加
http.cors.enabled: true
http.cors.allow-origin: "*"


image.png
  • 2.3 允许外部访问HEAD插件

vim /home/software/elasticsearch-head-master/Gruntfile.js


image.png
  • 2.4 启动插件(在插件根目录执行命令)

grunt server

  • 2.5 如果启动如下错误
image.png
  • 2.6 执行以下两条命令(在插件根目录执行命令)

npm install -g grunt :全局安装grunt
npm install grunt :将grunt安装到当前目录

  • 2.7 继续启动报错,缺少grunt支持部件
image.png
  • 2.8 挨个安装缺少的部件

npm install grunt-contrib-clean
npm install grunt-contrib-concat
npm install grunt-contrib-watch
npm install grunt-contrib-connect
npm install grunt-contrib-copy
npm install grunt-jasmine

  • 2.9 启动成功
image.png
  • 2.10 浏览器访问,并且连接刚搭建的Elasticsearch节点

外网访问ip:9100


image.png

相关文章

网友评论

      本文标题:Centos7下安装Elasticsearch

      本文链接:https://www.haomeiwen.com/subject/tbwszftx.html