Elasticsearch-linux环境部署-安装7.3.0版本

时间:2024-11-08 09:33:24

elasticsearch 7以上版本开始内置了jdk,如本文中部署的7.3.0版本就内置了jdk 11,如果使用的服务器已经安装配置了jdk 1.8的话,可以直接使用elasticsearch-7.3.0自带的jdk。

  • 解压压缩文件

    cd /data2
    tar -zxvf elasticsearch-7.3.0-linux-x86_64.tar.gz
    
  • 更改配置文件elasticsearch.yml

    path.data: /data2/elasticsearch-7.3.0/data
    path.logs: /data2/elasticsearch-7.3.0/logs
    network.host: 0.0.0.0
    http.port: 19200
    #  以下配置都是出现异常后的,新增的配置 一台服务器中部署两个elasticsearch不同版本的服务
    #  注:node.name 的值要与 cluster.initial_master_nodes 的值保持一致
    node.name: node-2
    discovery.seed_hosts: ["127.0.0.1"]
    cluster.initial_master_nodes: ["node-2"]
    
  • 更改配置文件jvm.options

    # 由于在启动时,出现了异常,需要更换GC算法
    #-XX:+UseConcMarkSweepGC
    -XX:+UseG1GC
    
  • 更换脚本文件elasticsearch-env

    #if [ ! -z "$JAVA_HOME" ]; then
    #  JAVA="$JAVA_HOME/bin/java"
    #else
    #  if [ "$(uname -s)" = "Darwin" ]; then
    #    # OSX has a different structure
    #    JAVA="$ES_HOME/jdk/Contents/Home/bin/java"
    #  else
    #    JAVA="$ES_HOME/jdk/bin/java"
    #  fi
    #fi
    # 将以上原始的脚本段注释掉,使用以下内容;JAVA 为 elasticsearch自带的jdk的路径
    if [ ! -z "$JAVA_HOME" ]; then
      JAVA="/data2/elasticsearch-7.3.0/jdk/bin/java"
    else
      if [ "$(uname -s)" = "Darwin" ]; then
        # OSX has a different structure
        JAVA="/data2/elasticsearch-7.3.0/jdk/bin/java"
      else
        JAVA="/data2/elasticsearch-7.3.0/jdk/bin/java"
      fi
    fi
    
  • 切换es用户启动

    su es
    cd /data2/elasticsearch-7.3.0
    # 后台启动elasticsearch服务
    ./bin/elasticsearch -d
    
  • 查看是否启动成功

    1. 查看日志

      cd /data2/elasticsearch-7.3.0/logs
      # 查看日志是否正常启动
      tail -f elasticsearch.log
      
    2. 查看进程

      ps -ef |grep elasticsearch
      
    3. 查看api:http://10.10.87.20:19200/

      {
        "name" : "centos74-0.novalocal",
        "cluster_name" : "elasticsearch",
        "cluster_uuid" : "_na_",
        "version" : {
          "number" : "7.3.0",
          "build_flavor" : "default",
          "build_type" : "tar",
          "build_hash" : "de777fa",
          "build_date" : "2019-07-24T18:30:11.767338Z",
          "build_snapshot" : false,
          "lucene_version" : "8.1.0",
          "minimum_wire_compatibility_version" : "6.8.0",
          "minimum_index_compatibility_version" : "6.0.0-beta1"
        },
        "tagline" : "You Know, for Search"
      }