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"
        }
      }
    }
}
相关推荐
苹果醋318 分钟前
数据库索引设计:在 MongoDB 中创建高效索引的策略
java·运维·spring boot·mysql·nginx
XMYX-034 分钟前
Linux 物理机如何区分 SSD 与 HDD ——以 DELL PERC H730 Mini 为例
linux·运维
yongui478342 小时前
CentOS系统如何查看当前内存容量
linux·运维·centos
xzq_java2 小时前
CentOS操作系统虚拟机安装以及连接工具下载和远程连接工具远程连接
linux·运维·centos
赵孝正2 小时前
GitLab 分支管理与 Push 问题全解析
大数据·elasticsearch·gitlab
ZLRRLZ3 小时前
【Docker】Docker安装
运维·docker·容器
逐梦吧!旅行者3 小时前
Linux之环境变量(内容由浅入深,层层递进)
linux·运维
挨踢攻城4 小时前
Linux 应急响应实操 Checklist
linux·运维·linux命令·rhce·rhca·厦门微思网络·linux 应急响应
wanhengidc4 小时前
什么是云手机?
运维·网络·安全·游戏·智能手机
optiz4 小时前
细菌基因组genome二代测序数据分析
linux·运维·服务器