Skip to content

Commit d23ad4f

Browse files
committed
feat: add opensearch docker-compose file
1 parent d52265f commit d23ad4f

File tree

5 files changed

+85
-10
lines changed

5 files changed

+85
-10
lines changed

.env

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ ELASTICSEARCH_PASSWORD=test123
55

66
# OpenSearch connection settings
77
OPENSEARCH_HOSTS=https://localhost:9200
8-
OPENSEARCH_USERNAME=elastic
9-
OPENSEARCH_PASSWORD=test123
8+
OPENSEARCH_USERNAME=admin
9+
OPENSEARCH_PASSWORD=admin

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ RUN hatch build && pip install dist/*.whl
1919

2020
# Set environment variables required for the MCP server
2121
# These can be overridden at runtime with docker run --env
22-
ENV ELASTIC_HOST="https://localhost:9200"
23-
ENV ELASTIC_USERNAME="elastic"
24-
ENV ELASTIC_PASSWORD="test123"
22+
ENV ELASTICSEARCH_HOST="https://localhost:9200"
23+
ENV ELASTICSEARCH_USERNAME="elastic"
24+
ENV ELASTICSEARCH_PASSWORD="test123"
2525

2626
# Expose the port the server is running on (if applicable)
2727
EXPOSE 8000

README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,21 @@ https://github.com/user-attachments/assets/f7409e31-fac4-4321-9c94-b0ff2ea7ff15
3030
- `get_cluster_stats`: Get statistical information about the cluster.
3131

3232

33-
## Start Elasticsearch Cluster
33+
## Start Elasticsearch/OpenSearch Cluster
3434

35-
Start the Elasticsearch cluster using Docker Compose:
35+
Start the Elasticsearch/OpenSearch cluster using Docker Compose:
3636

3737
```bash
38-
docker-compose up -d
38+
# For Elasticsearch
39+
docker-compose -f setup/elasticsearch-docker-compose.yml up -d
40+
41+
# For OpenSearch
42+
docker-compose -f setup/opensearch-docker-compose.yml up -d
3943
```
4044

41-
This will start a 3-node Elasticsearch cluster and Kibana. Default Elasticsearch username `elastic`, password `test123`.
45+
The default Elasticsearch username is `elastic` and password is `test123`. The default OpenSearch username is `admin` and password is `admin`.
4246

43-
You can access Kibana from http://localhost:5601.
47+
You can access Kibana/OpenSearch Dashboards from http://localhost:5601.
4448

4549
## Usage with Claude Desktop
4650

File renamed without changes.

setup/opensearch-docker-compose.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
services:
2+
opensearch-node1: # This is also the hostname of the container within the Docker network (i.e. https://opensearch-node1/)
3+
image: opensearchproject/opensearch:2.11.0
4+
container_name: opensearch-node1
5+
environment:
6+
- cluster.name=opensearch-cluster # Name the cluster
7+
- node.name=opensearch-node1 # Name the node that will run in this container
8+
- discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
9+
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligibile to serve as cluster manager
10+
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
11+
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
12+
- cluster.routing.allocation.disk.watermark.low=2gb
13+
- cluster.routing.allocation.disk.watermark.high=1gb
14+
- cluster.routing.allocation.disk.watermark.flood_stage=512mb
15+
ulimits:
16+
memlock:
17+
soft: -1 # Set memlock to unlimited (no soft or hard limit)
18+
hard: -1
19+
nofile:
20+
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
21+
hard: 65536
22+
volumes:
23+
- opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
24+
ports:
25+
- 9200:9200 # REST API
26+
- 9600:9600 # Performance Analyzer
27+
networks:
28+
- opensearch-net # All of the containers will join the same Docker bridge network
29+
opensearch-node2:
30+
image: opensearchproject/opensearch:2.11.0 # This should be the same image used for opensearch-node1 to avoid issues
31+
container_name: opensearch-node2
32+
environment:
33+
- cluster.name=opensearch-cluster
34+
- node.name=opensearch-node2
35+
- discovery.seed_hosts=opensearch-node1,opensearch-node2
36+
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2
37+
- bootstrap.memory_lock=true
38+
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
39+
- cluster.routing.allocation.disk.watermark.low=2gb
40+
- cluster.routing.allocation.disk.watermark.high=1gb
41+
- cluster.routing.allocation.disk.watermark.flood_stage=512mb
42+
ulimits:
43+
memlock:
44+
soft: -1
45+
hard: -1
46+
nofile:
47+
soft: 65536
48+
hard: 65536
49+
volumes:
50+
- opensearch-data2:/usr/share/opensearch/data
51+
networks:
52+
- opensearch-net
53+
opensearch-dashboards:
54+
image: opensearchproject/opensearch-dashboards:2.11.0 # Make sure the version of opensearch-dashboards matches the version of opensearch installed on other nodes
55+
container_name: opensearch-dashboards
56+
ports:
57+
- 5601:5601 # Map host port 5601 to container port 5601
58+
expose:
59+
- "5601" # Expose port 5601 for web access to OpenSearch Dashboards
60+
environment:
61+
OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' # Define the OpenSearch nodes that OpenSearch Dashboards will query
62+
networks:
63+
- opensearch-net
64+
65+
volumes:
66+
opensearch-data1:
67+
opensearch-data2:
68+
69+
networks:
70+
opensearch-net:
71+

0 commit comments

Comments
 (0)