Elasticsearch7.8.0版本入门——集群部署(linux环境-centos7)
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
目录
一、三台服务器信息
- 三台服务器
服务器名称 服务器ip es节点名称 es集群的名称 centos7虚拟机1 192.168.136.23 node-1 my-elasticsearch centos7虚拟机2 192.168.136.24 node-2 my-elasticsearch centos7虚拟机3 192.168.136.25 node-3 my-elasticsearch
二、Elasticsearch7.8.0单机部署
- Elasticsearch7.8.0单机部署参考lz此博文了链接https://blog.csdn.net/li1325169021/article/details/128901540?spm=1001.2014.3001.5501
三、Elasticsearch7.8.0集群部署
3.1、分别再三台服务器中都安装Elasticsearch7.8.0
- 分别再三台服务器中都安装Elasticsearch7.8.0参考第二步的单机部署区别是三者的elasticsearch配置文件只有node.name和ip不同其余一样指定node-1为master
3.2、修改192.168.136.23服务器中elasticsearch配置文件
-
修改node-1节点中/opt/es/elasticsearch-7.8.0/config/elasticsearch.yml 文件
#集群名称 每个集群的名称相同 cluster.name: my-elasticsearch #节点名称每个节点的名称不能重复 node.name: node-1 #是不是有资格当主节点 node.master: true node.data: true #ip 地址每个节点的地址不能重复节点启动端口号9200 network.host: 192.168.136.23 http.port: 9200 # head 插件需要这打开这两个配置防跨域 http.cors.allow-origin: "*" http.cors.enabled: true http.cors.allow-credentials: true http.max_content_length: 200mb #es7.x 之后新增的配置初始化一个新的集群时需要配置默认的master cluster.initial_master_nodes: ["node-1"] #es7.x 之后新增的配置节点发现广播 节点之间通信端口号9300 discovery.seed_hosts:["192.168.136.23:9300", "192.168.136.24:9300", "192.168.136.25:9300"] gateway.recover_after_nodes: 2 network.tcp.keep_alive: true network.tcp.no_delay: true transport.tcp.compress: true #集群内同时启动的数据任务个数默认是 2 个 cluster.routing.allocation.cluster_concurrent_rebalance: 16 #添加或删除节点及负载均衡时并发恢复的线程个数默认 4 个 cluster.routing.allocation.node_concurrent_recoveries: 16 #初始化数据恢复时并发恢复线程的个数默认 4 个 cluster.routing.allocation.node_initial_primaries_recoveries: 16
3.2、修改192.168.136.24服务器中elasticsearch配置文件
-
修改node-2节点中/opt/es/elasticsearch-7.8.0/config/elasticsearch.yml 文件
#集群名称 每个集群的名称相同 cluster.name: my-elasticsearch #节点名称每个节点的名称不能重复 node.name: node-2 #是不是有资格当主节点 node.master: true node.data: true #ip 地址每个节点的地址不能重复节点启动端口号9200 network.host: 192.168.136.24 http.port: 9200 # head 插件需要这打开这两个配置防跨域 http.cors.allow-origin: "*" http.cors.enabled: true http.cors.allow-credentials: true http.max_content_length: 200mb #es7.x 之后新增的配置初始化一个新的集群时需要配置默认的master cluster.initial_master_nodes: ["node-1"] #es7.x 之后新增的配置节点发现广播 节点之间通信端口号9300 discovery.seed_hosts:["192.168.136.23:9300", "192.168.136.24:9300", "192.168.136.25:9300"] gateway.recover_after_nodes: 2 network.tcp.keep_alive: true network.tcp.no_delay: true transport.tcp.compress: true #集群内同时启动的数据任务个数默认是 2 个 cluster.routing.allocation.cluster_concurrent_rebalance: 16 #添加或删除节点及负载均衡时并发恢复的线程个数默认 4 个 cluster.routing.allocation.node_concurrent_recoveries: 16 #初始化数据恢复时并发恢复线程的个数默认 4 个 cluster.routing.allocation.node_initial_primaries_recoveries: 16
3.3、修改192.168.136.25服务器中elasticsearch配置文件
-
修改node-3节点中/opt/es/elasticsearch-7.8.0/config/elasticsearch.yml 文件
#集群名称 每个集群的名称相同 cluster.name: my-elasticsearch #节点名称每个节点的名称不能重复 node.name: node-3 #是不是有资格当主节点 node.master: true node.data: true #ip 地址每个节点的地址不能重复节点启动端口号9200 network.host: 192.168.136.25 http.port: 9200 # head 插件需要这打开这两个配置防跨域 http.cors.allow-origin: "*" http.cors.enabled: true http.cors.allow-credentials: true http.max_content_length: 200mb #es7.x 之后新增的配置初始化一个新的集群时需要配置默认的master cluster.initial_master_nodes: ["node-1"] #es7.x 之后新增的配置节点发现广播 节点之间通信端口号9300 discovery.seed_hosts:["192.168.136.23:9300", "192.168.136.24:9300", "192.168.136.25:9300"] gateway.recover_after_nodes: 2 network.tcp.keep_alive: true network.tcp.no_delay: true transport.tcp.compress: true #集群内同时启动的数据任务个数默认是 2 个 cluster.routing.allocation.cluster_concurrent_rebalance: 16 #添加或删除节点及负载均衡时并发恢复的线程个数默认 4 个 cluster.routing.allocation.node_concurrent_recoveries: 16 #初始化数据恢复时并发恢复线程的个数默认 4 个 cluster.routing.allocation.node_initial_primaries_recoveries: 16
四、Elasticsearch7.8.0集群启动
4.1、192.168.136.23服务器中启动
- 切换到es用户进入/opt/es/elasticsearch-7.8.0/目录执行bin/elasticsearch启动或者执行bin/elasticsearch -d 后台启动
4.2、192.168.136.24服务器中启动
-
切换到es用户进入/opt/es/elasticsearch-7.8.0/目录执行bin/elasticsearch启动或者执行bin/elasticsearch -d 后台启动
4.2、192.168.136.25服务器中启动
- 切换到es用户进入/opt/es/elasticsearch-7.8.0/目录执行bin/elasticsearch启动或者执行bin/elasticsearch -d 后台启动
五、测试集群是否ok
- 浏览器访问192.168.136.23服务器中elasticsearch服务如下
- 浏览器访问192.168.136.24服务器中elasticsearch服务如下
- 浏览器访问192.168.136.25服务器中elasticsearch服务如下