elastaticsearch安装使用

本文详细介绍了Elasticsearch的解压安装步骤,包括创建必要文件夹、配置elasticsearch.yml,以及启动集群的方法。同时,深入解析了Head插件的安装流程,涵盖了Node.js环境搭建、插件配置与启动,确保集群有效监控。

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

一.解压安装
1)在普通用户下解压压缩包
在这里插入图片描述
2)创建data和logs文件夹
3)修改配置文件elasticsearch.yml,参考elasticsearch.yml配置
4)启动集群
在这里插入图片描述
并且可以看到浏览器中:
在这里插入图片描述
二.Elasticsearch head插件安装及nodejs环境搭建
1)下载插件
https://github.com/mobz/elasticsearch-head
elasticsearch-head-master.zip
2)nodejs官网下载安装包
https://nodejs.org/dist/
node-v6.9.2-linux-x64.tar.xz
3)将elasticsearch-head-master.zip和node-v6.9.2-linux-x64.tar.xz都导入到linux的对应目录。
4)安装nodejs
[atguigu@hadoop102 software]$ tar -zxvf node-v6.9.2-linux-x64.tar.gz -C /opt/module/
5)配置nodejs环境变量
[root@hadoop102 software]# vi /etc/profile
export NODE_HOME=/opt/module/node-v6.9.2-linux-x64
export PATH= P A T H : PATH: PATH:NODE_HOME/bin
[root@hadoop102 software]# source /etc/profile
6)查看node和npm版本
[root@hadoop102 software]# node -v
v6.9.2
[root@hadoop102 software]# npm -v
3.10.9
在这里插入图片描述
7)解压head插件到/opt/module目录下
[node1@node1 disk4]$ unzip elasticsearch-head-master.zip -d /opt/module/
8)查看当前head插件目录下有无node_modules/grunt目录:
没有:执行命令创建:
[node1@node1 elasticsearch-head-master]$ npm install grunt --save
在这里插入图片描述
9)安装head插件:
[node1@node1elasticsearch-head-master]$ npm install -g cnpm --registry=https://registry.npm.taobao.org
在这里插入图片描述
10)安装grunt:
[node1@node1 elasticsearch-head-master]$ npm install -g grunt-cli
在这里插入图片描述
11)编辑Gruntfile.js
[node1@node1 elasticsearch-head-master]$ vim Gruntfile.js
文件93行添加hostname:‘0.0.0.0’
options: {
hostname:‘0.0.0.0’,
port: 9100,
base: ‘.’,
keepalive: true
}
在这里插入图片描述
12)检查head根目录下是否存在base文件夹
没有:将 _site下的base文件夹及其内容复制到head根目录下
[node1@node1 elasticsearch-head-master]$ mkdir base
[node1@node1_site]$ cp base/* …/base/
13)启动grunt server:
[node1@node1 elasticsearch-head-master]$ grunt server -d
Running “connect:server” (connect) task
[D] Task source: /opt/module/elasticsearch-head-master/node_modules/grunt-contrib-connect/tasks/connect.js
Waiting forever…
Started connect web server on http://localhost:9100

如果提示grunt的模块没有安装:
Local Npm module “grunt-contrib-clean” not found. Is it installed?Local Npm module “grunt-contrib-concat” not found. Is it installed?Local Npm module “grunt-contrib-watch” not found. Is it installed?Local Npm module “grunt-contrib-connect” not found. Is it installed?Local Npm module “grunt-contrib-copy” not found. Is it installed?Local Npm module “grunt-contrib-jasmine” not found. Is it installed?Warning: Task “connect:server” not found. Use –force to continue.
执行以下命令:
npm install grunt-contrib-clean -registry=https://registry.npm.taobao.org
npm install grunt-contrib-concat -registry=https://registry.npm.taobao.org
npm install grunt-contrib-watch -registry=https://registry.npm.taobao.org
npm install grunt-contrib-connect -registry=https://registry.npm.taobao.org
npm install grunt-contrib-copy -registry=https://registry.npm.taobao.org
npm install grunt-contrib-jasmine -registry=https://registry.npm.taobao.org
最后一个模块可能安装不成功,但是不影响使用。
14)浏览器访问head插件:
在这里插入图片描述
http://hadoop102:910015)启动集群插件后发现集群未连接
在这里插入图片描述
在/disk4/elasticsearch-5.2.2/config路径下修改配置文件elasticsearch.yml,在文件末尾增加
[node1@node1 config]$ pwd
/disk4/elasticsearch-5.2.2/config
[node1@node1 config]$ vi elasticsearch.yml

http.cors.enabled: true
http.cors.allow-origin: ""
再重新启动elasticsearch。
在这里插入图片描述
16)关闭插件服务
ctrl+c
[node1@node1 elasticsearch-head-master]$ netstat -lntp | grep 9100
tcp 0 0 192.168.1.102:9100 0.0.0.0:
LISTEN 6070/grunt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值