Hero Image

Install Elasticsearch on AlmaLinux 9

Install Elasticsearch on AlmaLinux 9

Step 1 – Install Elasticsearch

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
cat > /etc/yum.repos.d/elasticsearch.repo <<EOF
[elasticsearch]
name=Elasticsearch repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF
dnf 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
        }
    }'