ES系列二之CentOS7安装ES head插件

CentOS7安装ES head插件

附:Centos7中安装Node出现Cannot find module '.../lib/utils/unsupported.js'问题

删除原本的的npm连接,重新建一个即可。

1、先cd到该node版本中的bin文件夹下,这里装的是12.16.2版本:

复制代码
cd /usr/local/soft/node-v16/bin
或 
/usr/local/soft/node/node-v20/bin

2、删除该路径下的npm文件, 出现提示输入yes即可

复制代码
mv npm npm.bk

3、重新建立文件连接

复制代码
ln -s ../usr/local/soft/node-v16/lib/node_modules/npm/bin/npm-cli.js ./npm

再次使用 npm -v 命令查看发现已近ok了

一、Head插件简介

ElasticSearch-head是一个H5编写的ElasticSearch集群操作和管理工具,可以对集群进行傻瓜式操作。

  • 显示集群的拓扑,并且能够执行索引和节点级别操作
  • 搜索接口能够查询集群中原始json或表格格式的检索数据
  • 能够快速访问并显示集群的状态
  • 有一个输入窗口,允许任意调用RESTful API。这个接口包含几个选项,可以组合在一起以产生有趣的结果;
  • 5.0版本之前可以通过plugin名安装,5.0之后可以独立运行。

-----------------------只需要在第一台es部署head 即可-----------------------

二、Head插件安装

前置:安装phantomjs(由于入坑多写一步,此步骤可省掉)

1.下载phantomjs

安装npm的时候会依赖phantomjs 所以我们先安装phantomjs

phantomjs 下载地址:http://phantomjs.org/download.html

可以复制下载地址通过命令来下载,如下

wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2

2.解压安装包

复制代码
# 下载bzip2
 ① yum -y install bzip2

#创建存放目录
[root@elk-1 ~]# mkdir /tmp/phantomjs

# ------------------------------------------------------------
# 将文件移动过去即可,不需要解压
[root@elk-1 ~]# mv phantomjs-2.1.1-linux-x86_64.tar.bz2 /tmp/phantomjs/
 
更改权限
[root@elk-1 ~]# chmod 777 /tmp/phantomjs -R
# ------------------------------------------------------------
 # ========================================================
#如果不行 再解压 安装
 ② bzip2 -d phantomjs-2.1.1-linux-x86_64.tar.bz2

 ③ tar -xvf phantomjs-2.1.1-linux-x86_64.tar
 # ========================================================

3.安装(由于我的解压目录在 /home/tools/phantomjs-2.1.1-linux-x86_64,所以后面就直接写绝对路径了)

① 将可执行文件放入系统路径

复制代码
   ln -s /home/tools/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs

② 安装依赖------fontconfig和freetype

复制代码
  yum install fontconfig freetype2

③ 配置环境变量

复制代码
  vim /etc/profile

  export  PHANTOMJS=/home/tools/phantomjs-2.1.1-linux-x86_64

  export  PATH=$PATH:$PHANTOMJS/bin

保存后执行:source /etc/profile

④ 测试 执行如下命令会显示phantomjs的版本

phantomjs -v

  1. 安装NodeJS

    复制代码
    [root@localhost soft]#  yum install -y nodejs
    或 上传tar.gz包 直接解压缩
  2. 安装npm

    复制代码
    [root@localhost bin]# npm install -g cnpm --registry=https://registry.npm.taobao.org

    附:报错 npm ERR! code CERT_HAS_EXPIRED

  3. 使用npm安装grunt

    [root@node1 ~]# npm install -g grunt
    npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
    npm WARN gentlyRm not removing /usr/bin/grunt as it wasn't installed by /usr/lib/node_modules/grunt
    /usr/bin/grunt -> /usr/lib/node_modules/grunt/bin/grunt
    /usr/lib
    └── [email protected]

    [root@node1 ~]#

    [root@node1 ~]# npm install -g grunt-cli --registry=https://registry.npm.taobao.org --no-proxy
    /usr/bin/grunt -> /usr/lib/node_modules/grunt-cli/bin/grunt
    /usr/lib
    └─┬ [email protected]
    ├─┬ [email protected]
    │ └─┬ [email protected]
    │ ├─┬ [email protected]
    │ │ └── [email protected]
    │ ├── [email protected]
    │ ├─┬ [email protected]
    │ │ └─┬ [email protected]
    │ │ ├── [email protected]
    │ │ └── [email protected]
    │ ├── [email protected]
    │ └── [email protected]
    ├── [email protected]
    ├─┬ [email protected]
    │ └── [email protected]
    └── [email protected]

    [root@node1 ~]#

  4. 版本确认

    复制代码
    [es@node1 ~]$ node -v
    v6.12.0
    [es@node1 ~]$ npm -v
    3.10.10
    [es@node1 ~]$ grunt -version
    grunt-cli v1.5.0
    [es@node1 ~]$

