一、前期准备工作:
5.x版本的ES跟之前的版本最大的不同之处就是多了很多环境的校验,比如jdk,max-files等等。
1、设置内核参数
[root@linux-node1 ~]# cat >> /etc/sysctl.conf << END
fs.file-max=65536
vm.max_map_count=262144
END
[root@linux-node1 ~]# sysctl -p
vm.max_map_count = 262144
fs.file-max = 65536
2、增加新的参数,这样head插件可以访问es
[root@linux-node1 ~]# cat >> /usr/local/elasticsearch/config/elasticsearch.yml << END
http.cors.enabled: true
http.cors.allow-origin: "*"
END
3、需要从github上面下载代码,因此先要安装git
[root@linux-node1 ~]# yum -y install git npm xz #npm,xz在安装插件的时候会用到
二、安装部署head插件
1、下载插件:git clone git://github.com/mobz/elasticsearch-head.git
2、第二步,安装node
①由于head插件本质上还是一个nodejs的工程,因此需要安装node,使用npm来安装依赖的包。(npm可以理解为maven)
去官网下载nodejs,https://nodejs.org/en/download/
下载下来的jar包是xz格式的,一般的linux可能不识别,还需要安装xz.(前面已经安装)
备注:我现在的安装包 node-v6.10.1-linux-x64.tar.xz 我的习惯是安装在/usr/local/目录下
②然后解压nodejs的安装包:
xz -d node-v6.10.1-linux-x64.tar.xz
tar -xvf node-v6.10.1-linux-x64.tar -C /usr/local/
③解压完node的安装文件后,需要配置下环境变量
[root@linux-node1 local]# cat >> /etc/profile << END
# set node environmentexport
export NODE_HOME=/usr/local/node-v6.10.1-linux-x64
export PATH=$PATH:$NODE_HOME/bin
END
④别忘记立即执行以下
source /etc/profile
⑤这个时候可以测试一下node是否生效:
[root@linux-node1 node-v6.10.1-linux-x64]# cd /usr/local/node-v6.10.1-linux-x64
[root@linux-node1 node-v6.10.1-linux-x64]# echo $NODE_HOME
/usr/local/node-v6.10.1-linux-x64
[root@linux-node1 node-v6.10.1-linux-x64]# /usr/local/node-v6.10.1-linux-x64/bin/node -v
v6.9.4
[root@linux-node1 node-v6.10.1-linux-x64]#/usr/local/node-v6.10.1-linux-x64/bin/npm -v
3.10.10
⑥安装head插件
[root@linux-node1 elasticsearch-head]# npm install
├─┬ grunt@1.0.1
│ ├── coffee-script@1.10.0
│ ├─┬ dateformat@1.0.12
│ │ ├── get-stdin@4.0.1
│ │ └─┬ meow@3.7.0
│ │ ├─┬ camelcase-keys@2.1.0
│ │ │ └── camelcase@2.1.1
│ │ ├── decamelize@1.2.0
│ │ ├─┬ loud-rejection@1.6.0
│ │ │ ├─┬ currently-unhandled@0.4.1
│ │ │ │ └── array-find-index@1.0.2
│ │ │ └── signal-exit@3.0.2
│ │ ├── map-obj@1.0.1
│ │ ├── minimist@1.2.0
│ │ ├─┬ normalize-package-data@2.3.6
│ │ │ ├── hosted-git-info@2.4.1
│ │ │ ├─┬ is-builtin-module@1.0.0
│ │ │ │ └── builtin-modules@1.1.1
│ │ │ └─┬ validate-npm-package-license@3.0.1
│ │ │ ├─┬ spdx-correct@1.0.2
│ │ │ │ └── spdx-license-ids@1.2.2
│ │ │ └── spdx-expression-parse@1.0.4
│ │ ├─┬ read-pkg-up@1.0.1
│ │ │ ├─┬ find-up@1.1.2
│ │ │ │ └── path-exists@2.1.0
│ │ │ └─┬ read-pkg@1.1.0
│ │ │ ├─┬ load-json-file@1.1.0
│ │ │ │ ├─┬ parse-json@2.2.0
│ │ │ │ │ └─┬ error-ex@1.3.1
│ │ │ │ │ └── is-arrayish@0.2.1
│ │ │ │ ├── pify@2.3.0
│ │ │ │ └─┬ strip-bom@2.0.0
│ │ │ │ └── is-utf8@0.2.1
│ │ │ └── path-type@1.1.0
│ │ ├─┬ redent@1.0.0
│ │ │ ├─┬ indent-string@2.1.0
│ │ │ │ └─┬ repeating@2.0.1
│ │ │ │ └─┬ is-finite@1.0.2
│ │ │ │ └── number-is-nan@1.0.1
│ │ │ └── strip-indent@1.0.1
│ │ └── trim-newlines@1.0.0
│ ├── eventemitter2@0.4.14
│ ├── exit@0.1.2
│ ├─┬ findup-sync@0.3.0
│ │ └── glob@5.0.15
│ ├─┬ glob@7.0.6
│ │ ├── fs.realpath@1.0.0
│ │ ├─┬ inflight@1.0.6
│ │ │ └── wrappy@1.0.2
│ │ ├── inherits@2.0.3
│ │ └── once@1.4.0
│ ├─┬ grunt-cli@1.2.0
│ │ └── resolve@1.1.7
│ ├── grunt-known-options@1.1.0
│ ├─┬ grunt-legacy-log@1.0.0
│ │ ├─┬ grunt-legacy-log-utils@1.0.0
│ │ │ └── lodash@4.3.0
│ │ ├── hooker@0.2.3
│ │ └── underscore.string@3.2.3
│ ├─┬ grunt-legacy-util@1.0.0
│ │ ├── getobject@0.1.0
│ │ ├── lodash@4.3.0
│ │ └─┬ which@1.2.14
│ │ └── isexe@2.0.0
│ ├── iconv-lite@0.4.15
│ ├─┬ js-yaml@3.5.5
│ │ ├── argparse@1.0.9
│ │ └── esprima@2.7.3
│ ├─┬ minimatch@3.0.3
│ │ └─┬ brace-expansion@1.1.6
│ │ ├── balanced-match@0.4.2
│ │ └── concat-map@0.0.1
│ ├─┬ nopt@3.0.6
│ │ └── abbrev@1.1.0
│ ├── path-is-absolute@1.0.1
│ └── rimraf@2.2.8
├─┬ grunt-contrib-clean@1.0.0
│ ├── async@1.5.2
│ └── rimraf@2.6.1
├─┬ grunt-contrib-concat@1.0.1
│ ├─┬ chalk@1.1.3
│ │ ├── ansi-styles@2.2.1
│ │ ├── escape-string-regexp@1.0.5
│ │ ├─┬ has-ansi@2.0.0
│ │ │ └── ansi-regex@2.1.1
│ │ ├── strip-ansi@3.0.1
│ │ └── supports-color@2.0.0
│ └── source-map@0.5.6
├─┬ grunt-contrib-connect@1.0.2
│ ├─┬ connect@3.6.0
│ │ ├─┬ debug@2.6.1
│ │ │ └── ms@0.7.2
│ │ ├─┬ finalhandler@1.0.0
│ │ │ ├── statuses@1.3.1
│ │ │ └── unpipe@1.0.0
│ │ ├── parseurl@1.3.1
│ │ └── utils-merge@1.0.0
│ ├── connect-livereload@0.5.4
│ ├── http2@3.3.6
│ ├─┬ morgan@1.8.1
│ │ ├── basic-auth@1.1.0
│ │ ├── depd@1.1.0
│ │ ├─┬ on-finished@2.3.0
│ │ │ └── ee-first@1.1.1
│ │ └── on-headers@1.0.1
│ ├─┬ opn@4.0.2
│ │ ├── object-assign@4.1.1
│ │ └─┬ pinkie-promise@2.0.1
│ │ └── pinkie@2.0.4
│ ├── portscanner@1.2.0
│ ├─┬ serve-index@1.8.0
│ │ ├─┬ accepts@1.3.3
│ │ │ └── negotiator@0.6.1
│ │ ├── batch@0.5.3
│ │ ├─┬ debug@2.2.0
│ │ │ └── ms@0.7.1
│ │ ├── escape-html@1.0.3
│ │ ├─┬ http-errors@1.5.1
│ │ │ └── setprototypeof@1.0.2
│ │ └─┬ mime-types@2.1.15
│ │ └── mime-db@1.27.0
│ └─┬ serve-static@1.12.1
│ ├── encodeurl@1.0.1
│ └─┬ send@0.15.1
│ ├── destroy@1.0.4
│ ├── etag@1.8.0
│ ├── fresh@0.5.0
│ └─┬ http-errors@1.6.1
│ └── setprototypeof@1.0.3
├─┬ grunt-contrib-copy@1.0.0
│ └── file-sync-cmp@0.1.1
├─┬ grunt-contrib-jasmine@1.0.3
│ ├── es5-shim@4.5.9
│ ├─┬ grunt-lib-phantomjs@1.1.0
│ │ ├─┬ phantomjs-prebuilt@2.1.14
│ │ │ ├── es6-promise@4.0.5
│ │ │ ├─┬ extract-zip@1.5.0
│ │ │ │ ├─┬ concat-stream@1.5.0
│ │ │ │ │ └── typedarray@0.0.6
│ │ │ │ ├── debug@0.7.4
│ │ │ │ ├─┬ mkdirp@0.5.0
│ │ │ │ │ └── minimist@0.0.8
│ │ │ │ └─┬ yauzl@2.4.1
│ │ │ │ └─┬ fd-slicer@1.0.1
│ │ │ │ └── pend@1.2.0
│ │ │ ├─┬ fs-extra@1.0.0
│ │ │ │ ├── jsonfile@2.4.0
│ │ │ │ └── klaw@1.3.1
│ │ │ ├─┬ hasha@2.2.0
│ │ │ │ └── is-stream@1.1.0
│ │ │ ├── kew@0.7.0
│ │ │ ├── progress@1.1.8
│ │ │ ├─┬ request@2.79.0
│ │ │ │ ├── aws-sign2@0.6.0
│ │ │ │ ├── aws4@1.6.0
│ │ │ │ ├── caseless@0.11.0
│ │ │ │ ├─┬ combined-stream@1.0.5
│ │ │ │ │ └── delayed-stream@1.0.0
│ │ │ │ ├── forever-agent@0.6.1
│ │ │ │ ├─┬ form-data@2.1.2
│ │ │ │ │ └── asynckit@0.4.0
│ │ │ │ ├─┬ har-validator@2.0.6
│ │ │ │ │ ├─┬ commander@2.9.0
│ │ │ │ │ │ └── graceful-readlink@1.0.1
│ │ │ │ │ └─┬ is-my-json-valid@2.16.0
│ │ │ │ │ ├── generate-function@2.0.0
│ │ │ │ │ ├─┬ generate-object-property@1.2.0
│ │ │ │ │ │ └── is-property@1.0.2
│ │ │ │ │ ├── jsonpointer@4.0.1
│ │ │ │ │ └── xtend@4.0.1
│ │ │ │ ├─┬ hawk@3.1.3
│ │ │ │ │ ├── boom@2.10.1
│ │ │ │ │ ├── cryptiles@2.0.5
│ │ │ │ │ ├── hoek@2.16.3
│ │ │ │ │ └── sntp@1.0.9
│ │ │ │ ├─┬ http-signature@1.1.1
│ │ │ │ │ ├── assert-plus@0.2.0
│ │ │ │ │ ├─┬ jsprim@1.4.0
│ │ │ │ │ │ ├── assert-plus@1.0.0
│ │ │ │ │ │ ├── extsprintf@1.0.2
│ │ │ │ │ │ ├── json-schema@0.2.3
│ │ │ │ │ │ └── verror@1.3.6
│ │ │ │ │ └─┬ sshpk@1.11.0
│ │ │ │ │ ├── asn1@0.2.3
│ │ │ │ │ ├── assert-plus@1.0.0
│ │ │ │ │ ├── bcrypt-pbkdf@1.0.1
│ │ │ │ │ ├─┬ dashdash@1.14.1
│ │ │ │ │ │ └── assert-plus@1.0.0
│ │ │ │ │ ├── ecc-jsbn@0.1.1
│ │ │ │ │ ├─┬ getpass@0.1.6
│ │ │ │ │ │ └── assert-plus@1.0.0
│ │ │ │ │ ├── jodid25519@1.0.2
│ │ │ │ │ ├── jsbn@0.1.1
│ │ │ │ │ └── tweetnacl@0.14.5
│ │ │ │ ├── is-typedarray@1.0.0
│ │ │ │ ├── isstream@0.1.2
│ │ │ │ ├── json-stringify-safe@5.0.1
│ │ │ │ ├── oauth-sign@0.8.2
│ │ │ │ ├── qs@6.3.2
│ │ │ │ ├── stringstream@0.0.5
│ │ │ │ ├─┬ tough-cookie@2.3.2
│ │ │ │ │ └── punycode@1.4.1
│ │ │ │ ├── tunnel-agent@0.4.3
│ │ │ │ └── uuid@3.0.1
│ │ │ └─┬ request-progress@2.0.1
│ │ │ └── throttleit@1.0.0
│ │ ├── rimraf@2.6.1
│ │ ├── semver@5.3.0
│ │ └─┬ temporary@0.0.8
│ │ └── package@1.0.1
│ ├── jasmine-core@2.5.2
│ ├── lodash@2.4.2
│ └── sprintf-js@1.0.3
├─┬ grunt-contrib-watch@1.0.0
│ ├─┬ gaze@1.1.2
│ │ └─┬ globule@1.1.0
│ │ ├── glob@7.1.1
│ │ └── lodash@4.16.6
│ ├── lodash@3.10.1
│ └─┬ tiny-lr@0.2.1
│ ├─┬ debug@2.2.0
│ │ └── ms@0.7.1
│ ├─┬ faye-websocket@0.10.0
│ │ └─┬ websocket-driver@0.6.5
│ │ └── websocket-extensions@0.1.1
│ ├── livereload-js@2.2.2
│ └── qs@5.1.0
├── grunt-karma@2.0.0
├─┬ http-proxy@1.16.2
│ ├── eventemitter3@1.2.0
│ └── requires-port@1.0.0
└─┬ karma@1.3.0
├── bluebird@3.5.0
├─┬ body-parser@1.14.2
│ ├── bytes@2.2.0
│ ├── content-type@1.0.2
│ ├─┬ debug@2.2.0
│ │ └── ms@0.7.1
│ ├── http-errors@1.3.1
│ ├── iconv-lite@0.4.13
│ ├── qs@5.2.0
│ ├─┬ raw-body@2.1.7
│ │ ├── bytes@2.4.0
│ │ └── iconv-lite@0.4.13
│ └─┬ type-is@1.6.14
│ └── media-typer@0.3.0
├─┬ chokidar@1.6.1
│ ├─┬ anymatch@1.3.0
│ │ ├── arrify@1.0.1
│ │ └─┬ micromatch@2.3.11
│ │ ├─┬ arr-diff@2.0.0
│ │ │ └── arr-flatten@1.0.1
│ │ ├─┬ braces@1.8.5
│ │ │ ├─┬ expand-range@1.8.2
│ │ │ │ └─┬ fill-range@2.2.3
│ │ │ │ ├── is-number@2.1.0
│ │ │ │ ├── isobject@2.1.0
│ │ │ │ ├── randomatic@1.1.6
│ │ │ │ └── repeat-string@1.6.1
│ │ │ ├── preserve@0.2.0
│ │ │ └── repeat-element@1.1.2
│ │ ├─┬ expand-brackets@0.1.5
│ │ │ └── is-posix-bracket@0.1.1
│ │ ├── extglob@0.3.2
│ │ ├── filename-regex@2.0.0
│ │ ├─┬ kind-of@3.1.0
│ │ │ └── is-buffer@1.1.5
│ │ ├─┬ normalize-path@2.1.1
│ │ │ └── remove-trailing-separator@1.0.1
│ │ ├─┬ object.omit@2.0.1
│ │ │ ├─┬ for-own@0.1.5
│ │ │ │ └── for-in@1.0.2
│ │ │ └── is-extendable@0.1.1
│ │ ├─┬ parse-glob@3.0.4
│ │ │ ├── glob-base@0.3.0
│ │ │ └── is-dotfile@1.0.2
│ │ └─┬ regex-cache@0.4.3
│ │ ├── is-equal-shallow@0.1.3
│ │ └── is-primitive@2.0.0
│ ├── async-each@1.0.1
│ ├── glob-parent@2.0.0
│ ├─┬ is-binary-path@1.0.1
│ │ └── binary-extensions@1.8.0
│ ├─┬ is-glob@2.0.1
│ │ └── is-extglob@1.0.0
│ └─┬ readdirp@2.1.0
│ ├─┬ readable-stream@2.0.6
│ │ ├── isarray@1.0.0
│ │ ├── process-nextick-args@1.0.7
│ │ └── util-deprecate@1.0.2
│ └── set-immediate-shim@1.0.1
├── colors@1.1.2
├─┬ combine-lists@1.0.1
│ └── lodash@4.17.4
├── core-js@2.4.1
├── di@0.0.1
├─┬ dom-serialize@2.2.1
│ ├── custom-event@1.0.1
│ ├── ent@2.2.0
│ ├── extend@3.0.0
│ └── void-elements@2.0.1
├─┬ expand-braces@0.1.2
│ ├── array-slice@0.2.3
│ ├── array-unique@0.2.1
│ └─┬ braces@0.1.5
│ └─┬ expand-range@0.1.1
│ ├── is-number@0.1.1
│ └── repeat-string@0.2.2
├── graceful-fs@4.1.11
├── isbinaryfile@3.0.2
├─┬ log4js@0.6.38
│ ├─┬ readable-stream@1.0.34
│ │ ├── core-util-is@1.0.2
│ │ ├── isarray@0.0.1
│ │ └── string_decoder@0.10.31
│ └── semver@4.3.6
├── mime@1.3.4
├─┬ optimist@0.6.1
│ ├── minimist@0.0.10
│ └── wordwrap@0.0.3
├── qjobs@1.1.5
├── range-parser@1.2.0
├── rimraf@2.6.1
├─┬ socket.io@1.4.7
│ ├─┬ debug@2.2.0
│ │ └── ms@0.7.1
│ ├─┬ engine.io@1.6.10
│ │ ├─┬ accepts@1.1.4
│ │ │ ├─┬ mime-types@2.0.14
│ │ │ │ └── mime-db@1.12.0
│ │ │ └── negotiator@0.4.9
│ │ ├── base64id@0.1.0
│ │ ├─┬ debug@2.2.0
│ │ │ └── ms@0.7.1
│ │ ├─┬ engine.io-parser@1.2.4
│ │ │ ├── after@0.8.1
│ │ │ ├── arraybuffer.slice@0.0.6
│ │ │ ├── base64-arraybuffer@0.1.2
│ │ │ ├── blob@0.0.4
│ │ │ ├─┬ has-binary@0.1.6
│ │ │ │ └── isarray@0.0.1
│ │ │ └── utf8@2.1.0
│ │ └─┬ ws@1.0.1
│ │ ├── options@0.0.6
│ │ └── ultron@1.0.2
│ ├─┬ has-binary@0.1.7
│ │ └── isarray@0.0.1
│ ├─┬ socket.io-adapter@0.4.0
│ │ ├─┬ debug@2.2.0
│ │ │ └── ms@0.7.1
│ │ └─┬ socket.io-parser@2.2.2
│ │ ├── debug@0.7.4
│ │ ├── isarray@0.0.1
│ │ └── json3@3.2.6
│ ├─┬ socket.io-client@1.4.6
│ │ ├── backo2@1.0.2
│ │ ├── component-bind@1.0.0
│ │ ├── component-emitter@1.2.0
│ │ ├─┬ debug@2.2.0
│ │ │ └── ms@0.7.1
│ │ ├─┬ engine.io-client@1.6.9
│ │ │ ├── component-inherit@0.0.3
│ │ │ ├─┬ debug@2.2.0
│ │ │ │ └── ms@0.7.1
│ │ │ ├── has-cors@1.1.0
│ │ │ ├── parsejson@0.0.1
│ │ │ ├── parseqs@0.0.2
│ │ │ ├── xmlhttprequest-ssl@1.5.1
│ │ │ └── yeast@0.1.2
│ │ ├── indexof@0.0.1
│ │ ├── object-component@0.0.3
│ │ ├─┬ parseuri@0.0.4
│ │ │ └─┬ better-assert@1.0.2
│ │ │ └── callsite@1.0.0
│ │ └── to-array@0.1.4
│ └─┬ socket.io-parser@2.2.6
│ ├── benchmark@1.0.0
│ ├── component-emitter@1.1.2
│ ├─┬ debug@2.2.0
│ │ └── ms@0.7.1
│ ├── isarray@0.0.1
│ └── json3@3.3.2
├─┬ tmp@0.0.28
│ └── os-tmpdir@1.0.2
└─┬ useragent@2.1.13
└── lru-cache@2.2.4
npm 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.1: 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
3、安装grunt
grunt是一个很方便的构建工具,可以进行打包压缩、测试、执行等等的工作,5.X里的head插件就是通过grunt启动的。
安装完成后检查一下:
[root@linux-node1 ~]# cd /usr/local/elasticsearch-head/node_modules/grunt/bin/
[root@linux-node1 bin]# pwd
/usr/local/elasticsearch-head/node_modules/grunt/bin
[root@linux-node1 bin]# ./grunt -V
grunt-cli v1.2.0
grunt v1.0.1
备注:我们在执行npm install 的时候,默认已经安装,如果自己安装的话,需要执行npm install grunt-cli
4、修改head源码
由于head的代码还是2.6版本的,直接执行有很多限制,比如无法跨机器访问。因此需要用户修改两个地方:
①修改服务器监听地址
[root@linux-node1 elasticsearch-head]# pwd
/usr/local/elasticsearch-head/
[root@linux-node1 elasticsearch-head]# vim Gruntfile.js #添加上下面的内容
connect: {
server: {
options: {
port: 9100,
hostname: '*',
base: '.',
keepalive: true
}
}
}
增加hostname属性,设置为*
②修改连接地址:
[root@linux-node1 _site]# pwd
/usr/local/elasticsearch-head/_site
[root@linux-node1 _site]# vim 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.88.133:9200";
5、运行head
然后在head目录中,执行npm install 下载以来的包:
[root@linux-node1 elasticsearch-head]# pwd
/usr/local/elasticsearch-head/
[root@linux-node1 elasticsearch-head]# npm install
三、启动
1、开启5.X的 ES。
备注:参照的我的博客
http://blog.csdn.net/m0_37886429/article/details/68487922
② CentOS7上elasticsearch5.0启动失败
http://blog.csdn.net/m0_37886429/article/details/68486682
2、启动nodejs
[root@linux-node1 ~]# cd /usr/local/elasticsearch-head/node_modules/grunt/bin/
[root@linux-node1 bin]# pwd
/usr/local/elasticsearch-head/node_modules/grunt/bin
[root@linux-node1 bin]# ./grunt server &
访问: target:9100
这个时候,访问http://192.168.88.133:9100就可以访问head插件了.