Elasticsearch¶
This section is about how to perform a specific task. If you want to understand how a certain component works, please see Reference
The rest of the page assumes you installed using the ansible playbooks from wire-server-deploy
For any command below, first ssh into the server:
For more information, see the elasticsearch documentation
How to rolling-restart an elasticsearch cluster¶
For maintenance you may need to restart the cluster.
On each server one by one:
- check your cluster is healthy (see above)
- stop shard allocation:
You should expect some output like this:
- Stop the elasticsearch daemon process:
systemctl stop elasticsearch - do any operation you need, if any
- Start the elasticsearch daemon process:
systemctl start elasticsearch - re-enable shard allocation:
You should expect some output like this from the above command:
- Wait for your cluster to be healthy again.
- Do the same on the next server.
How to manually look into what is stored in elasticsearch¶
See also the elasticsearch sections in Investigative tasks (e.g. searching for users as server admin).
Check the health of an elasticsearch node¶
To check the health of an elasticsearch node, run the following command:
You should see output looking like this:
Here, the green denotes good node health, and the 3 3 denotes 3 running nodes.
Check cluster health¶
This is the command to check the health of the entire cluster:
List cluster nodes¶
This is the command to list the nodes in the cluster:
How to recreate ES index¶
If you are facing issues with an existing index due to conflicting mappings or seeing this error when updating wire-server:
Using existing charts, existing index and ES native API with a multi-step approach.¶
This is the safest approach if you don't want any downtime of your user search result in the teams.
Charts for wire-server will be needed, specifically, subchart elasticsearch-index.
Create a new index with the new mappings by configuring a values.yaml file like so:
Find your current elasticsearch-index-create job and delete it:
Then helm install the elasticsearch-index charts with the previously configured values.yaml:
This will create a new index ('new-index-name') in ES cluster. To verify, log onto your ES cluster machine and run:
Or exec into a brig pod, and curl it with your Elasticsearch service name from the brig pod.
Depending on your ES setup, you might need to use https and provide credentials. In the output you should see your new index there.
Next, configure wire-server values file to use both the new index and the old one (until we populate the new with old index data).
Apply it:
Now use native reindex ES API in your ES cluster like so:
Wait for the result. Now switch the main/additional indexes in wire-server.
Apply it:
Now log onto Team Settings and check your member list if it is correct. If it is, you can stop using additionalWriteIndex and delete the old one.
### Re-creating the Elasticsearch index using existing charts with simple steps¶
Downtime warning: User search will return empty results between Step 1 and Step 2 (index deletion until migrate-data completes). With ~1000 users this window is very short (seconds to a minute). Inform your users of the brief search downtime.
Step 1: Delete the corrupted indices
Using wire-utility sts pod for operations
wire-utility-0 is a StatefulSet pod created by the wire-utility chart to facilitate operational tasks. For setup and usage details, see Wire Utility Tool.
Step 2: Redeploy elasticsearch-index chart
This will:
Create a fresh directory index with the correct mapping. Refill it with all users from Cassandra via migrate-data
Watch create + update-mapping (pre-hook)¶
kubectl logs -f $(kubectl get pods | grep elasticsearch-index-create | awk '{print $1}')
Watch migrate-data (post-hook)¶
kubectl logs -f $(kubectl get pods | grep brig-index-migrate-data | awk '{print $1}')
Step 3: Verify
From the brig pod
Both directory and wire_brig_migrations index should be available¶
curl http://<elasticsearch-host>:9200/_cat/indices
Doc count should match your user count¶
curl http://<elasticsearch-host>:9200/directory/_count
From wire-utility-0
Just run es indices or es all command which will provide all the Elasticsearch node related info.
Using modified Helm charts (and building it from scratch)¶
The following process uses charts for elasticsearch-migrate (which is a modified elasticsearch-index subchart of wire-server). If you are building an index from scratch, you can ignore "dual" writing with additionalWriteIndex.
Create a values.yaml to configure it:
This will create a new index called directory_new after it has been run. The name of a new index can be of your choosing, directory_new was selected as the previous default one was directory.
Run it with helm (mind the following command assumes some paths which might not be applicable in your installation):
Configure brig to use both the standard and the newly created index (usually in values/wire-server/values.yaml):
Apply it (same assumptions regarding paths as our standard deployment process):
To backfill the new index, edit values.yaml for elasticsearch-migrate charts and set runReindex to true:
Apply it again:
This should start a kubernetes Job named elasticsearch-migrate-data that might take several hours to run, depending on the amount of data it needs to re-create. Galley pods might get OOMKilled during this, if that is the case, increase galley memory for requests and limits (we found in Wire Cloud prod 8Gi is sufficient):
Reapply:
And then restart elasticsearch-migrate.
After the reindexing is complete, configure wire-server to read from the new index:
After verifying all is okay on the client side (check your Team Settings UI, if you can see your team user list). You can delete the old index in your ES cluster with:
curl -X DELETE “localhost:9200/directory”
Aliasing¶
To alias an index, use the Native Elasticsearch API in your ES cluster like so:
Troubleshooting¶
Description: ES nodes ran out of disk space and error message says: "blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"
Solution:
- Connect to the node:
- Clean up disk (e.g.
apt autoremoveon all nodes), then restart machines and/or the elasticsearch process
As always make sure you check the health of the process. before and after the reboot.
- Get the elastichsearch cluster out of read-only mode, run:
- Trigger reindexing: From a kubernetes machine, in one terminal:
And in a second terminal trigger the reindex: