首页
点滴
Docker安装配置Elasticsearch
#### 1、拉取elasticsearch镜像,和kibana可视化镜像 ``` docker pull elasticsearch:7.17.0 docker pull kibana:7.17.0 ``` #### 2、创建和容器内配置文件映射的文件 ``` mkdir -p /gsafety/docker/elasticsearch/config mkdir -p /gsafety/docker/elasticsearch/data mkdir -p /gsafety/docker/elasticsearch/plugins ``` #### 3、向外部配置文件中添加配置 ``` echo "http.host: 0.0.0.0" >> /gsafety/docker/elasticsearch/config/elasticsearch.yml ``` #### 4、保证挂载文件权限 ``` chmod -R 777 /gsafety/docker/elasticsearch/ ``` #### 5、启动elasticsearch容器 ``` docker run --name myelasticsearch -p 9200:9200 -p 9300:9300 \ -e "discovery.type=single-node" \ -e ES_JAVA_OPTS="-Xms64m -Xmx512m" \ -v /gsafety/docker/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \ -v /gsafety/docker/elasticsearch/data:/usr/share/elasticsearch/data \ -v /gsafety/docker/elasticsearch/plugins:/usr/share/elasticsearch/plugins \ -d elasticsearch:7.17.0 ``` #### 6、启动kibana容器 ``` docker run --name mykibana -e ELASTICSEARCH_HOSTS=http://10.97.129.36:9200 -p 5601:5601 -d kibana:7.17.0 ``` #### 7、测试,在9200、5601端口开通访问权限的前提下。 ``` 浏览器访问:http://ip地址:9200 linux服务器上用命令访问:curl 用户名:密码@localhost:9200 浏览器访问:http://ip地址:5601 ``` #### 8、安装ik分词器。 创建ik插件目录 ``` mkdir /gsafety/docker/elasticsearch/plugins/ik ``` 下载ik压缩包上传到 /gsafety/docker/elasticsearch/plugins/ik 目录下解压。然后重启es容器即可 ``` https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.0/elasticsearch-analysis-ik-7.17.0.zip ``` #### 9、测试ik分词器 可直接在服务器上测试,如果es已经开启的访问验证,则访问是需要用户名和密码 ``` curl -X POST -H "Content-Type: application/json" http://用户名:密码@localhost:9200/_analyze -d '{"analyzer": "ik_smart", "text": "中华人民共和国国歌"}' ``` 如果没开启验证 ``` curl -X POST -H "Content-Type: application/json" http://localhost:9200/_analyze -d '{"analyzer": "ik_smart", "text": "中华人民共和国国歌"}' ```
博客分类
源码解析 (1)
Java (10)
Linux (8)
多线程 (5)
Docker (9)
SpringBoot (14)
微服务 (1)
Redis (15)
MySQL (7)
VMware (3)
Nginx (15)
MyBatis (2)
Git (7)
RabbitMQ (1)
工具类 (12)
前端 (3)
友情链接
layui
© 2020-2025 www.chenhuazhan.com All Rights Reserved 备案号:
桂ICP备17004487号-1
粤公网安备44030002005146