How to install elasticsearch and kibana on linux

Modify the maximum number of memory mapped areas that a process may have
echo vm.max_map_count=262144 >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
Pull the elasticsearch image, here I am using version 7.12.1
docker pull elasticsearch:7.12.1
Create data mount directory
mkdir -p  /home/test/data
Change directory permissions
chmod -R 777 /home/test/data
chown -R 777 /home/test/data

Start the elasticsearch container
docker run -d --name elasticsearch -d -p 9200:9200 -p 9300:9300 \
-e ES_JAVA_OPTS="-Xms5g -Xmx5g" \
-e "discovery.type=single-node" \
-e "" \
-v /home/test/data:/usr/share/elasticsearch/data \
Check whether it is opened successfully
curl -v
Enter the elasticsearch container
docker exec -it elasticsearch /bin/bash 
Generate password
./bin/elasticsearch-setup-passwords auto
Save the generated password
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,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 [y/N]y

Changed password for user apm_system
PASSWORD apm_system = 2AGTCdYJ09dFWyChNZCh

Changed password for user kibana_system
PASSWORD kibana_system = OMPxbqsHO5WtqMSZyh0w

Changed password for user kibana
PASSWORD kibana = OMPxbqsHO5WtqMSZyh0w

Changed password for user logstash_system
PASSWORD logstash_system = 6vgfHhr5dyhU8gaNtWfq

Changed password for user beats_system
PASSWORD beats_system = whDklJ9RW5ohWmnAatIV

Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = jsQoRPds4AD1xqumhWzd

Changed password for user elastic
PASSWORD elastic = A2MiWXsztwqZPRu3HqZ3
Create kibana.yml file and edit content
echo ' kibana "0"
elasticsearch.hosts: [ "" ]
elasticsearch.username: kibana
elasticsearch.password: OMPxbqsHO5WtqMSZyh0w true
xpack.monitoring.ui.container.elasticsearch.enabled: false
' >> /home/test/kibana.yml
Start the kibana container
docker run -d --name kibana -p 5601:5601 -m 2G --restart=always -v /home/test/kibana.yml:/usr/share/kibana/config/kibana.yml kibana:7.12.1
Was this helpful?

I hope to help every developer quickly find the commands they need. Of course, you can also add your own commonly used commands for easy searching.