Jump to content

MediaWiki-Docker/Configuration recipes/OpenSearch

From mediawiki.org

OpenSearch

[edit]

See also: Documentation on how to set up CirrusSearch: MediaWiki-Docker/Extension/CirrusSearch

docker-compose.override.yml

[edit]
services:
  opensearch:
    image: docker-registry.wikimedia.org/repos/search-platform/cirrussearch-opensearch-image:v1.3.20-12
    # The official image does not yet support arm64 (Apple Silicon). To run it on macOS please see the Build the image locally section below.
    volumes:
      - osdata:/usr/share/opensearch/data
    environment:
      - discovery.type=single-node
    ports:
      - 9200:9200
      - 9300:9300
    # use 127.0.0.1:9200:9200 & 127.0.0.1:9300:9300 to prevent publicly exposing the opensearch instance
volumes:
  osdata:
    driver: local

Build the image locally (for macOS/arm64 users)

[edit]

If you run macOS/arm64 or that you need to tweak the opensearch image (new plugins to test) you might have to build the image locally. For this please use the cirrussearch-opensearch-image project:

# Clone the repo
git clone git@gitlab.wikimedia.org:repos/search-platform/cirrussearch-opensearch-image.git && cd cirrussearch-opensearch-image

# build the image under the "mylocalbuild" version tag
DOCKER_BUILDKIT=1 docker build --target production --tag docker-registry.wikimedia.org/repos/search-platform/cirrussearch-opensearch-image:mylocalbuild  -f .pipeline/blubber.yaml .

Use your own image in your docker-compose.override.yml:

services:
  opensearch:
    image: docker-registry.wikimedia.org/repos/search-platform/cirrussearch-opensearch-image:mylocalbuild
# the rest is similar to main section above
    volumes:
      - osdata:/usr/share/opensearch/data
    environment:
      - discovery.type=single-node
    ports:
      - 9200:9200
      - 9300:9300
volumes:
  osdata:
    driver: local

Operations

[edit]

Reset opensearch data

[edit]
Warning Warning: this will drop all the data you stored in this opensearch server
# Bring the deployment down
docker compose down
docker volume rm mediawiki_osdata
# it might complain that a container is using it so delete it the following command
# and retry the previous one
docker rm paste_the_ID_returned_by_the_previous_command

Troubleshooting

[edit]

service "opensearch" refers to undefined volume osdata: invalid compose project

[edit]

Perhaps you are migrating from elasticsearch, it is likely that you forgot to update the top-level volumes section of your docker-compose.override.yml file and it might still contain esdata instead of osdata.

Bind for 0.0.0.0:9200 failed: port is already allocated

[edit]

Could also possibly happen when migrating away from elasticsearch. To identify the culprit container run:

docker ps --filter "publish=9200"

and stop the the container with docker stop CONTAINER_ID.

Then try to run docker compose up -d again.

References

[edit]