官方文档

https://www.elastic.co/guide/en/elasticsearch/reference/6.4/docs.html

安装jdk8

参见:源码安装 jdk8

安装elasticsearch

  1. 下载地址:
    https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-4-3

  2. 解压:

    tar -xzf elasticsearch-6.4.3.tar.gz
    mv elasticsearch-6.4.3 /usr/local/elasticsearch
  3. 修改配置文件:

    1. 内存配置:
      cd /usr/local/elasticsearch
      vim config/jvm.options
      -Xms512m
      -Xmx512m
    2. 网络配置:
      vim config/elasticsearch.yml
      cluster.name: my-application
      node.name: node1
      bootstrap.memory_lock: false
      network.host: 0.0.0.0  # 允许远程访问
      http.port: 9200
      discovery.zen.ping.unicast.hosts: ["10.0.0.11"]
      discovery.zen.minimum_master_nodes: 1
    3. 系统配置:
      1. 最大文件句柄数配置:
        vim /etc/sysctl.conf
        vm.max_map_count=655360
        sysctl -p
      2. 进程数量配置:
        vim /etc/security/limits.conf
         * soft nofile 65536
         * hard nofile 131072
         * soft nproc 2048
         * hard nproc 4096
  4. 添加用户:

    groupadd es
    useradd es -g es -p 123456
    chown -R es.es /usr/local/elasticsearch
  5. 启动:

    # 前台启动
    su es -l -c "/usr/local/elasticsearch/bin/elasticsearch"
    # 后台启动
    su es -l -c "/usr/local/elasticsearch/bin/elasticsearch -d"
  6. 验证:
    curl http://10.0.0.11:9200

安装analysis-ik(中文分词插件)

  1. 下载地址:
    https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.3/elasticsearch-analysis-ik-6.4.3.zip

  2. 安装:

    unzip elasticsearch-analysis-ik-6.4.3.zip -d ik
    mv ik /usr/local/elasticsearch/plugins/
  3. 重启elasticsearch(略)

  4. 测试:

     curl -H "Content-Type: application/json" -X PUT '10.0.0.11:9200/accounts' -d '
     {
       "mappings": {
         "person": {
           "properties": {
             "user": {
               "type": "text",
               "analyzer": "ik_max_word",
               "search_analyzer": "ik_max_word"
             },
             "title": {
               "type": "text",
               "analyzer": "ik_max_word",
               "search_analyzer": "ik_max_word"
             },
             "desc": {
               "type": "text",
               "analyzer": "ik_max_word",
               "search_analyzer": "ik_max_word"
             }
           }
         }
       }
     }'

安装kibana

  1. 下载地址:
    https://www.elastic.co/cn/downloads/past-releases/kibana-6-4-3

  2. 解压:

    tar -xzf kibana-6.4.3-linux-x86_64.tar.gz
    mv kibana-6.4.3-linux-x86_64 /usr/local/kibana
  3. 修改配置文件:
    cd /usr/local/kibana/
    vim config/kibana.yml

    server.port: 5601
    server.host: "10.0.0.11"
    elasticsearch.url: "http://10.0.0.11:9200"
  4. 启动(应确保elasticsearch已启动):
    /usr/local/kibana/bin/kibana

  5. 访问地址:
    http://10.0.0.11:5601/app/kibana

文档更新时间: 2024-03-24 15:25   作者:lee