zoukankan      html  css  js  c++  java
  • elasticsearch-6.8.5单机部署(当生产环境使用)

    前提条件安装java8,否则启动的时候报错误
    the minimum required Java version is 8; your Java version from [/opt/develop/jdk1.7.0_79/jre] does not meet this requirement


    1.下载需要的安装版本
    我这里下载的是6.8.5,elasticsearch-6.8.5.tar.gz
    下载地址:
    https://www.elastic.co/cn/downloads/past-releases#elasticsearch

    2.创建中间件安装目录和数据文件、日志文件目录
    [root@hadoop-slave1 soft]# mkdir -p /usr/local/services
    [root@hadoop-slave1 soft]# mkdir -p /home/middle/elasticsearch/data
    [root@hadoop-slave1 soft]# mkdir -p /home/middle/elasticsearch/logs

    2.上传到服务器
    解压缩并创建数据目录
    [root@hadoop-slave1 soft]# tar -xvf elasticsearch-6.8.5.tar.gz
    [root@localhost soft]# mv elasticsearch-6.8.5 /usr/local/services/elasticsearch
    [root@localhost soft]#cd /usr/local/services/elasticsearch

    3.将elasticsearch目录权限修改为yeemiao
    [root@hadoop-slave1 config]# cd /usr/local/services
    [root@hadoop-slave1 services]# chown -R yeemiao.yeemiao ./elasticsearch
    同时修改数据文件和日志文件目录给到yeemiao
    [root@hadoop-slave1 services]# cd /home/middle
    [root@hadoop-slave1 middle]# chown -R yeemiao.yeemiao ./elasticsearch

    4.创建备份目录
    su - yeemiao
    mkdir -p /home/yeemiao/esbak

    5.修改配置文件
    [root@hadoop-slave1 middle]# su - yeemiao
    [yeemiao@hadoop-slave1 ~]$ cd /usr/local/services/elasticsearch/config
    [yeemiao@hadoop-slave1 config]$ vi elasticsearch.yml

    注意修改如下几项:
    path.data: /home/middle/elasticsearch/data
    path.logs: /home/middle/elasticsearch/logs
    network.host: 192.168.1.63
    http.port: 19200
    path.repo: /home/yeemiao/esbak

    ##安全认证
    xpack.security.enabled: true
    xpack.security.transport.ssl.enabled: true


    6.修改jvm参数(/usr/local/services/elasticsearch/config/jvm.options)

    ## JVM configuration

    ################################################################
    ## IMPORTANT: JVM heap size
    ################################################################
    ##
    ## You should always set the min and max JVM heap
    ## size to the same value. For example, to set
    ## the heap to 4 GB, set:
    ##
    ## -Xms4g
    ## -Xmx4g
    ##
    ## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
    ## for more information
    ##
    ################################################################

    # Xms represents the initial size of total heap space
    # Xmx represents the maximum size of total heap space

    -Xms8g
    -Xmx8g


    7.修改/usr/local/services/elasticsearch/bin/elasticsearch
    #   ES_JAVA_OPTS="-Xms8g -Xmx8g" ./bin/elasticsearch
    export ES_HEAP_SIZE=8g

    8.启动
    su - yeemiao
    [yeemiao@hadoop-slave1 ~]$ cd /usr/local/services/elasticsearch
    ./elasticsearch -d

    9.验证
    这个时候登陆会报错误
    [yeemiao@hadoop-slave1 bin]$ curl http://192.168.1.63:19200/?pretty
    {
      "error" : {
        "root_cause" : [
          {
            "type" : "security_exception",
            "reason" : "missing authentication token for REST request [/?pretty]",
            "header" : {
              "WWW-Authenticate" : "Basic realm="security" charset="UTF-8""
            }
          }
        ],
        "type" : "security_exception",
        "reason" : "missing authentication token for REST request [/?pretty]",
        "header" : {
          "WWW-Authenticate" : "Basic realm="security" charset="UTF-8""
        }
      },
      "status" : 401
    }

    10.安装安全认证(我这里密码全部设置为 sdrdev123)
    [yeemiao@hadoop-slave1 ~]$ cd /usr/local/services/elasticsearch/bin
    [esuser@localhost bin]$ ./elasticsearch-setup-passwords interactive
    Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
    You will be prompted to enter passwords as the process progresses.
    Please confirm that you would like to continue [y/N]y

    Enter password for [elastic]:
    Reenter password for [elastic]:
    Enter password for [apm_system]:
    Reenter password for [apm_system]:
    Enter password for [kibana]:
    Reenter password for [kibana]:
    Enter password for [logstash_system]:
    Reenter password for [logstash_system]:
    Enter password for [beats_system]:
    Reenter password for [beats_system]:
    Enter password for [remote_monitoring_user]:
    Reenter password for [remote_monitoring_user]:
    Changed password for user [apm_system]
    Changed password for user [kibana]
    Changed password for user [logstash_system]
    Changed password for user [beats_system]
    Changed password for user [remote_monitoring_user]
    Changed password for user [elastic]

    11.再次验证
    curl -u elastic:sdrdev123 http://192.168.1.63:19200/?pretty
    {
      "name" : "Jzm_fbR",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "igZpEAg9T5uF1PGdit6dVQ",
      "version" : {
        "number" : "6.8.5",
        "build_flavor" : "default",
        "build_type" : "tar",
        "build_hash" : "78990e9",
        "build_date" : "2019-11-13T20:04:24.100411Z",
        "build_snapshot" : false,
        "lucene_version" : "7.7.2",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
      },
      "tagline" : "You Know, for Search"
    }

    12.设置开启自启动

    14.设置开机自启动
    /etc/systemd/system/elasticsearch.service

    在/etc/systemd/system目录下创建 elasticsearch.service 文件
    root下操作
    vi /etc/systemd/system/elasticsearch.service

    [Unit]
    Description=elasticsearch
    [Service]
    User=yeemiao
    LimitNOFILE=100000
    LimitNPROC=100000
    ExecStart=/usr/bin/su - yeemiao -c "/usr/local/services/elasticsearch/bin/elasticsearch -d -p pid"
    [Install]
    WantedBy=multi-user.target

    设置开机自启
    systemctl enable elasticsearch

  • 相关阅读:
    HNU 12906 Battleship
    codeforces 261 D
    HDU 4939 Stupid Tower Defense(dp)
    HDU 4941 Magical Forest(map映射+二分查找)杭电多校训练赛第七场1007
    HDU 4902 Nice boat 2014杭电多校训练赛第四场F题(线段树区间更新)
    【转载】使用Pandas对数据进行筛选和排序
    【转载】使用pandas进行数据清洗
    【转载】VC维的来龙去脉
    Python-时间操作
    Pandas-数据导入
  • 原文地址:https://www.cnblogs.com/hxlasky/p/13361631.html
Copyright © 2011-2022 走看看