Install Elasticsearch on Debian 12
Step 1 – Install Elasticsearch
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-8.x.list
apt update
apt install -y elasticsearch
systemctl enable --now elasticsearch
Step 2 – Note the enrollment token and password
On first start, Elasticsearch prints:
The generated password for the elastic built-in superuser is: <password>
Save it immediately. You can also reset it:
/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
Step 3 – Verify
curl --cacert /etc/elasticsearch/certs/http_ca.crt \
-u elastic:YourPassword https://localhost:9200
Step 4 – Basic elasticsearch.yml settings
cluster.name: my-cluster
node.name: node-1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 127.0.0.1
http.port: 9200
# Disable security for development only (NOT recommended for production)
# xpack.security.enabled: false
Step 5 – Create an index
curl -X PUT "https://localhost:9200/my-index" \
-u elastic:YourPassword \
--cacert /etc/elasticsearch/certs/http_ca.crt \
-H 'Content-Type: application/json' \
-d '{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}'