Linux ubuntu 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux()
JDK版本(java -v)Java version "1.8.0_311"
docker版本(docker -v)Docker version 20.10.10, build b485636
Elasticsearch版本elasticsearch:7.1.1
2 Elasticsearch安装步骤 2.1 拉取镜像注:可通过Docker Hub查看elasticsearch相关的docker镜像
sudo docker pull elasticsearch:7.6.22.2 查看镜像
sudo docker images2.3 创建挂载目录
- data:存放索引数据
- plugins:存放es插件
## -创建挂载目录[data:存放索引数据,plugins:存放es插件] mkdir -p /home/zhongqiu/elasticsearch mkdir -p /home/zhongqiu/elasticsearch/config/data1 mkdir -p /home/zhongqiu/elasticsearch/config/data2 mkdir -p /home/zhongqiu/elasticsearch/config/data3 mkdir -p /home/zhongqiu/elasticsearch/config/plugins1 mkdir -p /home/zhongqiu/elasticsearch/config/plugins2 mkdir -p /home/zhongqiu/elasticsearch/config/plugins32.4 为挂载目录设置执行权限
## 设置执行权限 chmod 777 /home/zhongqiu/elasticsearch/config/data1 chmod 777 /home/zhongqiu/elasticsearch/config/data2 chmod 777 /home/zhongqiu/elasticsearch/config/data32.5 分别创建es的配置文件
--data1/data2/data3 分别创建es.yml [network.publish_host:填写服务器ip]
本文档中集群是在一台虚拟机上的伪集群,但是有三个节点es-node1、es-node2、es-node3。
es-node1配置文件vim /home/zhongqiu/elasticsearch/config/es1.yml ## 文件内容 cluster.name: elasticsearch-clusters cluster.initial_master_nodes : es-node1 node.name: es-node1 network.bind_host: 0.0.0.0 network.publish_host: 192.168.58.128 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.58.128:9301","192.168.58.128:9302","192.168.58.128:9303"]es-node2配置文件
vim /home/zhongqiu/elasticsearch/config/es2.yml ## 文件内容 cluster.name: elasticsearch-clusters node.name: es-node2 network.bind_host: 0.0.0.0 network.publish_host: 192.168.58.128 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.58.128:9301","192.168.58.128:9302","192.168.58.128:9303"]es-node3配置文件
vim /home/zhongqiu/elasticsearch/config/es3.yml ## 文件内容 cluster.name: elasticsearch-clusters node.name: es-node3 network.bind_host: 0.0.0.0 network.publish_host: 192.168.58.128 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.58.128:9301","192.168.58.128:9302","192.168.58.128:9303"]2.6 调高JVM线程数限制数量
不调整的话,启动可能报错。
sudo vim /etc/sysctl.conf ## 更新或者插入文件内容(有就更新,无则新增) vm.max_map_count = 262144 ## 刷新生效 sudo sysctl -p2.7 集群部署
上述的配置文件、文件挂载等步骤做完了开始启动节点、部署集群。
节点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=2048m -v /home/zhongqiu/elasticsearch/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/zhongqiu/elasticsearch/config/data1/:/usr/share/elasticsearch/data/ -v /home/zhongqiu/elasticsearch/config/plugins1/:/usr/share/elasticsearch/plugins --restart=always --name es01 elasticsearch:7.6.2节点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=2048m -v /home/zhongqiu/elasticsearch/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/zhongqiu/elasticsearch/config/data2/:/usr/share/elasticsearch/data/ -v /home/zhongqiu/elasticsearch/config/plugins2/:/usr/share/elasticsearch/plugins --restart=always --name es02 elasticsearch:7.6.2节点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=2048m -v /home/zhongqiu/elasticsearch/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/zhongqiu/elasticsearch/config/data3/:/usr/share/elasticsearch/data/ -v /home/zhongqiu/elasticsearch/config/plugins3/:/usr/share/elasticsearch/plugins --restart=always --name es03 elasticsearch:7.6.22.8 防火墙设置
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-reload2.8 校验
校验docker启动情况,校验集群情况
校验docker启动情况docker ps校验集群情况
curl http://192.168.58.128:9201/_cat/health?v3 安装ik分词 3.1 安装 es01节点安装
# 进入容器 docker exec -it es01 bash # 在线安装(这里github网络不稳定,可能多试几次) elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.2/elasticsearch-analysis-ik-7.6.2.zipes02 节点安装
# 进入容器 docker exec -it es02 bash # 在线安装(这里github网络不稳定,可能多试几次) elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.2/elasticsearch-analysis-ik-7.6.2.zip
es03 节点安装
# 进入容器 docker exec -it es03 bash # 在线安装(这里github网络不稳定,可能多试几次) elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.2/elasticsearch-analysis-ik-7.6.2.zip重启生效
docker restart es01 docker restart es02 es034 elastic-head安装
部署elasticsearch-head 便于管理es数据
4.1 安装## 获取镜像 docker pull mobz/elasticsearch-head:5 ## 运行镜像 docker run -d --name=es-head -p 9100:9100 -m 512m --memory-swap=1024m mobz/elasticsearch-head:54.2 校验
http://192.168.58.128:9100/5 安装Kibana 5.1 镜像获取
## 获取跟elasticsearch版本相同 docker pull kibana:7.6.25.2 kibana配置文件
# Default Kibana configuration for docker target server.name: kibana server.host: "0" elasticsearch.hosts: ["http://192.168.58.128:9201"] xpack.monitoring.ui.container.elasticsearch.enabled: true5.3 启动
docker run -d -p 5601:5601 -v /home/zhongqiu/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml --name kibana kibana:7.6.25.4 结果
http://192.168.58.128:5601/
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)