Elasticsearch简介及安装(以Linux环境为例)

参考地址:https://blog.csdn.net/aisemi/article/details/80212836

https://www.xugj520.cn/archives/elasticsearch_instal.html

一、ElasticSearch简介

1、ElasticSearch和MongoDB/Redis/Memcache一样,是非关系型数据库。是一个接近实时的搜索平台,从索引这个文档 到这个文档被搜索到只要一个轻微的延迟,企业应用定位:采用Restful API标准的可扩展和高可用的实时数据分析和全文搜索工具。

2、可拓展:支持一主多从且扩容简易,只要cluster.name一致且在同一个网络中就能加入当前集群;本身就是开源软件,也支持很多开源的第三方插件。

3、高可用:在一个集群的多个节点进行分布式存储,索引支持shards(分片)和复制,即使部分节点down掉,也能自动进行数据恢复和主从切换。

4、采用RestfulAPI标准:通过http接口使用JSON格式进行操作数据。

5、数据存储的最小单位是文档,本质上是一个JSON文本:

二、安装Elasticsearch(以Linux环境为例)

1、下载

到 https://www.elastic.co/cn/downloads/elasticsearch 下载相应的软件包

2、将压缩包放上Linux服务器,使用 “tar -zxvf  XXX”进行解压,得到目录:

3、配置

进入安装目录下的config目录,修改elasticsearch.yml文件,在文件末尾加入以下代码:

http.cors.enabled: true     #允许跨域
http.cors.allow-origin: "*"

network.host: 0.0.0.0       #使用本机IP地址

4、运行

进入安装目录下的bin目录,运行  ./elasticsearch

5、报错处理

(一)

*出现错误:“java.lang.RuntimeException: can not run elasticsearch as root”。

*解决方法:

创建elsearch用户组及elsearch用户:

groupadd elsearch
useradd elsearch -g elsearch
passwd elsearch

更改elasticsearch文件夹及内部文件的所属用户及组为elsearch:elsearch

cd /opt
chown -R elsearch:elsearch  elasticsearch-6.8.0

切换到elsearch用户再启动

su elsearch 
cd /opt/elasticsearch-6.8.0/bin
./elasticsearch   # 后续运行则需要加 -d

(二)

*出现错误:“max virtual memory areas vm.max_map_count [65530] is too low, increase to at least”

*解决方法:编辑/etc/sysctl.conf,加入 “vm.max_map_count=655360”,运行“sysctl -p”使配置生效

(三)

*出现错误:“max virtual memory areas vm.max_map_count [65530] is too low, increase to at least”

*解决方法:

1.打开/etc/security/limits.conf,在里面添加如下内容

* soft nofile 65536
* hard nofile 65536
 其中*表示所有用户  nofile表示最大文件句柄数,表示能够打开的最大文件数目

2.编辑/etc/pam.d/common-session,添加如下内容

vi /etc/pam.d/common-session

session required pam_limits.so 
3.编辑/etc/profile,添加如下内容
ulimit -SHn 65536

4.运行 source /etc/profile 使用配置生效

(四)

*出现错误:"OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Not enough space' (errno=12) "

也有可能出现ES服务进程莫名其妙的就挂掉了。

*解决方法:

1.查看es配置的内存: ~/elasticsearch-7.2.0/config/jvm.options

################################################################

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms1g
-Xmx1g

2.将jvm文件中的内存都改为256m

-Xms256m
-Xmx256m

6、验证

或者,curl localhost:9200

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值