在linux下用docker部署es和kibana
1、在某个文件夹下创建docker-compose.yml文件,并把以下内容copy进去
version: '3'
services:elasticsearch:image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0container_name: elasticsearchenvironment:- discovery.type=single-node #单节点- ES_JAVA_OPTS=-Xms512m -Xmx512m # 设置ES内存大小为512MB,我的服务器内存不大,所以设置512mports:- "9200:9200"networks:- elastickibana:image: docker.elastic.co/kibana/kibana:7.6.0container_name: kibanaports:- "5601:5601"networks:- elasticnetworks:elastic:driver: bridge
2、然后用docker-compose up 启动服务
3、在启动过程中,发现es没有启动起来 于是如下命令查看日志,最后发现是内存不够,所以杀掉了一些其他不必要的进程释放内存
docker logs elasticsearch
4、查看可用内存命令
free -h
5、重新用后台启动
docker-compose up -d
6、启动成功后,用如下命令检查,看到es和kibana都是running状态
docker-compose ps
7、用命令行来访问es是否正常启动起来,windows环境下打开dos窗口,执行以下命令,或者直接在linux系统里面执行如下命令,看到如下返回内容即是启动成功
curl -X GET ip:9200
访问es响应的内容
{"name" : "e088ac539fa7","cluster_name" : "docker-cluster","cluster_uuid" : "AwOxpCU0QViXu1QEp5g3ew","version" : {"number" : "7.6.0","build_flavor" : "default","build_type" : "docker","build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3","build_date" : "2020-02-06T00:09:00.449973Z","build_snapshot" : false,"lucene_version" : "8.4.0","minimum_wire_compatibility_version" : "6.8.0","minimum_index_compatibility_version" : "6.0.0-beta1"},"tagline" : "You Know, for Search"
}
8、在浏览器端输入 http://ip:5601/app/kibana#/home 访问es