ElasticSearch环境配置

来源:互联网 发布:数控车床编程实例简单 编辑:程序博客网 时间:2024/06/01 09:00

Windows环境下

下载地址

进入下载页面下载 ZIP格式的 Elasticsearch 和Kibana 压缩包

将ES和Kibana压缩包解压到自己制定的文件夹下即可,无需安装。

运行ES文件夹下bin目录下的elasticsearch.bat脚本即可启动ES,

在浏览器中输入http://localhost:9200/ 显示如下 ES 即安装成功

{  "name" : "Tom Foster",  "cluster_name" : "elasticsearch",  "version" : {    "number" : "2.1.0",    "build_hash" : "72cd1f1a3eee09505e036106146dc1949dc5dc87",    "build_timestamp" : "2015-11-18T22:40:03Z",    "build_snapshot" : false,    "lucene_version" : "5.3.1"  },  "tagline" : "You Know, for Search"}


然后Run Kibana中 bin 目录下的 kibana.bat 脚本 ,通过
http://localhost:5601 进入kibana界面。


Linux环境下

先安装最新版本的JDK,
然后进入官网下载,解压到用户目录下的文件夹下,操作与windows类似。
命令行安装失败的话就直接下载压缩包解压到安装目录。

ElasticSearch 安装


curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz
tar -xvf elasticsearch-5.6.3.tar.gz
cd elasticsearch-5.6.3/bin
./elasticsearch #启动

ElasticSearch配置

由于虚拟机内存问题
需要将JVM虚拟机内存设置修改
./elasticsearch-5.6.3/config/jvm.options
修改
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
#从2g修改为1g
-Xms1g
-Xmx1g

内存问题会造成运行时会很卡,可以给将配置文件的内存设置降低,并增大分配给虚拟机的内存


常见问题

max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]
切换到root用户,编辑limits.conf 添加类似如下内容
vi /etc/security/limits.conf
添加如下内容:
* soft nofile 655360
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
--------------------------------------
或者以一下方法
sysctl -w vm.max_map_count=655360
并用以下命令查看是否修改成功
sysctl -a | grep "vm.max_map_count"
如果能正常输出655360,则说明修改成功,然后再次启动elasticsearch

环境配置


远程访问主机
需要在config目录下的elasticsearch.yml修改如下

network.host: 0.0.0.0
http.port: 9200
transport.host: localhost
transport.tcp.port: 9300
只修改elasticsearch配置文件中的 network.host:0.0.0.0即可。
network.host: 0.0.0.0
http.port: 9200
transport.host: localhost
transport.tcp.port: 9300
network.host: 0.0.0.0
http.port: 9200
transport.host: localhost
transport.tcp.port: 9300
network.host: 0.0.0.0
http.port: 9200
transport.host: localhost
transport.tcp.port: 9300

插件cerebro安装

插件cerebro的GitHub地址为GitHub https://github.com/lmenezes/cerebro/

wget https://github.com/lmenezes/cerebro/releases/download/v0.6.5/cerebro-0.6.5.tgz
tar zxvf cerebro-0.6.5.tgz
cd cerebro-0.6.5/
bin/cerebro
#可以直接通过外网端口访问 http://yourip:9000/ 用Ubuntu虚拟机的IP替换yourip,可在自己原系统的浏览器中访问
插件界面,Kibana也类似.

也可以下载压缩包解压到安装目录,插件也是免安装的。

cerebro与es建立连接时,使用ES的网络端口http://localhost:9200/或http://yourip:9200/

运行时,启动顺序为 ES, Kibana, cerebro .