• docker-compose安装ES7.14和Kibana7.14(有账号密码)


    一、docker-compose安装ES7.14.0和kibana7.14.0

    1、下载镜像

    1.1、ES镜像

    docker pull elasticsearch:7.14.0

    1.2、kibana镜像

    docker pull kibana:7.14.0

    2、docker-compose安装ES和kibana

    2.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

    2.2、ES配置文件

    1、elasticesearch.yml

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

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

    xpack.security.enabled: true     #此项开启账号密码

    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.3、kibana配置

    i18n.locale: zh-CN

    server.host: "0.0.0.0"

    server.shutdownTimeout: "5s"

    elasticsearch.hosts: [ "http://10.1.1.197:9200" ]

    monitoring.ui.container.elasticsearch.enabled: true

    elasticsearch.username: "elastic"
    elasticsearch.password: "xxx"

    2.4、#创建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. volumes:
    25. - ./config/kibana.yml:/usr/share/kibana/config/kibana.yml
    26. depends_on:
    27. - elasticsearch
    28. networks:
    29. - es
    30. networks:
    31. es:
    32. driver: bridge

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

    docker-compose config -q

    2.6、#启动和停止

    docker-compose up -d

    docker-compose down

    重启

    docker-compose restart 容器id

    3、ES设置账号密码

    3.1、检查elasticesearch.yml已配置

    xpack.security.enabled: true     #此项开启账号密码(只配置这项就可以了)

    3.2、设置用户名和密码的命令

    参考:【精选】ElasticSearch7.14设置内置用户,使用用户名密码访问

    这里需要为4个用户分别设置密码,elastic, kibana, logstash_system,beats_system。(interactive 手动设置, auto 自动生成密码 )

    bin/elasticsearch-setup-passwords interactive

    #进入es容器操作步骤

    $docker exec -it es7-14 /bin/bash

    #手动创建密码
    $bin/elasticsearch-setup-passwords interactive

    3、访问ES和kibana

    3.1、访问ES

    http://10.1.1.197:9200/

    需要输入账号密码即可登录

    3.2、访问kibana

    http://10.1.1.197:5601/

    备注1:设置密码的配置文件,配置这个就可以了

    xpack.security.enabled: true     #此项开启账号密码(只配置这项就可以了)

    然后进入容器里配置密码bin/elasticsearch-setup-passwords interactive就可用了。

    备注2:docker-compose down后可能密码没了,所以最好是docker stop 容器id和docker start 容器id

  • 相关阅读:
    【计算机网络】网络层——IP协议
    mPEG-Cholesterol mPEG-CLS 甲氧基-聚乙二醇-胆固醇科研专用
    互联网摸鱼日报(2022-11-02)
    MySQL数据表的“增删查改“
    如何进行销售漏斗管理?
    Scala运算符及流程控制
    在团购网上空手赚钱项目,你敢做就敢赚!
    栈和队列的初始化,插入,删除,销毁。
    人工智能 – Artificial intelligence | AI,是什么?
    【第八章 IDEA中常用快捷键】
  • 原文地址:https://blog.csdn.net/fen_fen/article/details/134012716