In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article Xiaobian introduces in detail for you "docker how to install Elasticsearch cluster and set password", the content is detailed, the steps are clear, and the details are handled properly. I hope this "docker how to install Elasticsearch cluster and set password" article can help you solve your doubts.
Some basic configurations
Es needs to modify some parameters of linux.
Set up vm.max_map_count=262144
Sudo vim / etc/sysctl.confvm.max_map_count=262144
Do not restart, directly take effect of the current command
Sysctl-w vm.max_map_count=262144
The data and logs directories of es need to authorize 1000 users. We assume that three powerful es clusters are installed, and the corresponding data storage files are created first.
The user id of mkdir-p es01/datamkdir-p es01/logsmkdir-p es02/datamkdir-p es02/logsmkdir-p es03/datamkdir-p es03/logs## es is 1000, which is temporarily granted to all. Sudo chmod 777 es*-r
About versions and docker images
There are several types of licenses for elasticsearch, of which open source and basic are free, but security features are not integrated into es's basic license until after 6.8.
The corresponding docker image of basic is
Docker pull docker.elastic.co/elasticsearch/elasticsearch:7.6.2
At the same time, dockerhub synchronization is elasticsearch. Let's just pull the elasticsearch:7.6.2.
Start
The installation files are all placed in github: https://github.com/ryan-miao/docker-china-source/tree/master/docker-elasticsearch
First, create a docker-compose.yml
Version: '2.2'services: es01: image: elasticsearch:7.6.2 container_name: es01 environment:-node.name=es01-cluster.name=es-docker-cluster-discovery.seed_hosts=es02,es03-cluster.initial_master_nodes=es01,es02 Es03-bootstrap.memory_lock=true-"es_java_opts=-xms512m-xmx512m" ulimits: memlock: soft:-1 hard:-1 volumes: -. / es01/data:/usr/share/elasticsearch/data -. / es01/logs:/usr/share/elasticsearch/logs -. / elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -. / elastic-certificates.p12:/usr/share/elasticsearch/config/elastic -certificates.p12 ports:-9200 certificates.p12 ports 9200 networks:-elastic es02: image: elasticsearch:7.6.2 container_name: es02 environment:-node.name=es02-cluster.name=es-docker-cluster-discovery.seed_hosts=es01 Es03-cluster.initial_master_nodes=es01,es02 Es03-bootstrap.memory_lock=true-"es_java_opts=-xms512m-xmx512m" ulimits: memlock: soft:-1 hard:-1 volumes: -. / es02/data:/usr/share/elasticsearch/data -. / es02/logs:/usr/share/elasticsearch/logs -. / elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -. / elastic-certificates.p12:/usr/share/elasticsearch/config/elastic -certificates.p12 ports:-9201 image 9200 networks:-elastic es03: image: elasticsearch:7.6.2 container_name: es03 environment:-node.name=es03-cluster.name=es-docker-cluster-discovery.seed_hosts=es01 Es02-cluster.initial_master_nodes=es01,es02 Es03-bootstrap.memory_lock=true-"es_java_opts=-xms512m-xmx512m" ulimits: memlock: soft:-1 hard:-1 volumes: -. / es03/data:/usr/share/elasticsearch/data -. / es03/logs:/usr/share/elasticsearch/logs -. / elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -. / elastic-certificates.p12:/usr/share/elasticsearch/config/elastic -certificates.p12 ports:-9202 networks 9200 networks:-elastic kib01: depends_on:-es01 image: kibana:7.6.2 container_name: kib01 ports:-5601 networks: elasticsearch_url: http://es01:9200 elasticsearch_hosts: http://es01:9200 volumes: -. / kibana.yml:/usr/share/kibana/config/kibana.yml networks:-elasticnetworks: elastic: driver: bridge
About elasticsearch.yml
The contents are as follows
Network.host: 0.0.0.0xpack.security.enabled: truexpack.security.transport.ssl.enabled: truexpack.security.transport.ssl.keystore.type: pkcs12xpack.security.transport.ssl.verification_mode: certificatexpack.security.transport.ssl.keystore.path: elastic-certificates.p12xpack.security.transport.ssl.truststore.path: elastic-certificates.p12xpack.security.transport.ssl.truststore.type: pkcs12xpack.security.audit.enabled: true
Network.host setting allows other ip access, unbinding ip
Xpack.security is a security-related configuration, in which the certificate of ssl needs to be generated by itself
About Certificate elastic-certificates.p12
Es provides a tool for generating certificates, elasticsearch-certutil, which we can generate in an docker instance, then copy it, and then use it uniformly later.
First run the es instance
Sudo docker run-dit-- name=es elasticsearch:7.6.2 / bin/bash
Enter inside the instance
Sudo docker exec-it es / bin/bash
Generate ca: elastic-stack-ca.p12
[root@25dee1848942 elasticsearch] #. / bin/elasticsearch-certutil cathis tool assists you in the generation of x.509 certificates and certificatesigning requests for use with ssl/tls in the elastic stack.the 'ca' mode generates a new' certificate authority'this will create a new x.509 certificate and private key that can be usedto sign certificate when running in 'cert' mode.use the' ca-dn' option if you wish to configure the 'distinguished name'of the certificate authorityby default the' ca' mode produces a single pkcs#12 output file which holds: * The ca certificate * the ca's private keyif you elect to generate pem format certificates (the-pem option) Then the output willbe a zip file containing individual files for the ca certificate and private keyplease enter the desired output file [elastic-stack-ca.p12]: enter password for elastic-stack-ca.p12:
Regenerated into cert: elastic-certificates.p12
[root@25dee1848942 elasticsearch] #. / bin/elasticsearch-certutil cert-- ca elastic-stack-ca.p12this tool assists you in the generation of x.509 certificates and certificatesigning requests for use with ssl/tls in the elastic stack.the 'cert' mode generates x.509 certificate and private keys.
This generation elastic-certificates.p12 is exactly what we need to use.
Copy out the certificate, and ctrl+d exits inside the container
Sudo docker cp es:/usr/share/elasticsearch/elastic-certificates.p12. # close this container sudo docker kill essudo docker rm es
In this way, the certificate was obtained.
Generate password
First of all, we need to start the es cluster and go inside to generate the password.
Sudo docker-compose up
And then enter one of them.
Sudo docker exec-it es01 / bin/bash
Generate the password with auto, and set it with interactive by yourself.
[root@cfeeab4bb0eb elasticsearch] #. / bin/elasticsearch-setup-passwords-hsets the passwords for reserved userscommands-auto-uses randomly generated passwordsinteractive-uses passwords entered by a usernon-option arguments:command option description-e configure a setting-h,-- help show help-s,-- silent show minimal output-v -- verbose show verbose output [root@cfeeab4bb0eb elasticsearch] #. / bin/elasticsearch-setup-passwords autoinitiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system Remote_monitoring_user.the passwords will be randomly generated and printed to the console.please confirm that you would like to continue [YBO] ychanged password for user apm_systempassword apm_system = yxvzet9b2jedujyp66wschanged password for user kibanapassword kibana = 8nnthbj0n02idatghiduchanged password for user logstash_systempassword logstash_system = 9nidge7ksv8sqidsk8djchanged password for user beats_systempassword beats_system = qeuvaf1vealpjhfeuojjchanged password for user remote_monitoring_userpassword remote_monitoring_user = dtzcrckvtzsinrn3tw3dchanged password for user elasticpassword elastic = q5f2qnfujqyvzpiz57mz
Use password
The browser needs to enter an account number to access localhost:9200/9201/9202
Just enter the corresponding elastic/password
Browsers access localhost:5601
Forget the password.
If you forget your password after generation, you can go to the machine to modify it.
Access to the es machine
Sudo docker exec-it es01 / bin/bash
Create a temporary superuser ryanmiao
. / bin/elasticsearch-users useradd ryan-r superuserenter new password: error: invalid password...passwords must be at least [6] characters long [root@cfeeab4bb0eb elasticsearch] #. / bin/elasticsearch-users useradd ryan-r superuserenter new password: retype new password:
Use this user to change the elastic password:
Curl-xput-u ryan:ryan123 http://localhost:9200/_xpack/security/user/elastic/_password-h "content-type: application/json"-d'{"password": "q5f2qnfujqyvzpiz57mz"} 'has been introduced to this article "how to install Elasticsearch clusters and set passwords in docker". If you want to master the knowledge points of this article, you still need to practice and use it before you can understand it. If you want to know more about it, Welcome to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.