I am trying to install me custom REST plugin on my dockerized OpenSearch...
I am using ubuntu 20
this is my docker-compose.yml file
version: '3'
services:
opensearch-node1:
image: opensearchproject/opensearch:1.0.1
container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node1
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_master_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data
ports:
- 9200:9200
- 9600:9600 # required for Performance Analyzer
networks:
- opensearch-net
opensearch-node2:
image: opensearchproject/opensearch:1.0.1
container_name: opensearch-node2
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node2
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_master_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- opensearch-data2:/usr/share/opensearch/data
networks:
- opensearch-net
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:1.0.1
container_name: opensearch-dashboards
ports:
- 5601:5601
expose:
- "5601"
environment:
OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' # must be a string with no spaces when specified as an environment variable
networks:
- opensearch-net
volumes:
opensearch-data1:
opensearch-data2:
networks:
opensearch-net:
running docker-compose up start the service and it runs fine
but I have no idea how to continue from here...
this is the plugin layout (which I cloned from here )
The docker image is all ready to run, without your plugin of course:/ Therefore, you need to create a docker image with your plugin installed.
Open a new directory outside the plugin project with your packaged plugin in it. This package is called something like ->my-plugin.zip located in your plugin project under build/distributions/my-plugin.zip. If it is not there then you should assemble the plugin like so:
./gradlew assemble -Dopensearch.version=1.0.0 -Dbuild.snapshot=false
Add the following Dockerfile to the new directory:
FROM opensearchproject/opensearch:1.0.0
ADD ./my-plugin.zip /usr/
RUN /usr/share/opensearch/bin/opensearch-plugin install file:///usr/my-plugin.zip
The ADD will add the local package to the container so it can be used by the next command.
The script after RUN will install the plugin into OpenSearch.
Build the docker image, adding a tag will make life easier later:
docker build --tag=opensearch-with-my-plugin .
Now you have an opensearch image built with your plugin installed on it!
Fix the YAML file you posted originally so that it uses the correct image. This means replacing the opensearchproject/opensearch:1.0.1 with the tag you gave the image you had built - opensearch-with-my-plugin. And add it to the directory with the Dockerfile (not as you have it, in the project).
I took the liberty to change the dashboards version to 1.0.0, as i'm not sure if it will work with 1.0.0 of the image.
In any case, this should be a solid start!
version: '3'
services:
opensearch-node1:
image: opensearch-with-my-plugin
container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node1
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_master_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data
ports:
- 9200:9200
- 9600:9600 # required for Performance Analyzer
networks:
- opensearch-net
opensearch-node2:
image: opensearch-with-my-plugin
container_name: opensearch-node2
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node2
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_master_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- opensearch-data2:/usr/share/opensearch/data
networks:
- opensearch-net
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:1.0.0
container_name: opensearch-dashboards
ports:
- 5601:5601
expose:
- "5601"
environment:
OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' # must be a string with no spaces when specified as an environment variable
networks:
- opensearch-net
volumes:
opensearch-data1:
opensearch-data2:
networks:
opensearch-net:
Verify by running this in the terminal and see that your plugin is installed:)
curl -XGET https://localhost:9200/_cat/plugins -u 'admin:admin' --insecure
Also, I created a GitHub template for plugins with more info. The repo you cloned is the one I created for my blog post on writing plugins, so it is a REST plugin, but not the most generic one.
If you are still having issues getting this running please let me know in the comments, I'm glad to help.
EDIT: file locations edited a bit.
Related
Is it possible to deploy opensearch using docker-compose immediately with a set of data from a file?
The official documentation says that you need to deploy the docker image and then send a bulk request with data there. But nowhere does it say how to raise opensearch immediately with pre-prepared data.
Now I deploy opensearch like this
version: '3'
services:
opensearch-node1:
image: opensearchproject/opensearch:latest
container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node1
- discovery.type=single-node
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms1024m -Xmx1024m"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data
ports:
- 9200:9200
- 9600:9600
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:latest
container_name: opensearch-dashboards
ports:
- 5601:5601
expose:
- "5601"
environment:
OPENSEARCH_HOSTS: '["https://opensearch-node1:9200"]'
volumes:
opensearch-data1:
hi i want to connect to Elasticsearch inside my app which is defined as "cog-app" service in docker-compose.yml along with ditsro elasticsearch and kibana
i am not able to connect to elasticsearch when i run docker file, can you please tell me how i can connect elasticsearch service to app service
i have defined elasticsearch in cog-app service, and im getting connection failure with elasticsearch
version: "3"
services:
cog-app:
image: app:2.0
build:
context: .
dockerfile: ./Dockerfile
stdin_open: true
tty: true
ports:
- "7111:7111"
environment:
- LANG=C.UTF-8
- LC_ALL=C.UTF-8
- CONTAINER_NAME=app
volumes:
- /home/developer/app:/app
odfe-node1:
image: amazon/opendistro-for-elasticsearch:1.13.2
container_name: odfe-node1
environment:
- cluster.name=odfe-cluster
- node.name=odfe-node1
- discovery.seed_hosts=odfe-node1,odfe-node2
- cluster.initial_master_nodes=odfe-node1,odfe-node2
- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
- "ES_JAVA_OPTS=-Xms2g -Xmx2g" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536 # maximum number of open files for the Elasticsearch user, set to at least 65536 on modern systems
hard: 65536
volumes:
- odfe-data1:/usr/share/elasticsearch/data
ports:
- 9200:9200
- 9600:9600 # required for Performance Analyzer
odfe-node2:
image: amazon/opendistro-for-elasticsearch:1.13.2
container_name: odfe-node2
environment:
- cluster.name=odfe-cluster
- node.name=odfe-node2
- discovery.seed_hosts=odfe-node1,odfe-node2
- cluster.initial_master_nodes=odfe-node1,odfe-node2
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- odfe-data2:/usr/share/elasticsearch/data
networks:
- odfe-net
kibana:
image: amazon/opendistro-for-elasticsearch-kibana:1.13.2
container_name: odfe-kibana
ports:
- 5601:5601
expose:
- "5601"
environment:
ELASTICSEARCH_URL: https://odfe-node1:9200
ELASTICSEARCH_HOSTS: https://odfe-node1:9200
networks:
- odfe-net
volumes:
odfe-data1:
odfe-data2:
networks:
odfe-net:
please tell me how two services can communicate with each other
As the elasticsearch service is running in another container, localhost is not valid. You should use odfe-node1:9200 as the url
I have a small app with a python backend where I'm streaming and classifying tweets in real-time.
I use elasticsearch to collect classified tweets and Kibana to make visualizations based on es data.
In my frontend, I just use kibana visualizations.
For the moment, I'm trying to run my application in a multi-node swarm as a services stack but I'm having problems with my compose file.
I tried to start with elastisearch and to use this info https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html but didn't help, and I didn'd succed to deploy my docker-compose file even with just elasticsearch serivce.
This is my yml file:
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
ulimits:
memlock:
soft: -1
hard: -1
ports:
- '9200:9200'
kibana:
image: docker.elastic.co/kibana/kibana:7.6.2
ports:
- '5601:5601'
Below is the docker-compose file which works for a single node in a development environment, which have disabled security and has discovery.type=single-node param to make sure elasticsearch production bootstrap checks are not kicked in.
version: '2.2'
services:
#Elasticsearch Docker Images: https://www.docker.elastic.co/
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: elasticsearch
environment:
- xpack.security.enabled=false
- discovery.type=single-node
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
cap_add:
- IPC_LOCK
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
ports:
- 9200:9200
- 9300:9300
volumes:
elasticsearch-data:
driver: local
networks:
elastic:
external: true
I am currently trying to deploy a 3-node Elasticsearch cluster on a single EC2 instance (i.e. using ONE instance only) using a docker-compose file. The problem is I could not get the 3 nodes to communicate with each other to form the cluster.
On my Windows 10 machine, I used the official Elasticsearch:6.4.3 image while for AWS EC2, I am using a custom Elasticsearch:6.4.3 image with ec2-discovery plugin installed where I build using the "docker build -t mdasri/eswithec2disc ." command. Refer to dockerfile below.
The dockerfile:
FROM docker.elastic.co/elasticsearch/elasticsearch:6.4.3
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch discovery-ec2
I was successful in setting up the 3-node Elasticsearch cluster locally using docker-compose on my Windows 10 machine. In my docker-compose file, I have 3 different Elasticsearch services to make up the 3-nodes: es01, es02, es03. I was hoping to use the same docker-compose file to set up the cluster on AWS EC2 instance but I was hit with error.
I am using the "ecs-cli compose -f docker-compose.yml up" command to deploy to AWS EC2. The status of the ecs-cli compose was: "Started container...".
So to check the cluster status, I typed x.x.x.x/_cluster/health?pretty, but was hit with this error:
{
"error" : {
"root_cause" : [
{
"type" : "master_not_discovered_exception",
"reason" : null
}
],
"type" : "master_not_discovered_exception",
"reason" : null
},
"status" : 503
}
When I assess each of the docker container logs in the EC2 instance after I ssh in, this is the error I face in ALL 3 containers:
[2019-06-24T06:19:43,880][WARN ][o.e.d.z.UnicastZenPing ] [es01]
failed to resolve host [es02]
This is my docker-compose file for the respective AWS EC2 service:
version: '2'
services:
es01:
image: mdasri/eswithec2disc
container_name: es01
cpu_shares: 100
mem_limit: 2147482548
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
ports:
- "9200:9200"
- "9300:9300"
environment:
- "cluster.name=aws-cluster"
- "node.name=es01"
- "node.master=true"
- "node.data=false"
- "discovery.zen.hosts_provider=ec2"
- "discovery.zen.ping.unicast.hosts=es01, es02"
- "discovery.zen.minimum_master_nodes=2"
- "ES_JAVA_OPTS= -Xmx256m -Xms256m"
- "bootstrap.memory_lock=true"
volumes:
- /usr/share/elasticsearch/data
networks:
- esnet
es02:
image: mdasri/eswithec2disc
container_name: es02
cpu_shares: 100
mem_limit: 2147482548
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
environment:
- "cluster.name=aws-cluster"
- "node.name=es02"
- "node.master=true"
- "node.data=false"
- "discovery.zen.hosts_provider=ec2"
- "discovery.zen.ping.unicast.hosts=es01, es02"
- "ES_JAVA_OPTS= -Xmx256m -Xms256m"
- "bootstrap.memory_lock=true"
volumes:
- /usr/share/elasticsearch/data
networks:
- esnet
es03:
image: mdasri/eswithec2disc
container_name: es03
cpu_shares: 100
mem_limit: 2147482548
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
environment:
- "cluster.name=aws-cluster"
- "node.name=es03"
- "node.master=false"
- "node.data=true"
- "discovery.zen.hosts_provider=ec2"
- "discovery.zen.ping.unicast.hosts=es01,es02"
- "ES_JAVA_OPTS= -Xmx256m -Xms256m"
- "bootstrap.memory_lock=true"
volumes:
- /usr/share/elasticsearch/data
networks:
- esnet
networks:
esnet:
Please help me as I've been stuck on this problem for the past 1-2 weeks.
P.S: Please let me know what other information do you guys need. Thanks!
you need to configure links in your docker-compose to be able to resolvable:
from docker-compose Docs:
Link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name.
web:
links:
- db
- db:database
- redis
and see the comment also from #Mishi.Srivastava
I have currently tried to use docker-compose to spin up multiple elasticsearch containers but these are all deployed on my local machine. What would be the process for deploying multiple containers to several different machines using Docker?
I know that docker swarm exists but I am not sure how to utilize it along with docker compose so that I spin up multiple elasticsearch nodes that are located in the difference virtual machines that I have spun up.
So far I know that in the elasticsearch.yml config file I need to specify the virtual machine addresses with
discovery.zen.ping.unicast.hosts: ["vm_ip1:9200", "vm_ip2:9200"] but I am not sure how to enforce this change onto the docker containers that are created. To spin up the containers I used the sample docker-compose.yml file that is shown in the elasticsearch docs
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
container_name: elasticsearch
environment:
- cluster.name=elasticsearch
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- esnet
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
container_name: elasticsearch2
environment:
- cluster.name=elasticsearchr
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
- "index.number_of_shards: 2"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata2:/usr/share/elasticsearch/data
networks:
Please let me know if any more details are needed, thanks!