Featured image of post Docker-Run命令部署Elasticsearch

Docker-Run命令部署Elasticsearch

推荐文章:

【合集】Docker

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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

localhost:9200

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

#设定绑定的ip

network.host: 192.168.1.3

transport.host: 0.0.0.0

http.port: 9200

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

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

皖ICP备2024056275号-1
发表了78篇文章 · 总计149.56k字
本站已稳定运行