• Docker部署es+kibana -- 操作笔记


    docker 部署es+kibana

    安装elasticsearch

    进入docker 官方镜像仓库https://hub.docker.com/,如果第一次使用,需要注册账号

    注册登录后,在页面搜索elasticsearch

    搜索到后,进入页面向下查找


    #es暴露的端口很多
    #es也十分耗内存
    #es的数据一般需要放置到安全目录!使用挂载
    
    #创建网络,可以使用已经创建的网络
    $ docker network create --driver bridge --subnet 192.168.0.0/24 --gateway 192.168.0.1 mynet
    #运行es,单节点运行
    [root@node1 docker]# docker run -d --name elasticsearch --net mynet -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.10.1
    #使用查看es状态
    [root@node1 docker]# docker ps
    CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                                            NAMES
    443c4814689a        elasticsearch:7.10.1   "/tini -- /usr/loc..."   4 minutes ago       Up 4 minutes        0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch
    [root@node1 docker]# curl localhost:9200
    {
      "name" : "443c4814689a",
      "cluster_name" : "docker-cluster",
      "cluster_uuid" : "nxo7C1UsRbyd33lTYQNtFQ",
      "version" : {
        "number" : "7.10.1",
        "build_flavor" : "default",
        "build_type" : "docker",
        "build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa",
        "build_date" : "2020-12-05T01:00:33.671820Z",
        "build_snapshot" : false,
        "lucene_version" : "8.7.0",
        "minimum_wire_compatibility_version" : "6.8.0",
        "minimum_index_compatibility_version" : "6.0.0-beta1"
      },
      "tagline" : "You Know, for Search"
    }
    

    es运行后,发现系统变得比较卡,显然是es耗掉了绝大部分内存

    #查看系统消耗,占内存65%
    [root@node1 docker]# docker stats
    #停止es
    [root@node1 docker]# docker stats
    #增加内存限制,修改配置文件 -e 环境配置修改
    [root@node1 docker]# docker run -d --name elasticsearch --net mynet -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx256m" elasticsearch:7.10.1
    #查看系统消耗,占内存50%
    [root@node1 docker]# docker stats 6f4f729a4ddd
    [root@node1 docker]# curl localhost:9200
    {
      "name" : "6f4f729a4ddd",
      "cluster_name" : "docker-cluster",
      "cluster_uuid" : "f1CoqkN5SRCOjZIMh_PJ6g",
      "version" : {
        "number" : "7.10.1",
        "build_flavor" : "default",
        "build_type" : "docker",
        "build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa",
        "build_date" : "2020-12-05T01:00:33.671820Z",
        "build_snapshot" : false,
        "lucene_version" : "8.7.0",
        "minimum_wire_compatibility_version" : "6.8.0",
        "minimum_index_compatibility_version" : "6.0.0-beta1"
      },
      "tagline" : "You Know, for Search"
    }
    [root@node1 docker]# 
    
    

    es安装完成,现在安装kibana

    安装kibana

    到docker官方查看kibana

    #docker 运行kibana,同es使用相同版本7.10.1,同样使用mynet网络
    [root@node1 docker]# docker run -d --name kibana --net mynet -p 5601:5601 kibana:7.10.1
    Unable to find image 'kibana:7.10.1' locally
    7.10.1: Pulling from library/kibana
    3c72a8ed6814: Already exists 
    55b131d31acb: Pull complete 
    ... 
    5ffe1970589a: Pull complete 
    Digest: sha256:ee434144dd3f8d0f18bff10eda9918cd8e70f8deaaf6a75adf5d0df7f8094169
    Status: Downloaded newer image for kibana:7.10.1
    8d90e2e3fe43df43a7f936361a88cd2026c756381e71a80b37fea173ab9aba6a
    #浏览器访问http://192.168.1.10:5601, 可以查看到kibana 页面,可以访问成功
    

    配置kibanan连接es

    #停止正在运行的es和kibana
    [root@node1 docker]# docker rm -f $(docker ps -aq)
    8d90e2e3fe43
    6f4f729a4ddd
    #新建es数据和配置目录
    [root@node1 docker]#mkdir -p /mydata/elasticsearch/{config,data}
    //新建并写入配置文件
    [root@node1 docker]#echo "http.host: 0.0.0.0" >> /mydata/elasticsearch/config/elasticsearch.yml
    [root@node1 elasticsearch]# ls
    config  data
    [root@node1 elasticsearch]# cat config/elasticsearch.yml 
    http.host: 0.0.0.0
    #配置完成,执行命令启动elasticsearch并挂载配置文件到虚拟机目录:
    #-p 9200:9200 -p 9300:9300 开发映射端口
    #-e ES_JAVA_OPTS="-Xms64m -Xmx128m"设置es占用内存 最大128m 以后在设置
    #-v 挂载目录并启动容器
    #-e "discovery.type=single-node" 设置单击模式运行
    #-e ES_JAVA_OPTS="-Xms64m -Xmx128m" 设置es占用内存 最大128m 以后在设置
    [root@node1 docker]# docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx128m" -v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /mydata/elasticsearch/data:/usr/share/elasticsearch/data -v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:7.10.1
    315d59f62177833f85ebc9d37c527a34142b4b2c70cc9b5abccb6bd98e1a1370
    # 访问测试
    [root@node1 docker]# curl localhost:9200
    {
      "name" : "cc245a7cb465",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "cKAWvALsRuakx7l9ePbyDA",
      "version" : {
        "number" : "7.10.1",
        "build_flavor" : "default",
        "build_type" : "docker",
        "build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa",
        "build_date" : "2020-12-05T01:00:33.671820Z",
        "build_snapshot" : false,
        "lucene_version" : "8.7.0",
        "minimum_wire_compatibility_version" : "6.8.0",
        "minimum_index_compatibility_version" : "6.0.0-beta1"
      },
      "tagline" : "You Know, for Search"
    }
    
    #配置kibana 连接到es
    [root@node1 docker]#docker run -d --name kibana --net mynet -e ELASTICSEARCH_HOSTS=http://192.168.1.10:9200 -p 5601:5601 kibana:7.10.1
    
    ***************用努力照亮现实的梦!***********************
  • 相关阅读:
    Unity之图片压缩,批量设置,导入自动设置
    Unity之可寻址资源之初始化,下载
    最优二叉树
    独立任务最优调度问题
    石子合并问题
    linux初学笔记
    码农
    用循环打印出多种三角形
    人机猜拳(这是最近的一个总结)
    期末总结
  • 原文地址:https://www.cnblogs.com/orange2016/p/14352886.html
Copyright © 2020-2023  润新知