ubuntu安装elasticsearch-rtf

本文详细介绍了如何在Ubuntu环境下安装Elasticsearch及其配套工具,包括解决内存分配、文件描述符限制等问题,并开启外网访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.因为Elasticsearch是Java环境编写的,所以要有Java环境来支持运行

sudo apt-get install default-jdk

安装完查看java是否安装正常

java -version

这里写图片描述

2.安装Elasticsearch-rtf

1.下载(安装git)

git clone git://github.com/medcl/elasticsearch-rtf.git -b master --depth 1

2.运行

 cd elasticsearch-rtf/bin
 ./elasticsearch

3.可能会遇到下列的错误

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /elasticsearch-rtf/bin/hs_err_pid7912.log

出现上述原因是因为elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配
解决方案:

cd /elasticsearch-rtf/config
vim jvm.options

这里写图片描述
修改上面就可以了
4.继续运行,也可能出现下述问题
这里写图片描述
出现上述问题是因为安全,不能再root用户下运行
解决方案:

groupadd es
useradd es -g es -p es
chown -R es:es /elasticsearch-rtf
su es

然后重新启动,重新启动后很可能还会出现下列错误,在ubuntu下安装确实没有windows下简单

ERROR: bootstrap checks failed
max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方法:
重新切换到root用户

vim /etc/security/limits.conf

这里写图片描述
然后切回es用户输入

ulimit -Hn
//会显示
65536

在重新切换为root用户输入

vim /etc/sysctl.conf 

然后输入下列代码

vm.max_map_count=262144

这里写图片描述
然后执行sysctl -p 输入

sysctl -a|grep vm.max_map_count

这里写图片描述
在切会es用户下从新启动即可

5.开启外网验证

vim config/elasticsearch.yml 
  翻到下面找到并修改
  network.host: 0.0.0.0
  http.cors.enabled: true
  http.cors.allow-origin: "*"
  http.cors.allow-methods: OPTIONS,HEAD,GET,POST,PUT,DELETE
  http.cors.allow-headers: "X-Requested-With,Content-Type,Content-Length, X-User"

最后在重新启动一次

3.安装 elasticsearch-head

elasticsearch-head是集群管理工具、数据可视化、增删改查工具

git clone git://github.com/mobz/elasticsearch-head.git

elasticsearch-head的使用需要基于nodejs,所以需要安装nodejs

cd /usr/local/
wget https://npm.taobao.org/mirrors/node/v8.9.3/node-v8.9.3-linux-x64.tar.xz

然后进行解压

tar -xvf node-v8.9.3-linux-x64.tar
//名字太长了重命名
mv node-v8.9.3-linux-x64 node
//配置环境变量
vim /etc/profile
export NODE_HOME=/usr/local/node  
export PATH=$NODE_HOME/bin:$PATH  

保存退出,执行生效

source /etc/profile

使用命令,查看版本

node -v
npm -v

然后切回刚才下载的elasticsearch-head 目录执行

npm install
npm run start
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值