Menu Home

Setting up Ubuntu 26.04 + ElasticSearch 9 for Mastodon 4.6

1 Prepare system

echo "vm.max_map_count=262144" | sudo tee /etc/sysctl.d/99-elasticsearch.conf
sudo sysctl --system

2 Install package

sudo apt-get update
sudo apt-get install -y apt-transport-https gnupg wget # apt-transport-https is usually already present on 26.04

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg

gpg --show-keys --with-fingerprint /usr/share/keyrings/elasticsearch-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/9.x/apt stable main" \
| sudo tee /etc/apt/sources.list.d/elastic-9.x.list

sudo apt-get update
sudo apt-get install elasticsearch

3 Notice output

The generated password for the elastic built-in superuser is : xxxxxxxxxxxxxx

If this node should join an existing cluster, you can reconfigure this with
'/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token '
after creating an enrollment token on your existing cluster.

You can complete the following actions at any time:

Reset the password of the elastic built-in superuser with
'/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'.

Generate an enrollment token for Kibana instances with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'.

Generate an enrollment token for Elasticsearch nodes with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'.

4 Edit /etc/Elasticsearch/jvm.options.d/heap.options

Add about 50-75% of the memory to allow something for the OS/Cache.

-Xms5g
-Xmx5g

5 Edit /etc/elasticsearch/elasticsearch.yml

Update or Add the following values

# Important - Comment out the cluster.initial_master_nodes line
# or the sever won't boot in conflict with the single-node discovery.type

cluster.name: es-mastodon
node.name: node-1
bootstrap.memory_lock: true

network.host: <IP>
http.port 9200
discovery.type: single-node

http.host: <IP>
transport.host: <IP>

xpack.license.self_generated.type: basic
xpack.ml.enabled: false
xpack.graph.enabled: false
xpack.watcher.enabled: false
xpack.profiling.enabled: false

5 sudo systemctl edit elasticsearch

Add the following

[Service]
LimitNOFILE=65535
LimitMEMLOCK=infinity
LimitNPROC=4096

6 Start the service using systemctl

sudo systemctl daemon-reload
sudo systemctl enable --now elasticsearch.service

7 Test the connecting including the self signed cert

curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://<IP>:9200

Categories: Uncategorised

shlee

Leave a Reply

Your email address will not be published. Required fields are marked *

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)