您的位置 首页 教育

docker部署ES集群

离线部署es 1.找到一台联网的机器,把对应版本的镜像拉取下来 sudo docker pull elasti…

  • 离线部署es

1.找到一台联网的机器,把对应版本的镜像拉取下来

sudo docker pull elasticsearch:7.10.1

2.将镜像保存为本地文件

sudo docker save elasticsearch:7.10.1 -o /data/appadmjjkj/images/es-docker-7.10.1.tar

或 sudo docker save IMAGE ID -o /data/appadmjjkj/images/es-docker-7.10.1.tar

3.将保存号的tar镜像文件上传到要部署的机器上,安装镜像

sudo docker load -i es-docker-7.10.1.tar

4.创建挂载目录[data:存放索引数据,plugins:存放es插件]

sudo mkdir -p  /data/appadmjjkj/elasticsearch

sudo mkdir -p  /data/appadmjjkj/elasticsearch/config/data1

sudo mkdir -p  /data/appadmjjkj/elasticsearch/config/data2

sudo mkdir -p  /data/appadmjjkj/elasticsearch/config/data3

sudo mkdir -p  /data/appadmjjkj/elasticsearch/config/plugins1

sudo mkdir -p  /data/appadmjjkj/elasticsearch/config/plugins2

sudo mkdir -p  /data/appadmjjkj/elasticsearch/config/plugins3

5.设置执行权限

sudo chmod 777 /data/appadmjjkj/elasticsearch/config/data1

sudo chmod 777 /data/appadmjjkj/elasticsearch/config/data2

sudo chmod 777 /data/appadmjjkj/elasticsearch/config/data3

  1. 更改系统配置​

sudo vi /etc/sysctl.conf

->>

vm.max_map_count=262145

配置改完刷新

sysctl -p

7.data1/data2/data3 分别创建es.yml [network.publish_host:填写服务器ip]

 sudo vi /data/appadmjjkj/elasticsearch/config/es1.yml

  ->>

cluster.name: elasticsearch-cluster   #集群名(三个节点一致)

cluster.initial_master_nodes : es-node1 # 默认的主节点

node.name: es-node1   #节点名(每台节点不同)

network.bind_host: 0.0.0.0

network.publish_host: 10.30.4.49  #对外地址

http.port: 9201 #对外端口(每台机器装一个ES则不用改)

transport.tcp.port: 9301 #ES内部通信端口(每台机器装一个ES则不用改)

discovery.zen.minimum_master_nodes: 2 #主节点数/2+1,防止脑裂

http.max_content_length: 2000mb

http.max_header_size: 1024k

http.max_initial_line_length: 1024k

http.cors.enabled: true

http.cors.allow-origin: “*”

node.master: true

node.data: true  

discovery.zen.ping.unicast.hosts:  [“10.30.4.49:9301″,”10.30.4.49:9302″,”10.30.4.49:9303”]

#es jvm大小,预留等值的系统内存(可用内存)作为es缓存。以32g系统内存为例,ES jvm设为16g。

-Xms16g

-Xmx16g

#PS ES单节点最大31g

       

sudo vi /data/appadmjjkj/elasticsearch/config/es2.yml

    ->>

cluster.name: elasticsearch-cluster

node.name: es-node2

network.bind_host: 0.0.0.0

network.publish_host: 10.30.4.49

http.port: 9202

transport.tcp.port: 9302

discovery.zen.minimum_master_nodes: 2 #主节点数/2+1,防止脑裂

http.max_content_length: 2000mb

http.max_header_size: 1024k

http.max_initial_line_length: 1024k

http.cors.enabled: true

http.cors.allow-origin: “*”

node.master: false#主节点

node.data: true  

discovery.zen.ping.unicast.hosts:  [“10.30.4.49:9301″,”10.30.4.49:9302″,”10.30.4.49:9303”]

#es jvm大小,预留等值的系统内存(可用内存)作为es缓存。以32g系统内存为例,ES jvm设为16g。

-Xms16g

-Xmx16g

#PS ES单节点最大31g

   

sudo vi /data/appadmjjkj/elasticsearch/config/es3.yml

->>

cluster.name: elasticsearch-cluster

node.name: es-node3

network.bind_host: 0.0.0.0

network.publish_host: 10.30.4.49

http.port: 9203

transport.tcp.port: 9303

discovery.zen.minimum_master_nodes: 2 #主节点数/2+1,防止脑裂

indices.query.bool.max_clause_count: 10000000

http.max_content_length: 2000mb

http.max_header_size: 1024k

http.max_initial_line_length: 1024k

http.cors.enabled: true

http.cors.allow-origin: “*”

node.master: false#主节点

node.data: true  

discovery.zen.ping.unicast.hosts:  [“10.30.4.49:9301″,”10.30.4.49:9302″,”10.30.4.49:9303”]

#es jvm大小,预留等值的系统内存(可用内存)作为es缓存。以32g系统内存为例,ES jvm设为16g。

-Xms16g

-Xmx16g

#PS ES单节点最大31g

  1. 启动服务

# 服务1

sudo docker run -itd -e ES_JAVA_OPTS=”-Xms2048m -Xmx2048m”

-p 9201:9201 -p 9301:9301

-e ES_MIN_MEM=128m

-e ES_MAX_MEM=4096m

-v /data/appadmjjkj/elasticsearch/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml

-v /data/appadmjjkj/elasticsearch/config/data1/:/usr/share/elasticsearch/data/

-v /data/appadmjjkj/elasticsearch/config/plugins1/:/usr/share/elasticsearch/plugins

–restart=always

–name ES01

elasticsearch:7.10.1

# 服务2

sudo docker run -it -e ES_JAVA_OPTS=”-Xms2048m -Xmx2048m”

-p 9202:9202 -p 9302:9302

-e ES_MIN_MEM=128m

-e ES_MAX_MEM=4096m

-v /data/appadmjjkj/elasticsearch/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml

-v /data/appadmjjkj/elasticsearch/config/data2/:/usr/share/elasticsearch/data/

-v /data/appadmjjkj/elasticsearch/config/plugins2/:/usr/share/elasticsearch/plugins

–restart=always

–name ES02

elasticsearch:7.10.1

# 服务3

sudo docker run -itd -e ES_JAVA_OPTS=”-Xms2048m -Xmx2048m”

-p 9203:9203 -p 9303:9303

-e ES_MIN_MEM=128m

-e ES_MAX_MEM=4096m

-v /data/appadmjjkj/elasticsearch/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml

-v /data/appadmjjkj/elasticsearch/config/data3/:/usr/share/elasticsearch/data/

-v /data/appadmjjkj/elasticsearch/config/plugins1/:/usr/share/elasticsearch/plugins 

–restart=always

–name ES03

elasticsearch:7.10.1

  1. 验证是否正常启动

sudo docker ps -a 查看容器状态

确认集群配置

curl http://127.0.0.1:9201/_cat/nodes?pretty

 

        

本文来自网络,不代表0514资讯网立场,转载请注明出处:https://0514zx.com/info/6394.html
0514zx.com

作者: 0514zx.com

优质职场领域创作者
联系我们

联系我们

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部