您的位置:首页 > 其它

安装ElasticSearch 6.1.1 head插件

2018-01-08 22:19 495 查看

http://blog.csdn.net/chengyuqiang/article/details/78838175(主) http://www.mamicode.com/info-detail-2143248.html(辅助)

2.1 Head插件简介

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

2.2 Head插件安装

(1)安装NodeJS
[root@node1 ~]# yum install -y nodejs
或者自己下载tar文件解压
wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.5.0-linux-x64.tar.gztar -zxvf node-v4.5.0-linux-x64.tar.gz配置下环境变量,编辑/etc/profile添加export NODE_HOME=/usr/local/node-v4.5.0-linux-x64export PATH=$PATH:$NODE_HOME/bin/export NODE_PATH=$NODE_HOME/lib/node_modules执行 source /etc/profile1(2)安装npm
[root@node1 ~]#  npm install -g cnpm --registry=https://registry.npm.taobao.org
1(3)使用npm安装grunt
[root@node1 ~]# npm install -g gruntnpm WARN deprecated coffee-script@1.10.0: 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└── grunt@1.0.1[root@node1 ~]# 
12345678
[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└─┬ grunt-cli@1.2.0├─┬ findup-sync@0.3.0│ └─┬ glob@5.0.15│   ├─┬ inflight@1.0.6│   │ └── wrappy@1.0.2│   ├── inherits@2.0.3│   ├─┬ minimatch@3.0.4│   │ └─┬ brace-expansion@1.1.8│   │   ├── balanced-match@1.0.0│   │   └── concat-map@0.0.1│   ├── once@1.4.0│   └── path-is-absolute@1.0.1├── grunt-known-options@1.1.0├─┬ nopt@3.0.6│ └── abbrev@1.1.1└── resolve@1.1.7[root@node1 ~]#
12345678910111213141516171819202122(4)版本确认
[es@node1 ~]$ node -vv6.12.0[es@node1 ~]$ npm -v3.10.10[es@node1 ~]$ grunt -versiongrunt-cli v1.2.0[es@node1 ~]$
1234567(5)下载head插件源码
[es@node1 ~]$ wget https://github.com/mobz/elasticsearch-head/archive/master.zip
也可以在别的地方下载后上传到服务器[es@node1 ~]$ lsmaster.zip[es@node1 ~]$ unzip master.zip
123456789101112131415161718192021(6)下载依赖 进入elasticsearch-head-master目录,执行下面命令
[es@node1 elasticsearch-head-master]$ npm install> phantomjs-prebuilt@2.1.16 install /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt> node install.jsPhantomJS not found on PATHDownload already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2Verified checksum of previously downloaded fileExtracting tar contents (via spawned process)Removing /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantomCopying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1515165531727/phantomjs-2.1.1-linux-x86_64 -> /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantomWriting location.js fileDone. Phantomjs binary available at /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjselasticsearch-head@0.0.0 /home/es/elasticsearch-head-master└─┬ grunt-contrib-jasmine@1.0.3└─┬ grunt-lib-phantomjs@1.1.0└── phantomjs-prebuilt@2.1.16npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression[es@node1 elasticsearch-head-master]$ 
12345678910111213141516171819202122如果上面命令安装较慢或失败,可以尝试国内镜像安装
[es@node1 elasticsearch-head-master]$ sudo npm install -g cnpm --registry=https://registry.npm.taobao.org[sudo] password for es:/usr/bin/cnpm -> /usr/lib/node_modules/cnpm/bin/cnpm/usr/lib└─┬ cnpm@5.1.1├─┬ npminstall@3.3.0│ ├── binary-mirror-config@1.7.3│ ├── moment@2.20.1│ └─┬ tar@4.2.0│   └── minizlib@1.1.0└─┬ urllib@2.25.3└─┬ proxy-agent@2.1.0└─┬ pac-proxy-agent@2.0.0└─┬ socks-proxy-agent@3.0.1└─┬ agent-base@4.1.2└─┬ es6-promisify@5.0.0└── es6-promise@4.2.2[es@node1 elasticsearch-head-master]$ cnpm install⠸ [6/10] Installing json-schema-traverse@^0.3.0platform unsupported karma@1.3.0 › chokidar@1.7.0 › fsevents@^1.0.0 Package require os(darwin) not compatible with your platform(linux)[fsevents@^1.0.0] optional install error: Package require os(darwin) not compatible with your platform(linux)✔ Installed 10 packages✔ Linked 313 latest versionsPhantomJS not found on PATHDownload already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2Verified checksum of previously downloaded fileExtracting tar contents (via spawned process)Removing /home/es/elasticsearch-head-master/node_modules/_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt/lib/phantomCopying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1515223629881/phantomjs-2.1.1-linux-x86_64 -> /home/es/elasticsearch-head-master/node_modules/_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt/lib/phantomWriting location.js fileDone. Phantomjs binary available at /home/es/elasticsearch-head-master/node_modules/_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt/lib/phantom/bin/phantomjs✔ Run 1 scriptsdeprecate grunt-contrib-connect@1.0.2 › http2@^3.3.4 Use the built-in module in node 9.0.0 or newer, insteaddeprecate grunt@1.0.1 › coffee-script@~1.10.0 CoffeeScript on NPM has moved to "coffeescript" (no hyphen)anti semver karma@1.3.0 › useragent@2.2.1 › tmp@0.0.x delcares tmp@0.0.x(resolved as 0.0.33) but using ancestor(karma)'s dependency tmp@0.0.28(resolved as 0.0.28)✔ All packages installed (365 packages installed from npm registry, used 17s, speed 497.82kB/s, json 323(581.43kB), tarball 7.64MB)[es@node1 elasticsearch-head-master]$
1234567891011121314151617181920212223242526272829303132333435363738

2.3 配置

(0)停止ElasticSearch 如果ElasticSearch已经启动,需要先停止
[es@node1 ~]$ jps3261 Elasticsearch3375 Jps[es@node1 ~]$ kill 3261
1234(1)配置 ElasticSearch,使得HTTP对外提供服务
[es@node1 elasticsearch-6.1.1]$ vi config/elasticsearch.yml
1添加如下内容
# 增加新的参数,这样head插件可以访问es。设置参数的时候:后面要有空格http.cors.enabled: truehttp.cors.allow-origin: "*"
123(2)修改Head插件配置文件
[es@node1 elasticsearch-head-master]$ vi Gruntfile.js
1找到connect:server,添加hostname一项,如下
connect: {server: {options: {hostname: '0.0.0.0',port: 9100,base: '.',keepalive: true}}}
1234567891011

2.4 启动

(1)启动elasticsearch 首先确认elasticsearch已经启动
[es@node1 elasticsearch-6.1.1]$ bin/elasticsearch -d[es@node1 elasticsearch-6.1.1]$ jps3451 Jps3436 Elasticsearch[es@node1 elasticsearch-6.1.1]$
12345(2)启动head 通过命令
grunt server
启动head
[es@node1 elasticsearch-head-master]$ grunt server
需要在head的目录下运行Running "connect:server" (connect) taskWaiting forever...Started connect web server on http://node1:9100 
12345或者通过命令
npm run start
也可以启动head
[es@node1 elasticsearch-head-master]$ npm run start> elasticsearch-head@0.0.0 start /home/es/elasticsearch-head-master> grunt serverRunning "connect:server" (connect) taskWaiting forever...Started connect web server on http://node1:9100 
123456789(3)访问9100端口 http://10.105.45.32:9100/ 如果出现“未连接”,请修改localhost为node1,然后单击“连接”按钮

2.5 简单应用

(1)创建索引
[root@node1 ~]# curl -XPUT node1:9200/test{"acknowledged":true,"shards_acknowledged":true,"index":"test"}[root@node1 ~]# 
12(2)查看head变化 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: