Ununtu14上安装Elasticsearch5.x及其可视化插件Elasticsearch-Head

1. 拓扑图

在这里插入图片描述

2. Elasticsearch的单实例安装

1)解压安装包

hadoop@ubuntu:~$ tar -zxvf elasticsearch-5.6.16.tar.gz  -C ~/app/
hadoop@ubuntu:~$ cd app/
hadoop@ubuntu:~/app$ mv elasticsearch-5.6.16.tar.gz  elasticsearch

2)启动

hadoop@ubuntu:~/app/elasticsearch/bin$ . /elasticsearch

当打印日子出现started时说明已经启动完成。
3)查看版本信息
在这里插入图片描述

2 Elasticsearch-Head插件的安装

1) 安装git

hadoop@ubuntu:/home/hadoop/app#sudo apt-get install git

2)在Github上下载Elasticsearch-Head

hadoop@ubuntu:/home/hadoop/app#git clone https://github.com/mobz/elasticsearch-head.git

3) 安装node

hadoop@ubuntu:/home/hadoop/app#ssudo apt-get install python-software-properties
hadoop@ubuntu:/home/hadoop/app#scurl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
hadoop@ubuntu:/home/hadoop/app#sudo apt-get install nodejs

4) 安装所需依赖包

hadoop@ubuntu:~/app$ cd elasticsearch-head/
hadoop@ubuntu:~/app/elasticsearch-head$ npm install

5) 修改配置文件

 hadoop@ubuntu:~/app/elasticsearch-head-master$ vim Gruntfile.js

在这里插入图片描述

6)启动Elasticsearch-Head

hadoop@ubuntu:~/app/elasticsearch-head$ npm run start

在chrome浏览器上输入http://192.168.0.142:9100/可以看到
在这里插入图片描述

3 跨域问题

Elasticsearch和elasticsearch-head之间的连接还存在跨域问题,因此需要修改ES配置。

hadoop@ubuntu:~/app/elasticsearch$ vim config/elasticsearch.yml
在末尾添加:
http.cors.enabled: true
http.cors.allow-origin: "*"

在chrome浏览器上再次输入http://192.168.0.142:9100/可以看到:
在这里插入图片描述
还是显示未连接!!!楼主在网上各种谷歌/百度,弄了半天都解决不了!后来突然发现,界面上的连接地址是http//localhost:9200。这里的localhost可能被指向本地windows,导致Elasticsearch和elasticsearch-head无法连接。 因此,楼主修改了ip地址,刷新了页面,此时显示变为绿色,说明已经成功连接,此处应有掌声!
在这里插入图片描述

4 安装问题汇总

1)Localhost可以访问ES,但无法通过IP范问ES
在这里插入图片描述解决方法:配置文件默认只监听localhost的9200端口,因此需要放开其他ip的监听。

hadoop@ubuntu:~/app/elasticsearch$ vim config/elasticsearch.yml
添加network.host: 0.0.0.0

2)[max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

解决方法:es进程最大 打开文件数,至少需要65536

hadoop @ubuntu:/home/hadoop# sudo vim /etc/security/limits.conf
在末尾添加:
*               soft     nofile          65536
*               hard    nofile          65536

3) max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方法:用户拥有的内存权限太小,至少需要262144

hadoop @ubuntu:vim /etc/sysctl.conf
在末尾添加:
vm.max_map_count=262144
hadoop @ubuntu:sysctl -p

5 参考文献

1)《ElasticSearch权威指南》(中文版)

原创文章 32 获赞 12 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_35469756/article/details/92731694