1.拉取镜像
docker pull elasticsearch:6.5.4
2.修改别名
docker tag [容器ID] es65:6.5.4
2.启动应用
docker run -it -d -p 9200:9200 -p 9300:9300 --name es -e ES_JAVA_OPTS="-Xms128m -Xmx128m" es65:6.5.4
3.拷贝配置文件到宿主机
docker cp es:/usr/share/elasticsearch/ /Users/xumengmeng/Document/docker
4.删除刚启动的容器
docker stop es
docker rm es
5.重新运行
docker run -it -d -p 9200:9200 -p 9300:9300 --name es -e ES_JAVA_OPTS="-Xms128m -Xmx128m" -v /Users/xumengmeng/Document/docker/elasticsearch/config:/usr/share/elasticsearch/config -v /Users/xumengmeng/Document/docker/elasticsearch/data:/usr/share/elasticsearch/data -v /Users/xumengmeng/Document/docker/elasticsearch/plugins:/usr/share/elasticsearch/plugins es65:6.5.4
参数解释:
- -p 9200:9200 -p 9300:9300:为暴露两个端口。9200是发送http请求时向es发起请求的端口,9300是es在分布式集群状态下节点间的通信端口
- -e “discovery.type=single-node” :指定es以单节点运行
- -e ES_JAVA_OPTS=“-Xms64m -Xmx128m”:此参数很重要,如果不指定该参数,es启动会将虚拟机内存全部占用
[报错]
Exception in thread “main” java.nio.file.NotDirectoryException: /usr/share/elasticsearch/plugins/.DS_Store
【处理】rm -rf .DS_store
6.验证
访问:宿主机ip:9200
You Know, for Search
7.相关命令
查看安装插件列表
http://localhost:9200/_cat/plugins文章来源:https://www.toymoban.com/news/detail-763690.html
QIeB-qN analysis-ik 6.5.4
QIeB-qN ingest-geoip 6.5.4
QIeB-qN ingest-user-agent 6.5.4文章来源地址https://www.toymoban.com/news/detail-763690.html
8.管道建立
curl -X PUT "http://localhost:9200/_ingest/pipeline/user_agent" -H 'Content-Type: application/json' -d' { "description" : "Add user agent information", "processors" : [ { "user_agent" : { "field" : "agent" } } ] }'
1.删除attachment的pipeline
delete http://{{site}}:9200/_ingest/pipeline/attachment
2.建立attachment的pipeline,每个节点都需要这样操作
curl -X PUT "http://localhost:9200/_ingest/pipeline/attachment" -H 'Content-Type: application/json' -d' { "description": "Extract attachment information from arrays", "processors": [ { "foreach": { "field": "attachments", "processor": { "attachment": { "target_field": "_ingest._value.attachment", "field": "_ingest._value.data" } } } } ] }'
到了这里,关于docker容器安装ES的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!