linux服务器安装elasticsearch的head插件

1.elasticsearch版本:elasticsearch-6.4.0
1. 下载head插件:https://github.com/mobz/elasticsearch-head
2. 上传到/usr/local/

rz
 
 
  • 1
  1. 解压
unzip elasticsearch-head-master.zip
 
 
  • 1
  1. 安装node和Grunt环境
export NODE_HOME=/usr/local/node-v4.4.7-linux-x64
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules
 
 
    • 刷新环境变量:source /etc/profile
    • 安装grunt命令行工具grunt-cli
    npm install -g grunt-cli
     
     
      • 安装grunt及其插件
      npm install grunt --save-dev
       
       
        • 验证安装是否成功:
        grunt -version
         
         
          1. 重命名为elasticsearch-head
          2. 配置连接信息:进入elasticsearch-head/,运行vi Gruntfile.js来修复如下配置(ip 和 端口号)
              connect: {
                      server: {
                          options: {
                              port: 9100,
                              hostname: "0.0.0.0",
                              base: '.',
                              keepalive: true
                          }
                      }
                  }
           
           
            1. 保存后配置防火墙,开放9100端口,在控制台输入
            firewall-cmd --zone=public --add-port=9100/tcp --permanent
            
            firewall-cmd --reload
             
             
              1. 修改elasticsearch服务器的elasticsearch.yml文件,使得head插件可以连接到es服务器,增加以下两个配置(跨域访问)
              ![如果和elasticsearch安装不是在同一台服务器上需修改localhost为对应的ip地址](https://img-blog.csdnimg.cn/20190407093024230.png)
              http.cors.enabled: true
              http.cors.allow-origin: "*"
               
               
                1. 重启elastic 进入elasticsearch-head安装目录里elasticsearch-head/ 运行grunt server来启动head服务
                grunt server 
                 
                 

                  会出现下面的错误:

                  root@931a920a04b6:/usr/share/elasticsearch/plugins/elasticsearch-head/node_modules/grunt/bin# ./grunt server
                  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.

                  需要安装这些缺失的node modules, 注意需要回到elasticsearch_head目录下安装,

                  npm install grunt-contrib-clean grunt-contrib-concat grunt-contrib-watch grunt-contrib-connect grunt-contrib-copy grunt-contrib-jasmine
                  

                  再次运行grunt server

                  输出以下信息证明启动成功

                  Running "connect:server" (connect) task
                  Waiting forever...
                  Started connect web server on http://localhost:9100
                   
                   
                    评论
                    添加红包

                    请填写红包祝福语或标题

                    红包个数最小为10个

                    红包金额最低5元

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

                    抵扣说明:

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

                    余额充值