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"
        }
      }
    }
}
相关推荐
舞动CPU4 小时前
linux c/c++最高效的计时方法
linux·运维·服务器
皮锤打乌龟5 小时前
(干货)Jenkins使用kubernetes插件连接k8s的认证方式
运维·kubernetes·jenkins
钰@5 小时前
小程序开发者工具的network选项卡中有某域名的接口请求,但是在charles中抓不到该接口
运维·服务器·小程序
wanhengwangluo5 小时前
云服务器和物理服务器的区别有哪些?
运维·服务器
秦jh_6 小时前
【Linux】多线程(概念,控制)
linux·运维·前端
yaosheng_VALVE6 小时前
稀硫酸介质中 V 型球阀的材质选择与选型要点-耀圣
运维·spring cloud·自动化·intellij-idea·材质·1024程序员节
SafePloy安策7 小时前
ES信息防泄漏:策略与实践
大数据·elasticsearch·开源
涔溪7 小时前
Ecmascript(ES)标准
前端·elasticsearch·ecmascript
看山还是山,看水还是。7 小时前
Redis 配置
运维·数据库·redis·安全·缓存·测试覆盖率
扣得君7 小时前
C++20 Coroutine Echo Server
运维·服务器·c++20