ElasticSearch系列---【linux离线安装elasticsearch7.8非默认端口组成的集群】

发布时间 2023-06-28 02:22:57作者: 少年攻城狮

linux离线安装elasticsearch7.8非默认端口组成的集群

前置环境配置,es用户创建和包下载

请参考:https://www.cnblogs.com/hujunwei/p/17481718.html

规划

现有192.168.1.90(A)和192.168.1.101(B)两条虚拟机搭建的服务器,打算A服务器部署两个es实例,端口为(9400,9401)和(9600,9601),B服务器部署一个es实例,端口为(9500,9501),前者为对外提供查询的端口,后者为集群内部通信端口。

主节点配置文件

cluster.name: cluster-es
#节点名称, 每个节点的名称不能重复
node.name: node-1
#ip 地址, 每个节点的地址不能重复
network.host: 0.0.0.0
#是不是有资格主节点
node.master: true
node.data: true
http.port: 9400
# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master
transport.tcp.port: 9401
cluster.initial_master_nodes: ["node-1"]
#es7.x 之后新增的配置,节点发现,默认端口9300,可以省略,若修改,请和transport.tcp.port的值保持一致
discovery.seed_hosts: ["192.168.1.90:9401","192.168.1.101:9501","192.168.1.90:9601"]
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

从节点node-2配置文件

cluster.name: cluster-es
#节点名称, 每个节点的名称不能重复
node.name: node-2
#ip 地址, 每个节点的地址不能重复
network.host: 0.0.0.0
#是不是有资格主节点
node.master: true
node.data: true
http.port: 9500
# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master
transport.tcp.port: 9501
cluster.initial_master_nodes: ["node-1"]
#es7.x 之后新增的配置,节点发现,默认端口9300,可以省略,若修改,请和transport.tcp.port的值保持一致
discovery.seed_hosts: ["192.168.1.90:9401","192.168.1.101:9501","192.168.1.90:9601"]
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

从节点node-3配置文件

cluster.name: cluster-es
#节点名称, 每个节点的名称不能重复
node.name: node-3
#ip 地址, 每个节点的地址不能重复
network.host: 0.0.0.0
#是不是有资格主节点
node.master: true
node.data: true
http.port: 9600
# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master
transport.tcp.port: 9601
cluster.initial_master_nodes: ["node-1"]
#es7.x 之后新增的配置,节点发现,默认端口9300,可以省略,若修改,请和transport.tcp.port的值保持一致
discovery.seed_hosts: ["192.168.1.90:9401","192.168.1.101:9501","192.168.1.90:9601"]
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

es启动命令

#注意:第一次启动不了的话,再次启动先删除data目录和logs下的日志,再启动
./elasticsearch -d

浏览器验证地址

http://192.168.1.90:9400/_cat/nodes

如下图,说明集群已经搭建好了