• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Elasticsearch7.10.0安装和配置

武飞扬头像
Luke
帮助3196

Elasticsearch7.10.0安装和配置

  • 系统环境 : centos7、 jdk8 、

  • elasticsearch-7.10.0 安装和配置(单机)

  • kibana -7.10.0 安装和配置

  • ik分词器-7.10.0 安装和配置

  • 远程字典热加载配置

 需要开启的端口
 firewall-cmd --zone=public --add-port=9200/tcp --permanent # elasticsearch 
 firewall-cmd --zone=public --add-port=5601/tcp --permanent # kibana
 firewall-cmd --reload      # 重启防火墙
 firewall-cmd --query-port=6379/tcp # 查询端口是否开放

elasticsearch-7.10.0 安装和配置(单机)

2020-11-27 elasticsearch 目前最新版 7.10.0 。下载地址 https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-linux-x86_64.tar.gz

参考  https://blog.csdn.net/gwd1154978352/article/details/82666891
首先保证linux有jdk环境

  1. 将下载的文件放在服务器如下目录:/usr/elasticsearch/

  2. 解压 tar -zxvf elasticsearch-7.10.0-linux-x86_64.tar.gz

  3. 创建日志文件夹
    mkdir -p /data/logs/elasticsearch
    mkdir -p /data/elasticsearch/{data,work,plugins,scripts}

  4. 创建一个非root用户  ElasticSearch有个比较特殊的地方就是不能用root权限来运行,所以我们这边需要新建一个用户以及赋予对应权限。
    4.1. 新建一个elsearch用户组 groupadd elsearch
    4.2. 新建用户elsearch,并让他加入elsearch组useradd elsearch -g elsearch -p elsearch
    4.3.赋予新用户对elasticsearch-7.10.0和/data/*的操作权限
    chown -R elsearch:elsearch elasticsearch-7.10.0
    chown -R elsearch:elsearch /data/*
    4.4.切换用户 su elsearch

  5. 编辑配置文件 /usr/elasticsearch/elasticsearch-7.10.0/config/elasticsearch.yml


network.host: 0.0.0.0  //监听访问地址为任意网段,也可以按自己的要求要设置对应的网段path.data: /data/elasticsearch/datapath.logs: /data/logs/elasticsearch

#如果没有对应的插件,那么下面两个就不用配置,否则会报错
#path.plugins: /data/elasticsearch/plugins
#path.scripts: /data/elasticsearch/scripts

http.port: 9200
  1. 启动 /usr/elasticsearch/elasticsearch-6.4.0/bin/
    sh elasticsearch 或者用sh elasticsearch -d来后台启动

  2. 验证是否启动  ps aux|grep elsearch 或者 curl http:://localhost:9200

kibana -7.10.0 安装和配置

下载地址 https://artifacts.elastic.co/downloads/kibana/kibana-7.10.0-linux-x86_64.tar.gz


解压
tar -zxvf kibana-7.10.0-linux-x86_64.tar.gz

修改配置
修改/config/kibaba.yml文件(不修改的话外网无法通过ip访问)

server.host: "0.0.0.0" # 将默认的server.host: "localhost" 改成server.host: "0.0.0.0",以供外网访问。
i18n.locale: "zh-CN"  # 中文 

修改原有的内容,或者将原有的内容全部注释,添加这两个配置项。当然如果你的elasticsearch 在另外一台机器的话,需要单独配置。

# 启动 进入bin目录
sh kibana (或者使用nohup ./kibana & 进行后台启动)

# 浏览器中查看
http://ip地址:5601/

ik分词器-7.10.0 安装和配置

下载地址  https://github.com/medcl/elasticsearch-analysis-ik/archive/v7.10.0.zip  或者直接去github看
参考 https://blog.csdn.net/gwd1154978352/article/details/82728902 可以看怎么测试


#将压缩包挪到目录下 
/usr/elasticsearch/elasticsearch-7.10.0/plugins/ik
解压
unzip -O elasticsearch-analysis-ik-7.10.0.zip

然后重启elasticsearch。 就可以了。

ik分词器-7.10.0  远程字典热加载配置

参考github说明。

官方示例给出的示例是使用个一个文件,放到web服务器下。我为了方便,采用java写了一个接口,提供远程字典。


    /**
     * head请求 获取请求头.查看数据有没有变化
     * head请求,只请求head信息。不返回数据
     *
     * @param response res
     */
    @RequestMapping(method = RequestMethod.HEAD, value = "/ik_remote_ext_dict.dic")
    public void ikRemoteExtDictHeda(HttpServletResponse response) {
       
        String lastModified = "自定义实现";
        response.setHeader(" Last-Modified", lastModified);
        String text = "字典最后更新时间"   lastModified;
        log.info(text);
        ServletUtil.write(response, text, "application/json;charset=UTF-8");
    }


    /**
     * ik分词器远程字典
     * 返回全部的口语。
     *
     * @param response response
     */
    @GetMapping(value = "/ik_remote_ext_dict.dic")
    public void ikRemoteExtDict(HttpServletResponse response) {
      String dict="字典内容";
        ServletUtil.write(response, dict, "application/json;charset=UTF-8");
    }


这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/taneeje
系列文章
更多 icon
同类精品
更多 icon
继续加载