首先先安装一个docker
参考链接
https://www.jianshu.com/p/2b3924d71acd
docker安装完成后选择一个ElasticSearch的版本进行安装
我选择的是6.6.0,记住这个版本,kibana也要是相同的版本,不然有可能会有坑..还有就是ik分词的版本也要是这个..
安装基本过程:
- 1.获取镜像
docker pull ElasticSearch:6.60
- 2.创建并启动容器
docker run --name elasticsearch -d -p 9200:9200 -p 9300:9300 -e discovery.type=single-node" elasticsearch:6.6.0
- 3.下载ElasticSearch配置文件
docker cp elasticsearch:/usr/share/elasticsearch/config/elasticsearch.yml elasticsearch.yml
- 4.修改ElasticSearch的配置文件
- 修改后情况
cluster.name: elasticsearch
node.name: es-150
network.bind_host: 0.0.0.0
network.publish_host: 192.168.1.150
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
- 5.上传ElasticSearch配置文件
docker cp elasticsearch.yml elasticsearch:/usr/share/elasticsearch/config/elasticsearch.yml
- 6.重启ElasticSearch
docker restart elasticsearch
- 7.测试访问ElasticSearch
http://server-ip:9200
访问显示结果为
image.png
ElasticSearch安装完成后安装kibana
安装基本过程
- 1.获取镜像
docker pull kibana:版本要和ElasticSearch一样否则会坑
- 2.启动容器
docker run --name kibana -p 5601:5601 -d kibana:6.6.0
- 3.下载容器配置
docker cp kibana:/usr/share/kibana/config/kibana.yml kibana.yml
为了修改容器配置后方便上传
- 4.修改容器配置
server.name: kibana
server.host: "0.0.0.0"
#elasticsearch.hosts: [ "http://192.168.1.150:9200"]
elasticsearch.hosts: [ "http://172.17.0.4:9200"]
logging.dest : /usr/share/kibana/log/kibana.log
xpack.monitoring.ui.container.elasticsearch.enabled: false
其中http://172.17.0.4:9200是通过查看docker容器中ElasticSearch的id来获得的具体查看id方式
docker inspect -f='{{.Name}} {{.NetworkSettings.IPAddress}} {{.HostConfig.PortBindings}}' $(docker ps -aq)
- 5.上传容器配置
docker cp kibana.yml kibana:/usr/share/kibana/config/kibana.yml
- 6.重启kibana
docker restare kibana
- 7.访问kibana
http://server-ip:5601
显示结果为
image.png
安装过程中可能出现的问题
kibana访问显示内容为:
kibana server is not ready yet
查看后台日志显示内容为
{"type":"log","@timestamp":"2020-06-23T05:15:08Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
{"type":"log","@timestamp":"2020-06-23T05:15:12Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://192.168.1.150:9200/"}
处理方案:
在上面已经做了说明,这个是因为同一台服务器下,容器中相互访问问题导致的,获取到docker中对应ElasticSearch的容器ip维护到kibana的配置中即可
网友评论