ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## :-: docker 安装elasticsearch 1、查看所有的es镜像 ``` docker search elasticsearch ``` ![](https://img.kancloud.cn/fa/ff/fafff15bc904fe6d73a2f248b8f78812_876x460.png) 2、配置阿里云加速器 ![](https://img.kancloud.cn/33/1a/331ad1e24e36fc5752c7496e2ecb83ee_905x572.png) ``` 打开配置文件 vi /etc/docker/daemon.json ``` ``` { "registry-mirrors": ["https://2o24a5kv.mirror.aliyuncs.com"] } ``` 3、拉取es镜像(推荐star高的) docker pull    elasticsearch (如果拉取过程中报错在镜像后面加上版本,比如elasticsearch:7.3.1) ![](https://img.kancloud.cn/95/7a/957a0057470103fb27a6e656f5b61e7a_618x163.png) 4、启动es ``` 跨域 docker run -itd --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx128m" -v /usr/hj/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/hj/elasticsearch/data:/usr/share/elasticsearch/data -v /usr/hj/elasticsearch/plugins:/usr/share/elasticsearch/plugins -e http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization -e http.cors.allow-credentials=true -d elasticsearch:7.3.0 ``` ``` 普通 docker run -itd --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx128m" -v /usr/hj/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/hj/elasticsearch/data:/usr/share/elasticsearch/data -v /usr/hj/elasticsearch/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:7.3.0 ``` ``` 启动参数介绍 # docker run --name elasticsearch 创建一个es容器并起一个名字; # -p 9200:9200 将linux的9200端口映射到docker容器的9200端口,用来给es发送http请求 # -p 9300:9300 9300是es在分布式集群状态下节点之间的通信端口 \ 换行符 # -e 指定一个参数,当前es以单节点模式运行 # *注意,ES_JAVA_OPTS非常重要,指定开发时es运行时的最小和最大内存占用为64M和128M,否则就会占用全部可用内存 # -v 挂载命令,将虚拟机中的路径和docker中的路径进行关联 # -d 后台启动服务 ``` 4、验证是否运行es成功 [http://106.12.33.244:9200/](http://106.12.33.244:9200/) ![](https://img.kancloud.cn/8c/5a/8c5a1733640898171186dca7007d33cd_382x299.png)