三、安装head

  1. 下载head插件源码

    [root@localhost ~]# cd /usr/local/soft/es7.14/
    [root@localhost es7.14]# get https://github.com/mobz/elasticsearch-head/archive/master.zip

    --2017-12-18 09:58:08-- https://github.com/mobz/elasticsearch-head/archive/master.zip
    .......
    ......
    HTTP request sent, awaiting response... 200 OK
    Length: 921421 (900K) [application/zip]
    Saving to: 'master.zip'

    100%[===============================================================>] 921,421 9.64KB/s in 67s

    2017-12-18 09:59:18 (13.4 KB/s) - 'master.zip' saved [921421/921421]

    [root@localhost es7.14]# ls
    master.zip
    $ unzip master.zip

    改名

    [root@localhost es7.14]# mv elasticsearth-head-master head-master

  2. 下载依赖

    进入elasticsearch-head-master目录,执行下面命令:

    [root@localhost head-master]# npm install -g

    [root@localhost head-master]#

如果上面命令安装较慢或失败,可以尝试国内镜像安装

复制代码
[es@node1 elasticsearch-head-master]$ sudo npm install -g cnpm --registry=https://registry.npm.taobao.org

[es@node1 elasticsearch-head-master]$

四、配置

  1. 停止ElasticSearch

如果ElasticSearch已经启动,需要先停止

复制代码
[es@node1 ~]$ kill 3261
  1. 配置 ElasticSearch,使得HTTP对外提供服务

    [es@node1 elasticsearch-6.1.1]$ vi config/elasticsearch.yml

添加如下内容

复制代码
# 增加新的参数,这样head插件可以访问es。设置参数的时候:后面要有空格
http.cors.enabled: true
http.cors.allow-origin: "*"
  1. 修改Head插件配置文件

    [es@node1 elasticsearch-head-master]$ vi Gruntfile.js

找到connect:server,添加hostname一项,如下

复制代码
connect: {
                        server: {
                                options: {
                                        hostname: '0.0.0.0',
                                        port: 9100,
                                        base: '.',
                                        keepalive: true
                                }
                        }
                }

(3-2) 修改 _site/app.js

复制代码
[root@elk-1 ~]# vim /usr/local/elasticsearch-head-master/_site/app.js +4373  
原来是http://localhost:9200 ,如果head和ES不在同一个节点,注意修改成ES的IP地址,写成node-1或node-3的IP地址

五、启动

  1. 启动elasticsearch

    复制代码
     首先确认elasticsearch已经启动

    [es@node1 elasticsearch-6.1.1] bin/elasticsearch -d [es@node1 elasticsearch-6.1.1] jps
    3451 Jps
    3436 Elasticsearch
    [es@node1 elasticsearch-6.1.1]$

2、启动head

通过命令grunt server启动head

复制代码
[es@node1 elasticsearch-head-master]$ grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://node1:9100

或者通过命令npm run start也可以启动head

复制代码
[es@node1 elasticsearch-head-master]$ npm run start

> [email protected] start /home/es/elasticsearch-head-master
> grunt server

Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://node1:9100
  1. 访问9100端口

    复制代码
     http://node3:9100/

如果出现"未连接",请修改localhost为node1,然后单击"连接"按钮

分别启动es集群:node-1,node-2,node-3



六、简单应用

  1. 创建索引

    [root@node1 ~]# curl -XPUT node1:9200/test
    {"acknowledged":true,"shards_acknowledged":true,"index":"test"}
    [root@node1 ~]#

  2. 查看head变化

相关推荐
lilye661 小时前
精益数据分析(17/126):精益画布与创业方向抉择
大数据·数据挖掘·数据分析
思通数科AI全行业智能NLP系统3 小时前
AI视频技术赋能幼儿园安全——教师离岗报警系统的智慧守护
大数据·人工智能·安全·目标检测·目标跟踪·自然语言处理·ocr
程序员沉梦听雨6 小时前
【Elasticsearch】入门篇
大数据·elasticsearch·搜索引擎
Gadus_6 小时前
Elasticsearch性能优化实践
大数据·elasticsearch·搜索引擎·性能优化
riveting7 小时前
SD2351核心板:重构AI视觉产业价值链的“超级节点”
大数据·linux·图像处理·人工智能·重构·智能硬件
欧先生^_^8 小时前
Spark 的一些典型应用场景及具体示例
大数据·分布式·spark
八股文领域大手子9 小时前
如何给GitHub项目提PR(踩坑记录
大数据·elasticsearch·github
爱吃龙利鱼9 小时前
elk中kibana一直处于可用和降级之间且es群集状态并没有问题的解决方法
大数据·elk·elasticsearch
腾讯云大数据9 小时前
腾讯云ES一站式RAG方案获信通院“开源大模型+软件创新应用”精选案例奖
大数据·elasticsearch·开源·云计算·腾讯云
苍煜9 小时前
Elasticsearch(ES)中的脚本(Script)
大数据·elasticsearch·搜索引擎