ubuntu安装elasticsearch和head插件(所有可能出现的问题解决)超详细

ubuntu安装elasticsearch
基本用法
高级查询【上】
高级查询【下】
与springboot整合
整合mysql和thymeleaf

一、单例安装
首先去官网 elastic.co 下载tar.gz的压缩包,或者使用命令行下载:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.7.0.tar.gz

下载完后,用命令解压缩:

tar -zxvf 你的压缩包

然后在elastic根目录下使用命令启动:

./bin/elastcisearch

可能会出现一些问题(为啥都被我碰到了呢,,,):
1、内存不足
在这里插入图片描述
解决方法:

vim config/jvm.options 

将-xms2g和-xmx2g修改为-Xms512M 、-Xmx512M
在这里插入图片描述
2、无法用root启动
这是出于系统安全考虑设置的条件。由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑, 需要创建一个单独的用户用来运行ElasticSearch

创建elsearch用户组及elsearch用户

groupadd elsearch(用户名)
useradd elsearch(用户名) -g elsearch(组) -p elasticsearch(密码)

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

chown -R elsearch:elsearch  elasticsearch

elasticsearch为你elasticsearch的目录名称
切换到elsearch用户再启动

su elsearch #切换账户
./bin/elasticsearch

3、正常启动了,可是无法用外网访问
修改elasticsearch-x.x.x\config\elasticsearch.yml文件

vi config/elasticsearch.yml

在最后面添加 network.host: 0.0.0.0

可是修改后又出现了新的错误,wtf。。。

bootstrap checks failed max file descriptors [65535] 
for elasticsearch process is too low, increase to at least [65536]

解决方法:
1)

vi /etc/sysctl.conf

在最后面添加以下内容:

fs.file-max=655350 
vm.max_map_count=655360

保存之后sysctl -p使设置生效
2)

vi /etc/security/limits.conf

在最后面添加:

* soft nofile 655350
* hard nofile 655350

单例安装到此已经完美的解决了。

二、插件安装
1、下载插件(默认你已经安装git):

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

2、检查是否安装node

node -v

如果没有安装:先安装python:

sudo apt-get install python-software-properties

手动下载执行脚本文件:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

安装nodejs

sudo apt-get install nodejs

输入命令安装elasticsearch所需的依赖包:

npm install

依赖安装完后,需要修改一个文件才能连上head插件

vim config/elasticsearch.yml

在后面添加以下内容:

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

输入命令启动head插件

npm run start

卧槽,又他妈报错,心态有点崩啊。好吧,9100端口被占用,查找进程,杀死。再一看,卧槽?又复活了?杀不死?好吧,我换端口。

vim Gruntfile.js

找到port,修改为一个没有被占用的端口就ok啦。然后就可以访问head了,显示集群健康
在这里插入图片描述
参考链接:
https://blog.csdn.net/showhilllee/article/details/53404042
https://blog.csdn.net/u010466329/article/details/78594777
瓦力老师的慕课教程 https://www.imooc.com/video/15765

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值