ElasticSearch以及Head插件安装

  1. 涉及到的软件版本
  2. 配置:

    1. 配置系统变量:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      #提前修改对应的配置防止出现如下错误
      - max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
      解决办法: ulimit -n 65536
      vim /etc/security/limits.conf
      添加如下内容:
      * soft nofile 65536
      * hard nofile 131072
      * soft nproc 2048
      * hard nproc 4096
      - max number of threads [1024] for user [es] likely too low, increase to at least [2048]
      vi /etc/security/limits.d/90-nproc.conf
      找到如下内容:
      * soft nproc 1024
      #修改为
      * soft nproc 2048
      - max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
      解决办法:
      1. 修改配置sysctl.conf: vi /etc/sysctl.conf
      2. 添加下面配置: vm.max_map_count=655360
      3. 执行命令: sysctl -p
    2. 配置JDK,NodeJS的环境变量

    3. 解压es和es-head插件
    4. master,slave01,slave02三台机器进行配置
    5. master配置文件如下:

      1
      2
      3
      4
      5
      6
      7
      8
      cluster.name: WALL-E
      node.name: master
      node.master: true
      network.host: 0.0.0.0
      http.port: 9200
      #----------------------------------- Head Plugin ------------------------------
      http.cors.enabled: true
      http.cors.allow-origin: "*"
    6. slave配置文件如下:

      1
      2
      3
      4
      5
      cluster.name: WALL-E
      node.name: slave01
      network.host: 172.18.100.170
      http.port: 9201
      discovery.zen.ping.unicast.hosts: ["172.18.100.170"]
    7. 在head插件中启动: nohup npm run start > /dev/null &

    8. 完成

Tips:

  • NPM安装包慢,可以使用淘宝的镜像:
    npm config set registry https://registry.npm.taobao.org
  • 根据自己机器配置JVM的内存,默认1G:
    -Xms1g
    -Xmx1g

安装常见问题:

  • 启动用户不能是root
    解决办法: adduser es,切换到es 用户启动es
  • system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
    问题原因: 因为Centos6不支持SecComp,而ES5.2.1默认bootstrap.system_call_filter为true进行检测,所以导致检测失败不能启动
    解决方法: 在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:

    1
    2
    bootstrap.memory_lock: false
    bootstrap.system_call_filter: false
  • Head插件phantomjs解压问题:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    > phantomjs-prebuilt@2.1.16 install /usr/local/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt
    > node install.js

    PhantomJS not found on PATH
    Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
    Verified checksum of previously downloaded file
    Extracting tar contents (via spawned process)
    Error extracting archive
    Phantom installation failed { Error: Command failed: tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
    tar (child): bzip2: Cannot exec: No such file or directory
    tar (child): Error is not recoverable: exiting now
    tar: Child returned status 2
    tar: Error is not recoverable: exiting now

    at ChildProcess.exithandler (child_process.js:272:12)
    at ChildProcess.emit (events.js:159:13)
    at maybeClose (internal/child_process.js:943:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
    killed: false,
    code: 2,
    signal: null,
    cmd: 'tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2' } Error: Command failed: tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
    tar (child): bzip2: Cannot exec: No such file or directory
    tar (child): Error is not recoverable: exiting now
    tar: Child returned status 2
    tar: Error is not recoverable: exiting now

    at ChildProcess.exithandler (child_process.js:272:12)
    at ChildProcess.emit (events.js:159:13)
    at maybeClose (internal/child_process.js:943:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
    npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (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 ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR! /root/.npm/_logs/2017-11-24T06_23_42_070Z-debug.log

    解决办法,系统提供的lib解压有问题,安装bzip2即可: yum -y install bzip2

  • Head插件phantomjs权限问题:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    > phantomjs-prebuilt@2.1.16 install /usr/local/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt
    > node install.js

    PhantomJS not found on PATH
    Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
    Verified checksum of previously downloaded file
    Extracting tar contents (via spawned process)
    Removing /usr/local/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom
    Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1511506753039/phantomjs-2.1.1-linux-x86_64 -> /usr/local/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom
    Phantom installation failed { Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1511506753039/phantomjs-2.1.1-linux-x86_64' -> '/usr/local/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom'
    errno: -13,
    code: 'EACCES',
    syscall: 'link',
    path: '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1511506753039/phantomjs-2.1.1-linux-x86_64',
    dest: '/usr/local/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom' } Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1511506753039/phantomjs-2.1.1-linux-x86_64' -> '/usr/local/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom'
    npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (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 ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR! /root/.npm/_logs/2017-11-24T06_59_17_542Z-debug.log

    解决办法: npm install -g