Install Elasticsearch on RHEL 9
Step 1 – Install
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
cat > /etc/yum.repos.d/elasticsearch.repo <<EOF
[elasticsearch]
name=Elasticsearch 8.x
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
EOF
dnf install -y elasticsearch
systemctl enable --now elasticsearch
Step 2 – Save initial root password
grep 'generated password' /var/log/elasticsearch/elasticsearch.log
# Reset if needed:
/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
cluster.name: my-cluster
node.name: node-1
network.host: 127.0.0.1
http.port: 9200
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}}'