• ES & Kibana 安装


    ES & Kibana

    本文基于Docker安装部署使用

    Kibana的版本和ElasticSearch的版本,以及IK分词器的版本一一对应

    Kibana 安装

    安装Kibana

    # 创建网络
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# docker network create --driver bridge --subnet 192.168.0.0/16 --gateway 192.168.0.1 es
    
    # 拉取Kibana镜像并启动
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# docker pull docker.elastic.co/kibana/kibana:7.14.0
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# docker images
    REPOSITORY                        TAG       IMAGE ID       CREATED       SIZE
    docker.elastic.co/kibana/kibana   7.14.0    58dffcbc8caa   2 years ago   1.33GB
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# docker run -d --name my-kibana --net es -p 5601:5601 docker.elastic.co/kibana/kibana:7.14.0
    3d1cd9477728d9c1197cd47ca17f4def83520079781d1241345cfee110d7dc5a
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    通过外网访问Kibana 调整防火墙开放的端口

    # 防火墙状态
    systemctl status firewalld
    # 开启防火墙
    systemctl start firewalld
    # 关闭防火墙
    systemctl stop firewalld
    
    # 开放端口
    firewall-cmd --zone=public --add-port=10002/tcp --permanent
    
    # 命令含义:
    –zone #作用域
    –add-port=80/tcp #添加端口,格式为:端口/通讯协议
    –permanent #永久生效,没有此参数重启后失效( —permanent放在前面与后面都行)
    
    # 重启防火墙
    firewall-cmd --reload
    
    # 验证修改是否生效
    firewall-cmd --zone= public --query-port=10002/tcp
    
    # 移除指定端口
    firewall-cmd --permanent --remove-port=123/tcp
    
    # 查看已开放的端口
    firewall-cmd --zone=public --list-ports
    
    • 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

    访问 iP:5601

    Kibana server is not ready yet
    # 显示当前结果则安装成功,由于没有启动Elasticsearch无法连接引起的
    
    • 1
    • 2

    kibana汉化

    # 进入 kibana 容器
    bash-4.4$ ls
    kibana.yml  node.options
    bash-4.4$ pwd           
    /usr/share/kibana/config
    
    # 指定 kibana.yml 文件中 【i18n.locale: "zh-CN"】为中文
    bash-4.4$ vi kibana.yml
    #
    # ** THIS IS AN AUTO-GENERATED FILE **
    #
    
    # Default Kibana configuration for docker target
    server.host: "0"
    server.shutdownTimeout: "5s"
    elasticsearch.hosts: [ "http://elasticsearch:9200" ]
    monitoring.ui.container.elasticsearch.enabled: true
    i18n.locale: "zh-CN"
    
    # 退出容器 重启容器即可
    bash-4.4$ exit
    exit
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# docker restart 4a7b009a7050
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    ElasticSearch 安装

    [root@iZ2zeg7mctvft5renx1qvbZ ~]# docker run -d --name elasticsearch --net es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.14.0
    26d606f02c30a3643f39c8b2795c9e7872766f25e4f4d9c150f9e6a1ad55b0ed
    
    • 1
    • 2

    访问 IP:9200

    {
      "name" : "b3b61a39c27f",
      "cluster_name" : "docker-cluster",														# 集群名称,ES一个也是一个集群
      "cluster_uuid" : "SxlZ8tYeTouS0EwWl4Vjag",
      "version" : {
        "number" : "7.14.0",
        "build_flavor" : "default",
        "build_type" : "docker",
        "build_hash" : "dd5a0a2acaa2045ff9624f3729fc8a6f40835aa1",
        "build_date" : "2021-07-29T20:49:32.864135063Z",
        "build_snapshot" : false,
        "lucene_version" : "8.9.0",																# 基于 lucene 这里有显示 lucene 的版本
        "minimum_wire_compatibility_version" : "6.8.0",
        "minimum_index_compatibility_version" : "6.0.0-beta1"
      },
      "tagline" : "You Know, for Search"														# 你知道的,为了搜索
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    ElasticSearch 插件安装

    Head 可视化工具

    [root@iZ2zeg7mctvft5renx1qvbZ ~]#docker pull mobz/elasticsearch-head:5
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# docker run -p 9100:9100 --net es --name elasticsearch-head -d mobz/elasticsearch-head:5-alpine
    7ce08be4ba166a4fbf86cdb5ca986d5b4d2411ad557fa95d2fa2c40e7760cb51
    
    • 1
    • 2
    • 3

    访问后,发现连接不上ES

    在这里插入图片描述

    修改ES的配置文件,解决跨域问题

    [root@b3b61a39c27f config]# pwd
    /usr/share/elasticsearch/config
    [root@b3b61a39c27f config]# vi elasticsearch.yml 
    cluster.name: "docker-cluster"
    network.host: 0.0.0.0
    
    http.cors.enabled: true									# 追加++
    http.cors.allow-origin: "*"								# 追加++
    
    [root@b3b61a39c27f config]# exit
    # 最后重启容器生效
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    在这里插入图片描述

    发现查不到数据

    在这里插入图片描述

    通过控制台看到这个 js 报错:http://8.140.248.231:9100/vendor.js

    # 调整 _site/vendor.js 文件
    6886行 修改 
    contentType: “application/x-www-form-urlencoded”, 
    contentType: “application/json;charset=UTF-8”, 
    7573行 修改 
    var inspectData = s.contentType === “application/x-www-form-urlencoded” && 
    var inspectData = s.contentType === “application/json;charset=UTF-8” &&
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    重启容器后正常

    在这里插入图片描述

    IK 分词器

    # github地址
    https://github.com/medcl/elasticsearch-analysis-ik/releases
    
    # 下载
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.14.0/elasticsearch-analysis-ik-7.14.0.zip
    
    # 如果是挂载的可以复制到挂载目录,这里没有使用挂载,我需要把下载文件copy到容器
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# docker cp elasticsearch-analysis-ik-7.14.0.zip b3b61a39c27f:/usr/share/elasticsearch/plugins/
    Successfully copied 4.51MB to b3b61a39c27f:/usr/share/elasticsearch/plugins/
    
    # 解压压缩包
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# unzip elasticsearch-analysis-ik-7.17.6.zip
    
    # 在ik/config 下面添加自定义的词典 【xxx.dic】
    停用词||新增词
    
    # 扩展&停用词 典
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
    <properties>
            <comment>IK Analyzer 扩展配置</comment>
            <!--用户可以在这里配置自己的扩展字典 -->
            <entry key="ext_dict"></entry>
             <!--用户可以在这里配置自己的扩展停止词字典-->
            <entry key="ext_stopwords"></entry>
            <!--用户可以在这里配置远程扩展字典 -->
            <!-- <entry key="remote_ext_dict">words_location</entry> -->
            <!--用户可以在这里配置远程扩展停止词字典-->
            <!-- <entry key="remote_ext_stopwords">words_location</entry> -->
    </properties>
    
    # 查看分词器是否加载成功
    [root@iZ2zeg7mctvft5renx1qvbZ ~]# docker exec -it b3b61a39c27f /bin/bash
    [root@b3b61a39c27f elasticsearch]# ls
    bin  config  data  jdk	lib  LICENSE.txt  logs	modules  NOTICE.txt  plugins  README.asciidoc
    [root@b3b61a39c27f elasticsearch]# cd bin/
    [root@b3b61a39c27f bin]# ls
    elasticsearch		elasticsearch-croneval	     elasticsearch-keystore  elasticsearch-saml-metadata    elasticsearch-sql-cli	      x-pack-env
    elasticsearch-certgen	elasticsearch-env	     elasticsearch-migrate   elasticsearch-service-tokens   elasticsearch-sql-cli-7.14.0.jar  x-pack-security-env
    elasticsearch-certutil	elasticsearch-env-from-file  elasticsearch-node      elasticsearch-setup-passwords  elasticsearch-syskeygen	      x-pack-watcher-env
    elasticsearch-cli	elasticsearch-geoip	     elasticsearch-plugin    elasticsearch-shard	    elasticsearch-users
    [root@b3b61a39c27f bin]# elasticsearch-plugin list
    ik
    [root@b3b61a39c27f bin]# 
    
    • 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
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44

    DBeaver连接ES

    在使用DBeaver连接后,查看表时提示【current license is non-compliant for [jdbc]】

    简单说:jdbc的方法需要付费才能使用,这时候我们只能使用试用30的方式解决,哈哈

    在这里插入图片描述

    临时解决方案

    在这里插入图片描述

    在这里插入图片描述

    在这里插入图片描述

    成功连接

    单说:jdbc的方法需要付费才能使用,这时候我们只能使用试用30的方式解决,哈哈

    在这里插入图片描述

  • 相关阅读:
    《QDebug 2022年6月》
    JavaScript /react 中new Map的用法
    程序竞赛中利用 ios_base::sync_with_stdio(false) 与 cin.tie(NULL) 加速 IO
    线程池简介及其简单实现
    行情分析——加密货币市场大盘走势(11.21)
    忍不住推荐一款作图工具draw.io
    iwebsec靶场搭建
    EFDC模型教程
    JS数据类型的判断方式
    Python学习 -- 常用数据交换格式(CSV、XML、JSON)
  • 原文地址:https://blog.csdn.net/qq_43935317/article/details/134448314