installation
Because we need to use docker to install, we have to install:
- docker: Depending on the operating system, in accordance with the requirements of the installation docker. You can go to the site to install https://docs.docker.com/
- docker-compose. This can go to the site to install https://docs.docker.com/compose/install/#install-using-pip
With docker to install Elasticsearch
Download docker image
Docker's just get Elasticsearch issue docker pull command Elastic Docker registry as simple.
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.3.2
The above is an example to demonstrate the Elasticsearch 7.3.2. In actual use, you can replace it with your own favorite version.
Development or test environment
Elasticsearch run from the command line. Use the following command to quickly start Elasticsearch for development or testing:
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.3.2
Note that the single-node discovery, discovery allows to bypass the check bootstrap checks the development of a single node in the cluster.
Production Environment
vm.max_map_count
Kernel settings need to be set to at least 262144 can be used for the production environment.
vm.max_map_count
Setting should be /etc/sysctl.conf
permanent settings:
$ grep vm.max_map_count /etc/sysctl.conf
vm.max_map_count=262144
To apply this setting on a real-time system, do the following:
sysctl -w vm.max_map_count = 262144
With docker to install Kibana
Download docker image
docker pull docker.elastic.co/kibana/kibana:7.3.2
Development or test environment
You can use the following commands to quickly start Kibana and connected to the local Elasticsearch vessel development and testing:
docker run --link YOUR_ELASTICSEARCH_CONTAINER_NAME_OR_ID:elasticsearch -p 5601:5601 {docker-repo}:{version}
For our case, we first follow the steps above to Elasticsearch of docker up and running, and then execute the following command:
docker ps
The results are shown as follows:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3839f34c1d2d docker.elastic.co/elasticsearch/elasticsearch:7.3.2 "/usr/local/bin/dock…" 7 minutes ago Up 7 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp admiring_matsumoto
The above information is already good docker docker information Elasticsearch of installation. We then execute the following command:
docker run --link 3839f34c1d2d:elasticsearch -p 5601:5601 docker.elastic.co/kibana/kibana:7.3.2
So that our Kibana docker on the up.
Use docker-compose to start Elasticsearch and Kibana
In this step, we assume that we have a good Elasticsearch download and Kibana the docker image. If you have not done so, you can execute the following command to download:
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.3.2
docker pull docker.elastic.co/kibana/kibana:7.3.2
Then down, let's create a directory called docker and creates a file called docker-compose.yml in this directory. It reads as follows:
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.3.2
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.3.2
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
kibana:
image: docker.elastic.co/kibana/kibana:7.3.2
container_name: kibana
ports: ['5601:5601']
networks: ['esnet']
environment:
- SERVER_NAME=kibana.localhost
- ELASTICSEARCH_HOSTS=http://es01:9200
- I18N_LOCALE=zh-CN
- ELASTICSEARCH_USERNAME=elastic
- ELASTICSEARCH_PASSWORD=mypasword
depends_on: ['es01']
volumes:
esdata01:
driver: local
esdata02:
driver: local
networks:
esnet:
In this configuration, we create a node of two Elasticsearch: es01 and es02. Es01 node listens localhost: 9200, and es02 through dialogue and Docker network es01. We also created another kibana of docker. We can configure the parameters it needs in the environment.
Once we created this docker-compose.yml file, we in the current directory, enter the following command:
docker-compose up
or:
docker-compose up -d
The -d option indicates that here in detached mode, running in the background container.
We can finally see our Kibana be launched in a browser like
As we set before, it runs up Locale setting is Chinese. We can also see two nodes simultaneously Elasticsearch be activated:
Once docker start, we can execute commands docker commands, such as
docker exec es01 ls /usr/share/elasticsearch
We can carry on into the docker installation by following command:
docker exec -it es01 /bin/bash
$ docker exec -it es01 /bin/bash
[root@ec4d19f59a7d elasticsearch]# ls
LICENSE.txt README.textile config jdk logs plugins
NOTICE.txt bin data lib modules
[root@ec4d19f59a7d elasticsearch]#
es01 here is the name of our Elasticsearch instance.
We can also configure Kibana by the way. We can create another file in the directory named kibana.yml docker-compose.yml of:
kibana.yml
#
# ** THIS IS AN AUTO-GENERATED FILE **
#
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://elasticsearch:9200" ]
i18n.locale: "zh-CN"
xpack.monitoring.ui.container.elasticsearch.enabled: true
Here we do some simple settings, such as we configured the locale for the Chinese. We can modify our docker-compose.yml file as follows:
docker-compose.yml
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.3.2
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.3.2
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
kibana:
image: docker.elastic.co/kibana/kibana:7.3.2
container_name: kibana
networks: ['esnet']
ports: ['5601:5601']
environment:
- ELASTICSEARCH_HOSTS=http://es01:9200
volumes:
- ./kibana.yml:/usr/share/kibana/config/kibana.yml
volumes:
esdata01:
driver: local
esdata02:
driver: local
networks:
esnet:
Here we come to the local kibana.yml file bind mount to the image among our docker in by volumes in kibana in. In this way it instead docker in the file in order to use kibana.yml file /usr/share/kibana/config/kibana.yml we set locally.
When docker all containers are up and running, we can see by following command:
$ docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------
es01 /usr/local/bin/docker-entr ... Up 0.0.0.0:9200->9200/tcp,
9300/tcp
es02 /usr/local/bin/docker-entr ... Up 9200/tcp, 9300/tcp
kibana /usr/local/bin/dumb-init - ... Up 0.0.0.0:5601->5601/tcp
It shows all the port usage.
We can docker instances are stopped by the following way:
docker-compose down
We quickly deploy our Elasticsearch cluster.
reference:
【1】https://www.elastic.co/guide/en/kibana/7.3/docker.html
【2】https://www.elastic.co/guide/en/elasticsearch/reference/7.3/install-elasticsearch.html