By: Neeraj in ELKStack Tutorials on 2019年05月06日 [フレーム]
You can install Elastic Search in a docker environment. For this to work, you need to make sure that you have the docker installed in your environment (linux/windows/mac etc). Once the docker is installed, you also need to check whether docker-compose is installed. For Windows environment, docker-compose is usually bundled with your docker installation. But for linux, you need to explicitly install docker-compose. You can install docker-compose using the command. Use pip to install.
pip install docker-compose
After you have installed docker-compose, create a file named docker-compose.yml with the below code:
version: '2.2' services: es01: image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1 container_name: es01 environment: - node.name=es01 - discovery.seed_hosts=es02 - cluster.initial_master_nodes=es01,es02 - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - esdata01:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - esnet es02: image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1 container_name: es02 environment: - node.name=es02 - discovery.seed_hosts=es01 - cluster.initial_master_nodes=es01,es02 - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - esdata02:/usr/share/elasticsearch/data networks: - esnet volumes: esdata01: driver: local esdata02: driver: local networks: esnet:
The above yml defines two elastic search nodes running in port 9200 in a single cluster. Now you can install elastic search in your docker environment, using the below command.
docker-compose up
You can check whether the elastic search nodes are properly installed and running by connecting to your port 9200. You can do so using curl command.
curl http://127.0.0.1:9200/_cat/health 1472225929 15:38:49 docker-cluster green 2 2 4 2 0 0 0 0 - 100.0%
You can shut down the dockers running elastic search nodes by issuing the command:
docker-compose down
If you are getting this error: ERROR: for +es01 Cannot start service es01: driver failed programming external connectivity on endpoint es01
it means another instance of elastic search is already using the port 9200. So find that instance using "ps aux| grep elastic" and kill it. After that run docker-compose up again to start the nodes.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in ELKStack )
Latest Articles (in ELKStack)
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate