Docker-Run命令部署Elasticsearch

docker run --name elasticsearch \
    -p 9200:9200 \
    -p 9300:9300 \
    -e ES_JAVA_POTS="-Xms256m -Xmx256m" \
    -e "discovery.type=single-node" \
    -d elasticsearch:8.5.1

docker cp elasticsearch:/usr/share/elasticsearch/logs ~/elasticsearch/
docker cp elasticsearch:/usr/share/elasticsearch/plugins ~/elasticsearch/
docker cp elasticsearch:/usr/share/elasticsearch/config ~/elasticsearch/

vim ~//elasticsearch/config/elasticsearch.yml

true => false

cluster.name: "docker-cluster"
network.host: 0.0.0.0

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically
# generated to configure Elasticsearch security features on 01-12-2022 04:37:03
#
# --------------------------------------------------------------------------------

# Enable security features
xpack.security.enabled: false

xpack.security.enrollment.enabled: true

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: false
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: false
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
  #----------------------- END SECURITY AUTO CONFIGURATION -------------------------
  docker rm -f elasticsearch

  docker run \
  -d \
  --name elasticsearch \
  -p 9200:9200 \
  -p 9300:9300 \
  -e ES_JAVA_POTS="-Xms256m -Xmx256m" \
  -e "discovery.type=single-node" \
  -v ~/docker/volumes/elasticsearch/logs:/usr/share/elasticsearch/logs \
  -v ~/docker/volumes/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
  -v ~/docker/volumes/elasticsearch/config:/usr/share/elasticsearch/config \
  elasticsearch:8.5.1

http://localhost:9200

如果还不行,最后一行写入:

#设定绑定的ip

network.host: 192.168.1.3

transport.host: 0.0.0.0

http.port: 9200

mac查看ip:[mac苹果电脑怎么查看本机IP与MAC地址 - 知乎

https://zhuanlan.zhihu.com/p/81306825

ifconfig 192.168.1.3

其中“eth0”表示以太网网卡,“lo0”表示环回地址。

下载对应ik分词器 https://hub.nuaa.cf/medcl/elasticsearch-analysis-ik/releases

解压放入~/docker/volumes/elasticsearch/plugins/{ik压缩包名称}下,重启es

也可 进入es容器内部 docker exec -it elasticsearch /bin/bash 执行:

elasticsearch-plugin install


标题:Docker-Run命令部署Elasticsearch
作者:Curry
地址:http://bolo.it-cxy.top/articles/2024/11/16/1731763821383.html

    评论
    0 评论
avatar

取消