您的位置:首页 > Web前端 > HTML5

elasticsearch5.4.2安装以及插件head的安装过程

2018-01-24 11:51 483 查看
转自:http://blog.csdn.net/ntc10095/article/details/73656897在安装elasticsearch前先配置下系统环境。elasticsearch5后需要运行在JDK8及以上版本,下载安装jdk8并配置环境变量此处不再累述一、安装ElasticSearch1、下载elasticsearch并解压[html] viewplain copy在线下载:wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.2.tar.gz    tar -zxvf elasticsearch-5.4.2.tar.gz //解压    mv -f elasticsearch-5.4.2  /home/ntc/code/elasticsearch-node1 //将解压出来的文件夹移动到自定义目录下并修改文件夹名为elasticsearch-node1  2、修改elasticsearch相关参数vi /home/ntc/code/elasticsearch-node1/config/elasticsearch.yml  //编辑elasticsearch.yml文件[plain] viewplain copy# 集群的名字  cluster.name: elasticsearch  # 节点名字  node.name: node-1  # 索引分片个数,默认为5片  index.number_of_shards: 5  # 索引副本个数,默认为1个副本  index.number_of_replicas: 1  # 数据存储目录(多个路径用逗号分隔)  path.data: /home/ntc/es/data  # 日志目录  path.logs: /home/ntc/es/logs  # 修改一下ES的监听地址,这样别的机器才可以访问  network.host: 192.168.40.133  # 设置节点间交互的tcp端口(集群),默认是9300  transport.tcp.port: 9300  # 监听端口(默认的就好)  http.port: 9200    # 增加新的参数,这样head插件才可以访问es  http.cors.enabled: true  http.cors.allow-origin: "*"  vi /home/ntc/code/elasticsearch-node1/config/jvm.options  //jvm空间大小由于elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配[html] viewplain copy-Xms512m  -Xmx512m  

注意,设置参数的时候“:冒号”后面要有空格!

3、修改系统参数vi /etc/security/limits.conf*              soft    nproc          65536*              hard    nproc          65536*              soft    nofile          65536*              hard    nofile          65536vi /etc/sysctl.confvm.max_map_count= 262144sysctl -p 使修改生效4、启动elasticsearch(必然报错)cd  /home/ntc/code/elasticsearch-node1/bin./elasticsearch  -d //-d表示在后台运行(停止运行通过“kill -9 进程号”),若不在后台运行可通过”CTRL+C”组合键来停止运行查看es是否已运行ps -aux|grep -i elasticsearch报错请查看另一篇博客:http://blog.csdn.net/ntc10095/article/details/73650794启动成功后访问:http://192.168.40.133:9200/二、安装Head  插件Elasticsearch Head Plugin: 对ES进行各种操作,如查询、删除、浏览索引等。1、下载elasticsearch-head并解压在线下载:wget  https://github.com/mobz/elasticsearch-head/archive/master.zip 或者到github下载:https://github.com/mobz/elasticsearch-headunzip  elasticsearch-head-master.zip //解压zip文件mv  elasticsearch-head-master.zip  /home/ntc/code/elasticsearch-head //解压到自定义目录并修改文件夹名为elasticsearch-head2、安装node由于head插件本质上还是一个nodejs的工程,因此需要安装node,使用npm来安装依赖的包。(npm可以理解为maven)
wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gz[/code] 
tar -zxvf node-v4.4.7-linux-x64.tar.gz
解压完node的安装文件后,需要配置下环境变量,编辑/etc/profile,添加保存后别忘记立即执行以下
source /etc/profile
这个时候可以测试一下node是否生效:3、安装gruntgrunt是一个很方便的构建工具,可以进行打包压缩、测试、执行等等的工作,5.0里的head插件就是通过grunt启动的。因此需要安装一下grunt:cd  /home/ntc/code/elasticsearch-head安装nodejsnpm install -g grunt-cli  //执行后会生成node_modules文件夹npm install注:5.0以上,elasticsearch-head 不能放在
elasticsearch
的 
plugins
modules
 目录下,否则elasticsearch启动会报错4、修改head源码vi /home/ntc/code/elasticsearch-head/Gruntfile.js
connect: {
server: {
options: {
port: 9100,
hostname: '*',
base: '.',
keepalive: true
}
}
}
增加hostname属性,设置为*

修改连接地址:

目录:vi /home/ntc/code/elasticsearch-head/_site/app.js修改head的连接地址:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
把localhost修改成你es的服务器地址,如:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.40.133:9200";
5、运行head 启动nodejs
cd /home/ntc/code/elasticsearch-head //先跳转到head目录下
grunt server //若想在后台运行,结尾追加“&”
http://blog.csdn.net/llwwlql/article/details/77162277

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: