Linux CentOS7 单机部署elasticsearch-7.2.0

1,593 阅读2分钟
  • 安装规划
软件版本软件安装路径访问路径安装用户
7.2.0kibana/opt/kibana-7.2.0-linux-x86_64http://192.168.66.151:5601/elsearch
Elasticsearch/opt/elasticsearch-7.2.0http://192.168.66.151:9200/elsearch
  • 软件安装包下载

    #elasticsearch安装
    wget -p /soft/es/elasticsearch https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-linux-x86_64.tar.gz
    #kibana 下载
    wget -p /soft/es/elasticsearch https://artifacts.elastic.co/downloads/kibana/kibana-7.2.0-linux-x86_64.tar.gz
    
  • 安装环境准备

    设置一些elasticsearch启动需要的一些额外操作系统设置

    ​ 1.修改所有用户最大可创建的文件数目,如果不设置,启动会报max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]错误

    echo "* soft nofile 65536" >> /etc/security/limits.conf  
    echo "* hard nofile 65536" >> /etc/security/limits.conf      
    

    ​ 2.修改最大虚拟内存,如果不设置,启动会报max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

    echo "vm.max_map_count=262144" >> /etc/sysctl.conf sysctl -w vm.max_map_count=262144       
    

    ​ 可以使用以下命令查看是否生效:

    sysctl -a | grep vm.max_map_count       
    

    ​ 3.设置用户最大线程数,如果不设置,启动会报max number of threads [3795] for user [esuser] is too low, increase to at least [4096]

    echo "* soft nproc 4096" >> /etc/security/limits.conf  
    echo "* hard nproc 4096" >> /etc/security/limits.conf      
    
    1. jdk环境,建议为1.8,具体安装省略

    2. 添加运行elasticsearch的用户(es必须使用非root用户启动)

      groupadd elsearch
      useradd elsearch -g elsearch -p 123456
      chown -R elsearch:elsearch /opt/es
      

elasticsearch安装

  1. 下载载安装包elasticsearch-7.2.0-linux-x86_64.tar.gz解压文件

    tar -zxvf elasticsearch-7.2.0-linux-x86_64.tar.gz
    
  2. 查看所修改的配置文件

    [elsearch@hejt-29 es]$ grep -v "^#" elasticsearch-7.2.0/config/elasticsearch.yml | more
     cluster.name: es-demo
     node.name: node-1
     node.master: true
     node.data: true
     http.cors.enabled: true
     http.cors.allow-origin: "*"
     http.port: 9200
     transport.tcp.port: 9300
     path.data: /soft/es/to/data
     path.logs: /soft/es/to/logs
     bootstrap.memory_lock: true
     network.host: 0.0.0.0
     discovery.seed_hosts: ["127.0.0.1"]
     cluster.initial_master_nodes: ["node-1"]
    [elsearch@hejt-29 es]$
    
  3. es内存调整配置文件(建议配置为物理内存的一半或者更多最好不要超过32G,超过了也可能不会增强性能):

    /soft/es/elasticsearch-7.2.0/config/jvm.options
    sed -i 's/-Xms2g/-Xms32g/' /soft/es/elasticsearch-7.2.0/config/jvm.options
    sed -i 's/-Xmx2g/-Xmx32g/' /soft/es/elasticsearch-7.2.0/config/jvm.options
    echo "-Xss256k" >>/opt/elasticsearch/elasticsearch-5.2.0/config/jvm.options
    
  4. 启动

    /soft/es/elasticsearch-7.2.0/bin/elasticsearch -d
    
  5. 验证

[elsearch@hejt-29 es]$ curl -i -XGET '192.168.66.151:9200/'
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 502

{
  "name" : "node-1",
  "cluster_name" : "es-demo",
  "cluster_uuid" : "-6Eg9-Y_R52KELnET06Asg",
  "version" : {
    "number" : "7.2.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "508c38a",
    "build_date" : "2019-06-20T15:54:18.811730Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[elsearch@hejt-29 es]$ 

kibana 安装

  1. 解压

    tar  -zxvf  kibana-7.2.0-linux-x86_64.tar.gz   
    
  2. 修改配置文件

    #查看kibana配置文件去掉空行和注释行,如下主要配置内容
    [elsearch@hejt-29 es]$ grep -v "^#" ./kibana-7.2.0-linux-x86_64/config/kibana.yml| grep -v "^$" | more
    server.port: 5601
    server.host: "192.168.66.151"
    server.name: "kibana-audit-asiainfo"
    elasticsearch.hosts: ["http://192.168.66.151:9200"]
    i18n.locale: "zn-CN"
    [elsearch@hejt-29 es]$
    
  3. 启动

    ./kibana-7.2.0-linux-x86_64/bin/kibana
    #或者后台启动
    nohup /soft/es/kibana-7.2.0-linux-x86_64/bin/kibana > /dev/null 2>&1 &
    
  4. 验证

netstat -tunlp|grep 5601

微信图片_20210506102647.png