• Docker安装ES7.14和Kibana7.14(无账号密码)


    一、Docker安装ES7.14.0

    1、下载镜像

    docker pull elasticsearch:7.14.0

    2、docker安装7.14.0

    mkdir -p /usr/local/elasticsearch/config

    chmod 777 -R /usr/local/elasticsearch/

    echo "cluster.name: "docker-cluster" >> /usr/local/elasticsearch/config/elasticesearch.yml

    echo "network.host: 0.0.0.0" >> /usr/local/elasticsearch/config/elasticesearch.yml

    echo "discovery.zen.minimum_master_nodes: 1" >> /usr/local/elasticsearch/config/elasticesearch.yml

    echo "discovery.type: single-node" >> /usr/local/elasticsearch/config/elasticesearch.yml

    docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx128m" -v /usr/local/elasticsearch/config/elasticesearch.yml:/usr/local/elasticsearch/config/elasticesearch.yml  -d elasticsearch:7.14.0

    • -e "cluster.name=es-docker-cluster":设置集群名称
    • -e "http.host=0.0.0.0":监听的地址,可以外网访问
    • -e "ES_JAVA_OPTS=-Xms64m -Xmx128m":内存大小
    • -e "discovery.type=single-node":非集群模式
    • -v es-data:/usr/share/elasticsearch/data:目录映射,绑定elasticsearch的数据目录
    • -v es-logs:/usr/share/elasticsearch/logs:目录映射,绑定elasticsearch的日志目录
    • -v es-plugins:/usr/share/elasticsearch/plugins:目录映射,绑定elasticsearch的插件目录
    • -p 9200:9200:端口映射配置

    3、访问

    http://10.1.1.197:9200

    二、Docker安装kibana:7.14.0

    1、下载镜像

    版本:kibana:7.14.0 需要和ES版本对应
    Kibana 是一个免费且开放的用户界面,能够让您对 Elasticsearch 数据进行可视化。

    docker pull kibana:7.14.0

    2、安装kibana

    docker run -d --name kibana714  -e ELASTICSEARCH_HOSTS="http://10.1.1.74:9200" -p 5601:5601 kibana:7.14.0

    • -e ELASTICSEARCH_HOSTS ES地址:注意不要使用127.0.0.1

    访问UI界面:http://10.1.1.197:5601/

    三、Docker-compose安装ES和kibana

    1、创建配置文件目录和文件

    #创建目录

    mkdir -p /home/es-kibana/config

    mkdir -p /home/es-kibana/data

    mkdir -p /home/es-kibana/plugins

    #给挂载目录授权

    chmod 777 -R  /home/es-kibana/config

    chmod 777  /home/es-kibana/es-data/data

    chmod 777  /home/es-kibana/es-data/logs

    chmod 777  /home/es-kibana/es-data/plugins

    1.1、配置文件elasticesearch.yml

    cluster.name: "docker-cluster"
    network.host: 0.0.0.0

    discovery.zen.minimum_master_nodes: 1
    discovery.type: single-node

    1.2、配置文件jvm.options

    1. ## JVM configuration
    2. ################################################################
    3. ## IMPORTANT: JVM heap size
    4. ################################################################
    5. ##
    6. ## You should always set the min and max JVM heap
    7. ## size to the same value. For example, to set
    8. ## the heap to 4 GB, set:
    9. ##
    10. ## -Xms4g
    11. ## -Xmx4g
    12. ##
    13. ## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
    14. ## for more information
    15. ##
    16. ################################################################
    17. # Xms represents the initial size of total heap space
    18. # Xmx represents the maximum size of total heap space
    19. -Xms1g
    20. -Xmx1g
    21. -XX:+IgnoreUnrecognizedVMOptions
    22. ################################################################
    23. ## Expert settings
    24. ################################################################
    25. ##
    26. ## All settings below this section are considered
    27. ## expert settings. Don't tamper with them unless
    28. ## you understand what you are doing
    29. ##
    30. ################################################################
    31. ## GC configuration
    32. -XX:+UseConcMarkSweepGC
    33. -XX:CMSInitiatingOccupancyFraction=75
    34. -XX:+UseCMSInitiatingOccupancyOnly
    35. ## G1GC Configuration
    36. # NOTE: G1GC is only supported on JDK version 10 or later.
    37. # To use G1GC uncomment the lines below.
    38. # 10-:-XX:-UseConcMarkSweepGC
    39. # 10-:-XX:-UseCMSInitiatingOccupancyOnly
    40. # 10-:-XX:+UseG1GC
    41. # 10-:-XX:InitiatingHeapOccupancyPercent=75
    42. ## optimizations
    43. # pre-touch memory pages used by the JVM during initialization
    44. -XX:+AlwaysPreTouch
    45. ## basic
    46. # explicitly set the stack size
    47. -Xss1m
    48. # set to headless, just in case
    49. -Djava.awt.headless=true
    50. # ensure UTF-8 encoding by default (e.g. filenames)
    51. -Dfile.encoding=GBK
    52. # use our provided JNA always versus the system one
    53. -Djna.nosys=true
    54. # turn off a JDK optimization that throws away stack traces for common
    55. # exceptions because stack traces are important for debugging
    56. -XX:-OmitStackTraceInFastThrow
    57. # flags to configure Netty
    58. -Dio.netty.noUnsafe=true
    59. -Dio.netty.noKeySetOptimization=true
    60. -Dio.netty.recycler.maxCapacityPerThread=0
    61. # log4j 2
    62. -Dlog4j.shutdownHookEnabled=false
    63. -Dlog4j2.disable.jmx=true
    64. -Djava.io.tmpdir=${ES_TMPDIR}
    65. ## heap dumps
    66. # generate a heap dump when an allocation from the Java heap fails
    67. # heap dumps are created in the working directory of the JVM
    68. -XX:+HeapDumpOnOutOfMemoryError
    69. # specify an alternative path for heap dumps; ensure the directory exists and
    70. # has sufficient space
    71. -XX:HeapDumpPath=data
    72. # specify an alternative path for JVM fatal error logs
    73. -XX:ErrorFile=logs/hs_err_pid%p.log
    74. ## JDK 8 GC logging
    75. 8:-XX:+PrintGCDetails
    76. 8:-XX:+PrintGCDateStamps
    77. 8:-XX:+PrintTenuringDistribution
    78. 8:-XX:+PrintGCApplicationStoppedTime
    79. 8:-Xloggc:logs/gc.log
    80. 8:-XX:+UseGCLogFileRotation
    81. 8:-XX:NumberOfGCLogFiles=32
    82. 8:-XX:GCLogFileSize=64m
    83. # JDK 9+ GC logging
    84. 9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
    85. # due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
    86. # time/date parsing will break in an incompatible way for some date patterns and locals
    87. 9-:-Djava.locale.providers=COMPAT
    88. # temporary workaround for C2 bug with JDK 10 on hardware with AVX-512
    89. 10-:-XX:UseAVX=2

    主要是这3个配置项

    2、#创建docker-compose.yml文件(重要)

    1. version: '3'
    2. services:
    3. elasticsearch:
    4. image: elasticsearch:7.14.0
    5. container_name: es7-14
    6. restart: unless-stopped
    7. volumes:
    8. - ./es-data/data:/usr/share/elasticsearch/data
    9. - ./es-data/logs:/usr/share/elasticsearch/logs
    10. # 挂载分词器的目录
    11. #- ./es-data/plugins:/usr/share/elasticsearch/plugins
    12. - ./config/jvm.options:/usr/share/elasticsearch/config/jvm.options
    13. - ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    14. ports:
    15. - "9100:9100"
    16. - "9200:9200"
    17. networks:
    18. - es
    19. kibana:
    20. image: kibana:7.14.0
    21. container_name: kibana7-14
    22. ports:
    23. - "5601:5601"
    24. environment:
    25. - "ELASTICSEARCH_HOSTS=http://10.1.1.197:9200"
    26. depends_on:
    27. - elasticsearch
    28. networks:
    29. - es
    30. networks:
    31. es:
    32. driver: bridge

    3、#自我检测自己写的有没有语法上的问题

    docker-compose config -q

    4、#启动和停止

    docker-compose up -d

    docker-compose down

    重启

    docker-compose restart 容器id

    docker-compose安装时遇到问题:

    docker logs 容器id

    1、docker启动es报错java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes...

    问题:docker以挂载配置文件启动elasticsearch的时候会报如下错误:java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes...

    看错误我们会以为是es容器里的/usr/share/elasticsearch/data/nodes文件夹目录没有读写权限,其实给提示误导了,实际是挂载的目录没有读写权限。比如我们宿主主机的配置目录为:/home/es-kibana/es-data/data,那么我们需要赋予它读写权限:

    解决:授权挂载目录的权限

    chmod 777 /home/es-kibana/es-data/data

    2、docker启动es出现此异常Unrecognized VM option 'UseConcMarkSweepGC'

    解决办法:在jvm. options文件中加上-XX:+IgnoreUnrecognizedVMOptions

  • 相关阅读:
    左值和右值
    选择篇(067)-下面代码的输出是什么?
    react处理跨域
    基于 Qt控制开发板 LED和C语言控制LED渐变亮度效果
    RK平台使用MP4视频做开机动画以及卡顿问题
    Linux 命令系统
    【高阶数据结构】图详解第二篇:图的遍历(广度优先+深度优先)
    算法 | 分支限界法和回溯法的搜索策略&动态规划特性&贪心算法特性
    学生信息管理系统
    Stable Diffusion 3震撼发布模型与Sora同架构
  • 原文地址:https://blog.csdn.net/fen_fen/article/details/133887081