linux手动安装es

docker下载

shell 复制代码
docker pull elasticsearch:7.9.3
docker pull kibana:7.9.3
  • 检查安装目录下存在文件夹/data/elasticsearch/data ,如果缺少,请创建目录并设置权限,否则会因为无权限访问而启动失败。
shell 复制代码
# 创建目录
mkdir /data/elasticsearch/data/

# 创建并改变该目录权限
chmod 777 /data/elasticsearch/data

docker-compose文件

复制代码
version: '2.1'
services:
  ad_elasticsearch:
    image: elasticsearch:7.9.3
    container_name: ad_elasticsearch
    restart: always
    environment:
      - "cluster.name=elasticsearch" #设置集群名称为elasticsearch
      - "discovery.type=single-node" #以单一节点模式启动
      - "ES_JAVA_OPTS=-Xms512m -Xmx1024m" #设置使用jvm内存大小
    volumes:
      - ./data:/usr/share/elasticsearch/data:rw
      - ./logs:/user/share/elasticsearch/logs:rw
      - ./esplugins:/usr/share/elasticsearch/plugins
    ports:
      - 9200:9200
      - 9300:9300

  kibana:
    image: kibana:7.9.3
    container_name: ad_kibana
    links:
      - ad_elasticsearch:elasticsearch #可以用es这个域名访问elasticsearch服务
    depends_on:
      - ad_elasticsearch #kibana在elasticsearch启动之后再启动
    environment:
      - "elasticsearch.hosts=http://elasticsearch:9200" #设置访问elasticsearch的地址
    ports:
      - 5601:5601

yml文件配置完毕以后,接下来指定文件运行容器。

shell 复制代码
docker-compose -f docker-compose.yml up -d

启动完毕以后应该可以看到一系列的容器出现start状态。 可以查看容器的日志。

shell 复制代码
# 查看全部的docker-compose 日志
docker-compose logs

需要安装中文分词器IKAnalyzer,并重新启动。

注意下载与Elasticsearch对应的版本。安装目录已经存在elasticsearch-analysis-ik-7.9.3.zip,需要解压到指定目录。

shell 复制代码
# 在安装目录的esplugin中创建文件夹
cd esplugin && mkdir analysis-ik

# 退出到安装目录
cd ..

# 解压缩到指定文件夹
unzip elasticsearch-analysis-ik-7.9.3.zip -d ./esplugin/analysis-ik/
docker restart ad_elasticsearch

Ingest Attachment Processor Plugin是一个文本抽取插件,本质上是利用了Elasticsearchingest node功能,提供了关键的预处理器attachment

shell 复制代码
docker exec -it ad_elasticsearch /bin/sh

进入容器后,在安装目录下运行以下命令即可安装。

shell 复制代码
./bin/elasticsearch-plugin install ingest-attachment

重新启动服务

shell 复制代码
docker restart ad_elasticsearch

设置通道索引

shell 复制代码
PUT /_ingest/pipeline/attachment
{
    "description": "Extract attachment information",
    "processors": [
        {
            "attachment": {
                "field": "content",
                "ignore_missing": true
            }
        },
        {
            "remove": {
                "field": "content"
            }
        }
    ]
}

建立文档索引

复制代码
PUT /docwrite
{
  "mappings" : {
      "properties" : {
        "ancestors" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "attachment" : {
          "properties" : {
            "content" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              },
              "analyzer" : "ik_smart"
            },
            "content_length" : {
              "type" : "long"
            },
            "content_type" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "language" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        },
        "authObjs" : {
          "properties" : {
            "authId" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "authType" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "docId" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "parkId" : {
              "type" : "long"
            },
            "receiveUserId" : {
              "type" : "long"
            }
          }
        },
        "content" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "createDeptId" : {
          "type" : "long"
        },
        "createTime" : {
          "type" : "date"
        },
        "createUserId" : {
          "type" : "long"
        },
        "description" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "docFormat" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "docId" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "docName" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          },
          "analyzer" : "ik_smart"
        },
        "docOwner" : {
          "type" : "long"
        },
        "docSize" : {
          "type" : "long"
        },
        "docUrl" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "encry" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "hasRecycle" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "parentId" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "parkId" : {
          "type" : "long"
        },
        "updateDeptId" : {
          "type" : "long"
        },
        "updateTime" : {
          "type" : "date"
        },
        "updateUserId" : {
          "type" : "long"
        }
      }
    }
}
相关推荐
SelectDB20 小时前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
Elasticsearch2 天前
3个信号、2个环境变量、0个采集器:使用 Python 和 Elastic 的托管 OTLP 端点实现 OpenTelemetry
elasticsearch
XIAOHEZIcode2 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220703 天前
如何搭建本地yum源(上)
运维
Elasticsearch4 天前
如何通过 Claude Code 来写入 CSV 数据到 Elasticsearch
elasticsearch
大树886 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠6 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
大志哥1236 天前
ES和Logstash日志链路系统上线后遭遇切片爆炸(解决)
大数据·elasticsearch
霸道流氓气质6 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务