docker离线安装方法_探路者之旅的博客-CSDN博客
部署步骤
1.初始化es配置文件
-- 拉取es镜像
docker pull elasticsearch:7.2.0
--创建挂载目录[data:存放索引数据,plugins:存放es插件]
mkdir -p /home/software/elasticsearch
mkdir -p /home/software/elasticsearch/config/data1
mkdir -p /home/software/elasticsearch/config/data2
mkdir -p /home/software/elasticsearch/config/data3
mkdir -p /home/software/elasticsearch/config/plugins1
mkdir -p /home/software/elasticsearch/config/plugins2
mkdir -p /home/software/elasticsearch/config/plugins3
-- 设置执行权限
chmod 777 /home/software/elasticsearch/config/data1
chmod 777 /home/software/elasticsearch/config/data2
chmod 777 /home/software/elasticsearch/config/data3
--data1/data2/data3 分别创建es.yml [network.publish_host:填写服务器ip]
vim /home/software/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: 192.168.100.200
http.port: 9201
transport.tcp.port: 9301
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.100.200:9301","192.168.100.200:9302","192.168.100.200:9303"]
vim /home/software/elasticsearch/config/es2.yml
->>
cluster.name: elasticsearch-cluster
node.name: es-node2
network.bind_host: 0.0.0.0
network.publish_host: 192.168.100.200
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.100.200:9301","192.168.100.200:9302","192.168.100.200:9303"]
vim /home/software/elasticsearch/config/es3.yml
->>
cluster.name: elasticsearch-cluster
node.name: es-node3
network.bind_host: 0.0.0.0
network.publish_host: 192.168.100.200
http.port: 9203
transport.tcp.port: 9303
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.100.200:9301","192.168.100.200:9302","192.168.100.200:9303"]
调高JVM线程数限制数量
vim /etc/sysctl.conf
->>
vm.max_map_count=262144
# 刷新配置
sysctl -p
2.服务部署
es集群部署
# 服务1
docker run -e ES_JAVA_OPTS="-Xms2048m -Xmx2048m" \
-d -p 9201:9201 -p 9301:9301 \
-e ES_MIN_MEM=128m \
-e ES_MAX_MEM=4096m \
-v /home/software/elasticsearch/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/software/elasticsearch/config/data1/:/usr/share/elasticsearch/data/ \
-v /home/software/elasticsearch/config/plugins1/:/usr/share/elasticsearch/plugins \
--restart=always \
--name es01 \
elasticsearch:7.2.0
# 服务2
docker run -e ES_JAVA_OPTS="-Xms2048m -Xmx2048m" \
-d -p 9202:9202 -p 9302:9302 \
-e ES_MIN_MEM=128m \
-e ES_MAX_MEM=4096m \
-v /home/software/elasticsearch/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/software/elasticsearch/config/data2/:/usr/share/elasticsearch/data/ \
-v /home/software/elasticsearch/config/plugins2/:/usr/share/elasticsearch/plugins \
--restart=always \
--name es02 \
elasticsearch:7.2.0
# 服务3
docker run -e ES_JAVA_OPTS="-Xms2048m -Xmx2048m" \
-d -p 9203:9203 -p 9303:9303 \
-e ES_MIN_MEM=128m \
-e ES_MAX_MEM=4096m \
-v /home/software/elasticsearch/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/software/elasticsearch/config/data3/:/usr/share/elasticsearch/data/ \
-v /home/software/elasticsearch/config/plugins3/:/usr/share/elasticsearch/plugins \
--restart=always \
--name es03 \
elasticsearch:7.2.0
# 防火墙设置
firewall-cmd --add-port=9301/tcp
firewall-cmd --add-port=9302/tcp
firewall-cmd --add-port=9303/tcp
firewall-cmd --add-port=9200/tcp
firewall-cmd --add-port=9201/tcp
firewall-cmd --add-port=9202/tcp
firewall-cmd --add-port=9203/tcp
firewall-cmd --complete-reload
确认集群配置
curl http://127.0.0.1:9201/_cat/nodes?pretty
3.IK分词器安装
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.2.0/elasticsearch-analysis-ik-7.2.0.zip下载下来放到/home/software/elasticsearch/config/plugins1/中 然后复制到 plugins2 、plugins3
重启三个es节点
5.ES负载均衡
nginx配置es负载均衡文章来源:https://www.toymoban.com/news/detail-522923.html
修改nginx配置文件文章来源地址https://www.toymoban.com/news/detail-522923.html
#修改nginx配置文件
vim /home/software/nginx/conf.d/default.conf
->>
# 配置上游服务器集群信息
upstream es-cluster {
server 192.168.100.200:9201;
server 192.168.100.200:9202;
server 192.168.100.200:9203;
keepalive 1000;
}
# 配置代理服务器信息
server {
listen 9200;
server_name localhost;
location / {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://es-cluster;
}
location /nginx-status {
stub_status on;
}
}
到了这里,关于ES集群安装(docker)7.2.0的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!