Elasticsearch入门学习(一):安装ES7.0.1

一、Elasticsearch介绍

  之前有学习使用过Solr。Elasticsearch也是基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。官方客户端在Java、.NET(C#)、PHP、Python、Apache Groovy、Ruby和许多其他语言中都是可用的。

二、CentOS 7.3安装ES 

//解压   ES需要有JDK支持
tar -zxvf elasticsearch-7.0.1-linux-x86_64.tar.gz 

//ES不可以使用root启动,需要创建用户
//创建一个用户组 取名为es
groupadd es

//创建一个用户,将其添加到es组里面
useradd yangk -g es

//为其设置目录权限,我安装的ES是在/yangk/elasticsearch-7.0.1
chown -R yangk:es /yangk/elasticsearch-7.0.1

//切换用户
su 用户

//启动es   -d是后台启动
./elasticsearch -d

//配置其可以远程访问
//修改/yangk/elasticsearch-7.0.1/config/elasticsearch.yml找到 Network
network.host: 0.0.0.0

//在末尾添加,开启跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*" 

 

开启远程访问的时候还有可能出现以下错误

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

第一个问题:

//这个错误,主要是因为linux会限制进程的最大打开文件数

//首先切换到root
su root

//编辑vi /etc/security/limits.conf

//在文件末尾增加
yangk     -     nofile        65536   # 将 yangk替换为自己的用户名

第二个问题

这个是ES使用的虚拟内存太小,直接调大即可,在 root 用户下执行下面命令:
sysctl -w vm.max_map_count=262144

第三个问题

还是找到 config/elasticsearch.yml 文件,编辑,找到 Discovery 配置附近,修改

# 取消注释,并修改属性
cluster.initial_master_nodes: ["127.0.0.1"]

配置完之后启动还是出现报错

[INFO ][o.e.b.BootstrapChecks    ] [gFOuNlS] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed

解决方案

//切换到root用户

//修改vi /etc/security/limits.conf。增加
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096

//修改vi /etc/security/limits.d/XX-nproc.conf
#修改为,这个有可能存在
* soft nproc 4096

//修改 /etc/sysctl.conf   增加
vm.max_map_count=655360

//执行命令
sysctl -p

 这样就启动成功

 

三、ES图形化界面

下载地址:https://github.com/mobz/elasticsearch-head

这是一个node.js的项目,需要先安装node环境

然后在cmd里面进入elasticsearch-head根目录安装项目所需依赖

 

//安装grunt
npm install -g grunt-cli

//安装head所需依赖
npm i

//启动项目
run run start 或者 grunt server

//启动项目有可能会出现grunt权限不足等。只需要软连接一下就可以了
ln -s /yangk/node-v8.11.3-linux-x64/bin/grunt  /usr/local/bin/grunt

 

转载于:https://www.cnblogs.com/yangk1996/p/11148158.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值