CentOS7下使用docker安装ElasticSearch
2021/7/20 7:07:38
本文主要是介绍CentOS7下使用docker安装ElasticSearch,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
使用docker-compose安装ES及其图形化界面kibana。
docker-compose文件
version: "3" services: elasticsearch6.8.11: image: daocloud.io/library/elasticsearch:6.8.11 restart: always container_name: es6.8.11 ports: - 9200:9200 kibana: # 版本号与ES要一致 image: daocloud.io/library/kibana:6.8.11 restart: always container_name: kibana6.8.11 volumes: - ./kibna/config:/usr/share/kibana/config ports: - 5601:5601 environment: - elasticsearch_url=http://192.168.1.4:9200 depends_on: - elasticsearch6.8.11
kibana配置文件
在配置kibana的数据卷下新建文件kibana.yml
,添加如下内容:
# # ** THIS IS AN AUTO-GENERATED FILE ** # # Default Kibana configuration for docker target server.name: kibana server.host: "0" # 指定ES的地址 elasticsearch.hosts: [ "http://192.168.1.4:9200" ] xpack.monitoring.ui.container.elasticsearch.enabled: true
下载安装
将文件置于/opt/docker/es
下,执行如下安装命令
docker-compose up -d
错误解决
ES启动失败
报错信息
若使用docker-compose logs -f
监测到如下日志,表示ES启动失败。
es6.8.11 | [2021-07-17T18:57:38,590][INFO ][o.e.b.BootstrapChecks ] [EfARraA] bound or publishing to a non-loopback address, enforcing bootstrap checks es6.8.11 | ERROR: [1] bootstrap checks failed es6.8.11 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] es6.8.11 | [2021-07-17T18:57:38,598][INFO ][o.e.n.Node ] [EfARraA] stopping ... es6.8.11 | [2021-07-17T18:57:38,631][INFO ][o.e.n.Node ] [EfARraA] stopped es6.8.11 | [2021-07-17T18:57:38,631][INFO ][o.e.n.Node ] [EfARraA] closing ... es6.8.11 | [2021-07-17T18:57:38,642][INFO ][o.e.n.Node ] [EfARraA] closed
错误原因
系统分配的虚拟内存太小
解决方式
编辑
/etc/sysctl.conf
,追加以下内容:vm.max_map_count=262144保存后,执行:
sysctl -p
kibana启动失败(未配置数据卷时可能出现)
报错信息
使用docker-compose
查看日志,发现kibana报错如下:
kibana6.8.11 | {"type":"log","@timestamp":"2021-07-17T19:26:46Z","tags":["license","warning","xpack"],"pid":1,"message":"License information from the X-Pack plugin could not be obtained from Elasticsearch for the [data] cluster. Error: No Living connections"} kibana6.8.11 | {"type":"log","@timestamp":"2021-07-17T19:26:47Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"} kibana6.8.11 | {"type":"log","@timestamp":"2021-07-17T19:26:47Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"} kibana6.8.11 | {"type":"log","@timestamp":"2021-07-17T19:26:47Z","tags":["warning","task_manager"],"pid":1,"message":"PollError No Living connections"} kibana6.8.11 | {"type":"log","@timestamp":"2021-07-17T19:26:48Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"} kibana6.8.11 | {"type":"log","@timestamp":"2021-07-17T19:26:48Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
错误原因
kibana监听的地址不对
解决方式
修改kibana监听地址
使用命令
docker exec -it 容器id bash
进入kibana容器内部修改
config/kibana.yml
中elasticsearch.host
的值为ES的IP地址:# # ** THIS IS AN AUTO-GENERATED FILE ** # # Default Kibana configuration for docker target server.name: kibana server.host: "0" # 看到此处监听的地址是http://elasticsearch:9200,修改为ES的地址即可 elasticsearch.hosts: [ "http://elasticsearch:9200" ] xpack.monitoring.ui.container.elasticsearch.enabled: true重启容器。
测试访问
ES:
kibana:
IK分词器
从GitHub上找到IK的工程。
找到与ES对应的版本。
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.8.11/elasticsearch-analysis-ik-6.8.11.zip
Linux安装可使用如下方法:
进入ES容器内部
进入bin目录下
运行命令
sh elasticsearch-plugin install IK的GitHub下载地址
下载安装重启ES容器
测试
这篇关于CentOS7下使用docker安装ElasticSearch的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-20Docker部署资料:新手入门教程
- 2024-12-19Docker部署实战:新手入门教程
- 2024-12-19Docker部署教程:新手入门详解
- 2024-12-09云原生周刊:在Docker上部署大语言模型
- 2024-12-05Docker教程:新手快速入门指南
- 2024-12-05Docker项目实战:新手教程与案例解析
- 2024-12-04Docker入门教程:快速掌握基础操作
- 2024-12-04Docker入门教程:轻松搭建你的第一个容器化应用
- 2024-12-04Docker-Compose 入门教程:全面解析基础命令与应用场景
- 2024-12-04Docker入门:新手必读的简单教程