docker elasticsearch

分词插件准备:

wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip

wget https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v7.17.7/elasticsearch-analysis-pinyin-7.17.7.zip

单机版

mkdir -p /data/elasticsearch/config
mkdir -p /data/elasticsearch/data
mkdir -p /data/elasticsearch/plugins

cat /data/elasticsearch/config/elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0

docker run -d -m 2G --cpus 1 --name elasticsearch --restart=always  -e "discovery.type=single-node" -p 0.0.0.0:9200:9200 -v /data/elasticsearch/config:/usr/share/elasticsearch/config -v /data/elasticsearch/data:/usr/share/elasticsearch/data -v /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins elasticsearch:7.17.7

集群版

机器准备:

172.16.10.1

172.16.10.2

172.16.10.3

每台机器目录创建,以及插件解压放入plugins目录中

172.16.10.1配置文件:

cat /data/elasticsearch/config/elasticsearch.yml
cluster.name: es
node.name: node1
node.master: true
node.data: true
network.host: 172.16.10.1
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["172.16.10.1:9300", "172.16.10.2:9300","172.16.10.3:9300"]
cluster.initial_master_nodes: ["node1"]
#http.cors.enabled: true
#http.cors.allow-origin: "*"

172.16.10.2配置文件:

cat /data/elasticsearch/config/elasticsearch.yml
cluster.name: es
node.name: node2
node.master: true
node.data: true
network.host: 172.16.10.2
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["172.16.10.1:9300", "172.16.10.2:9300","172.16.10.3:9300"]
cluster.initial_master_nodes: ["node1"]

172.16.10.3 配置文件:

cat /data/elasticsearch/config/elasticsearch.yml
cluster.name: es
node.name: node3
node.master: true
node.data: true
network.host: 172.16.10.3
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["172.16.10.1:9300", "172.16.10.2:9300","172.16.10.3:9300"]
cluster.initial_master_nodes: ["node1"]

docker启动命令

docker run  -d  --network=host --privileged=true  --restart=always -e ES_JAVA_OPTS="-Xms2048m -Xmx2048m"  -e TAKE_FILE_OWNERSHIP=true --name es-node1 -v /data/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /data/elasticsearch/data:/usr/share/elasticsearch/data -v /data/elasticsearch/logs:/usr/share/elasticsearch/logs -v /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins elasticsearch:7.17.7

docker run  -d  --network=host --privileged=true  --restart=always -e ES_JAVA_OPTS="-Xms2048m -Xmx2048m"  -e TAKE_FILE_OWNERSHIP=true --name es-node2 -v /data/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /data/elasticsearch/data:/usr/share/elasticsearch/data -v /data/elasticsearch/logs:/usr/share/elasticsearch/logs -v /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins elasticsearch:7.17.7

docker run  -d  --network=host --privileged=true  --restart=always -e ES_JAVA_OPTS="-Xms2048m -Xmx2048m"  -e TAKE_FILE_OWNERSHIP=true --name es-node3 -v /data/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /data/elasticsearch/data:/usr/share/elasticsearch/data -v /data/elasticsearch/logs:/usr/share/elasticsearch/logs -v /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins elasticsearch:7.17.7

查看集群是否成功

curl http://172.16.10.3:9200/_cat/nodes?pretty
172.16.10.3 55 42 0 0.02 0.04 0.05 cdfhilmrstw - node3
172.16.10.1 41 34 0 0.00 0.01 0.05 cdfhilmrstw * node1
172.16.10.2 70 61 0 0.05 0.03 0.05 cdfhilmrstw - node2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值