主要是修改配置文件
第一步:复制三份es
第二步:修改yml配置文件
配置文件位置:/usr/local/ElasticSearch/es-cluster/node-9201/config/elasticsearch.yml
9201的配置文件:
# 加入如下配置 # 集群名称 cluster.name: cluster-es # 节点名称, 每个节点的名称不能重复 node.name: node-9201 #ip 地址, 每个节点的地址不能重复 network.host: 192.168.0.104 # 是不是有资格主节点 node.master: true node.data: true http.port: 9201 #tcp 监听端口 transport.tcp.port: 9301 # head 插件需要这打开这两个配置 http.cors.allow-origin: "*" http.cors.enabled: true http.max_content_length: 200mb #es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master cluster.initial_master_nodes: ["node-9201"] #es7.x 之后新增的配置,节点发现 discovery.seed_hosts: ["192.168.0.104:9301","192.168.0.104:9302","192.168.0.104:9303"] 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
9202的配置文件
# 加入如下配置 # 集群名称 cluster.name: cluster-es # 节点名称, 每个节点的名称不能重复 node.name: node-9202 #ip 地址, 每个节点的地址不能重复 network.host: 192.168.0.104 # 是不是有资格主节点 node.master: true node.data: true http.port: 9202 #tcp 监听端口 transport.tcp.port: 9302 # head 插件需要这打开这两个配置 http.cors.allow-origin: "*" http.cors.enabled: true http.max_content_length: 200mb #es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master cluster.initial_master_nodes: ["node-9201"] #es7.x 之后新增的配置,节点发现 discovery.seed_hosts: ["192.168.0.104:9301","192.168.0.104:9302","192.168.0.104:9303"] 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
9203的配置文件
# 加入如下配置 # 集群名称 cluster.name: cluster-es # 节点名称, 每个节点的名称不能重复 node.name: node-9203 #ip 地址, 每个节点的地址不能重复 network.host: 192.168.0.104 # 是不是有资格主节点 node.master: true node.data: true http.port: 9203 #tcp 监听端口 transport.tcp.port: 9303 # head 插件需要这打开这两个配置 http.cors.allow-origin: "*" http.cors.enabled: true http.max_content_length: 200mb #es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master cluster.initial_master_nodes: ["node-9201"] #es7.x 之后新增的配置,节点发现 discovery.seed_hosts: ["192.168.0.104:9301","192.168.0.104:9302","192.168.0.104:9303"] 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
然后分别启动三个节点即可
第三步:检查集群状态
postman发送请求:http://192.168.0.104:9201/_cat/nodes 查看节点个数
补充:可能出现的错误
我在启动时,9203节点总是添加不进集群
解决办法:
1、检查配置文件的正确性
2、删除9203节点里面的data和logs目录里面的所有东西
3、重启9203
解决问题



