docker 部署 elasticsearch
557人浏览 / 0人评论
elasticsearch:7.16.2
# 7.16.2
docker pull elasticsearch:7.16.2
# 第一次启动
docker run -d --name es -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms64m -Xmx128m" -e "discovery.type=single-node" elasticsearch:7.16.2
# 复制文件
docker cp es:/usr/share/elasticsearch/data /home/elasticsearch/data
docker cp es:/usr/share/elasticsearch/config /home/elasticsearch/conf
docker cp es:/usr/share/elasticsearch/plugins /home/elasticsearch/plugins
# 挂载启动
docker run -d -it --restart=always --name es \
-p 9200:9200 -p 9300:9300 \
-e ES_JAVA_OPTS="-Xms64m -Xmx128m" \
-e "discovery.type=single-node" \
-v /home/elasticsearch/data:/usr/share/elasticsearch/data \
-v /home/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /home/elasticsearch/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
elasticsearch:7.16.2
# 加载ik分词器
# 下载zip文件:https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v7.16.2
cd /home/elasticsearch/plugins
mkdir elasticsearch-analysis-ik-7.16.2
上传文件,然后 unzip 解压,最后删除 zip 文件
#启用认证
# vim /data/elasticsearch/elasticsearch.yml,然后添加以下内容:
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
# 开启跨域
http.cors.enabled: true
http.cors.allow-origin: '*'
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
#重启
docker restart es
# 进入容器执行:elasticsearch-setup-passwords interactive,然后输入密码:123456
elasticsearch:8.13.3
docker pull elasticsearch:8.13.3
# 修改配置文件
http.port: 9200
discovery.type: single-node
http.host: 0.0.0.0
## 禁用密码(启用密码后需要在容器内执行:elasticsearch-setup-passwords interactive)
xpack.security.enabled: false
#xpack.license.self_generated.type: basic
# 加载ik分词器
docker exec -it es /bin/bash
cd /usr/share/elasticsearch/
bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/8.13.3
# 然后重启容器即可
全部评论