Saki's 研究记录

Zinc 全文索引的搜索引擎 —— 部署[1]

字数统计: 1.1k阅读时长: 5 min
2022/07/22

简介

官网: zincsearch
项目地址: zinc,该项目开源目前 Star9.7k+
开源协议:Apache 2.0

Zinc 是一个进行全文索引的开源搜索引擎,企业内部搭建搜索引擎常用 SolrElasticsearch,它们都是使用 Java实现的,底层依赖 LuceneJava相对来说占用较多内存。 Zinc目标就是作为 Elasticsearch的轻量级替代品。 Zinc运行所需的内存不到 100 MB,使用 bluge(bulgeGolang实现的全文检索库,功能上类似 lucene)作为底层索引库。与 elasticsearch相比,它非常简单且易于操作。

如对于只使用 API获取数据,并使用 kibana进行搜索的开发者,,那么它是 Elasticsearch的直接替代品( Kibana不支持 ZincZinc提供了自己的 UI)。

Zinc 主要有如下特性:

  • 提供全文索引功能
  • 单个二进制文件即可安装、运行,支持多平台。这得益于 Go 语言
  • Vue编写的用于查询数据的 Web UI
  • 兼容 Elasticsearch的数据获取 API(单一记录和批量 API
  • 内建开箱即用的身份验证
  • Schema less - 无需预先定义 schema,同一索引中的不同文档可以有不同的字段

2022年5月31日,已经实现基本搜索和 API了,集群高可用分布式等等还在开发中。
版本更新: github.com/zinclabs/zinc/releases
更多技术细节请参阅原项目,支持普通安装(可以直接下载编译好的二进制文件),也支持 DockerK8S安装使用。

部署

  1. 搜索镜像:

    1
    2
    3
    # docker search zinc
    NAME DESCRIPTION STARS OFFICIAL AUTOMATED
    hiprabhat/zinc Zinc search engine 0
  2. 拉取镜像:

    1
    docker pull hiprabhat/zinc
  3. 环境准备:

    1
    mkdir data
  4. 编辑 docker-compose.yaml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    version: '3'
    services:
    zinc:
    image: docker.io/hiprabhat/zinc:latest
    container_name: zinc
    ports:
    - "4080:4080"
    environment:
    TZ: Asia/Shanghai
    FIRST_ADMIN_USER: admin
    FIRST_ADMIN_PASSWORD: admin123
    DATA_PATH: /data
    deploy:
    restart_policy:
    delay: 0s
    condition: "always"
    resources:
    limits:
    memory: 1024M
    volumes:
    - $PWD/data:/data
    - /etc/localtime:/etc/localtime:ro
    networks:
    - appnet

    networks:
    appnet:
  5. 启动服务

    1
    docker-compose up

    启动信息:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    [+] Running 2/2
    ⠿ Network zinc_appnet Created 0.0s
    ⠿ Container zinc Created 0.1s
    Attaching to zinc
    zinc | {"level":"debug","time":"2022-07-20T11:09:15Z","message":"Loading indexes..."}
    zinc | {"level":"debug","time":"2022-07-20T11:09:15Z","message":"Loading system indexes..."}
    zinc | {"level":"debug","time":"2022-07-20T11:09:15Z","message":"Index loaded: _users"}
    zinc | {"level":"debug","time":"2022-07-20T11:09:15Z","message":"Index loaded: _index_mapping"}
    zinc | {"level":"debug","time":"2022-07-20T11:09:15Z","message":"Error loading .env file"}
    zinc | [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
    zinc | - using env: export GIN_MODE=release
    zinc | - using code: gin.SetMode(gin.ReleaseMode)
    zinc |
    zinc | [GIN-debug] GET /healthz --> github.com/prabhatsharma/zinc/pkg/meta/v1.GetHealthz (3 handlers)
    zinc | [GIN-debug] GET / --> github.com/prabhatsharma/zinc/pkg/meta/v1.GUI (3 handlers)
    zinc | [GIN-debug] GET /ui/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
    zinc | [GIN-debug] HEAD /ui/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
    zinc | [GIN-debug] POST /api/login --> github.com/prabhatsharma/zinc/pkg/handlers.ValidateCredentials (3 handlers)
    zinc | [GIN-debug] PUT /api/user --> github.com/prabhatsharma/zinc/pkg/handlers.CreateUpdateUser (4 handlers)
    zinc | [GIN-debug] DELETE /api/user/:userID --> github.com/prabhatsharma/zinc/pkg/handlers.DeleteUser (4 handlers)
    zinc | [GIN-debug] GET /api/users --> github.com/prabhatsharma/zinc/pkg/handlers.GetUsers (4 handlers)
    zinc | [GIN-debug] PUT /api/index --> github.com/prabhatsharma/zinc/pkg/handlers.CreateIndex (4 handlers)
    zinc | [GIN-debug] GET /api/index --> github.com/prabhatsharma/zinc/pkg/handlers.ListIndexes (4 handlers)
    zinc | [GIN-debug] PUT /api/:target/document --> github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument (4 handlers)
    zinc | [GIN-debug] POST /api/:target/_search --> github.com/prabhatsharma/zinc/pkg/handlers.SearchIndex (4 handlers)
    zinc | [GIN-debug] PUT /es/:target/_doc/:id --> github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument (4 handlers)
    zinc | [GIN-debug] DELETE /es/:target/_doc/:id --> github.com/prabhatsharma/zinc/pkg/handlers.DeleteDocument (4 handlers)
    zinc | [GIN-debug] POST /es/:target/_doc --> github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument (4 handlers)
    zinc | [GIN-debug] PUT /es/:target/_create/:id --> github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument (4 handlers)
    zinc | [GIN-debug] POST /es/:target/_create/:id --> github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument (4 handlers)
    zinc | [GIN-debug] POST /es/:target/_update/:id --> github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument (4 handlers)
    zinc | [GIN-debug] POST /es/_bulk --> github.com/prabhatsharma/zinc/pkg/handlers.BulkHandler (4 handlers)
    zinc | [GIN-debug] POST /es/:target/_bulk --> github.com/prabhatsharma/zinc/pkg/handlers.BulkHandler (4 handlers)
    zinc | [GIN-debug] Listening and serving HTTP on :4080
    zinc | {"level":"debug","time":"2022-07-20T11:10:01Z","message":"auth: success"}
  6. 访问操作的界面
    访问 https://localhost:4080 即可看到上面的界面。

以上。

CATALOG
  1. 1. 简介
  2. 2. 部署