ElasticSearch集群环境搭建

1、准备三台服务器

这里准备三台服务器如下:

IP地址 主机名 节点名
192.168.225.65 linux1 node-1
192.168.225.66 linux2 node-2
192.168.225.67 linux3 node-3

2、准备elasticsearch安装环境

(1)编辑/etc/hosts(三台服务器都执行)

复制代码
vim /etc/hosts
添加如下内容:
192.168.225.65    linux1
192.168.225.66    linux2
192.168.225.67    linux3

(2)编辑/etc/hostname (三台服务器都执行)

复制代码
在192.168.225.65上修改
echo 'linux1' > /etc/hostname
在192.168.225.66上修改
echo 'linux2' > /etc/hostname
在192.168.225.67上修改
echo 'linux3' > /etc/hostname

(3)修改系统参数 (三台服务器都执行)

复制代码
vim /etc/security/limits.conf
修改内容如下:
*  soft nofile  65536
*  hard nofile 131072
*  soft nproc  4096
*  hard nproc  4096 

vim /etc/sysctl.conf
修改内容如下:
vm.max_map_count = 262145
保存退出,刷新配置文件
sysctl -p 

(4)上传elasticsearch安装包和创建安装用户(三台服务器都执行)
elasticsearch-7.8.1下载地址

复制代码
这里是将elasticsearch安装包elasticsearch-7.8.1-linux-x86_64.tar.gz上传到/opt目录下
cd /opt
tar -zxvf elasticsearch-7.8.1-linux-x86_64.tar.gz
mv elasticsearch-7.8.1 elasticsearch7.8
useradd jamysong
chown -R jamysong:jamysong  /opt/elasticsearch7.8

注意:做完以上四步重启下三台服务器

3、安装elasticsearch

(1) 编辑elasticsearch配置文件

vim /opt/elasticsearch7.8/cong/elasticsearch.yaml

node1的配置文件

linux 复制代码
cluster.name: cluster-jamysong
node.name: node-1
network.host: linux1
node.master: true
node.data: true
http.port: 9200 
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
cluster.initial_master_nodes: ["node-1"]
discovery.seed_hosts: ["linux1:9300", "linux2:9300","linux3:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
cluster.routing.allocation.cluster_concurrent_rebalance: 16
cluster.routing.allocation.node_concurrent_recoveries: 16
cluster.routing.allocation.node_initial_primaries_recoveries: 16

node2的配置文件

linux 复制代码
cluster.name: cluster-jamysong
node.name: node-2
network.host: linux2
node.master: true
node.data: true
http.port: 9200 
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
cluster.initial_master_nodes: ["node-1"]
discovery.seed_hosts: ["linux1:9300", "linux2:9300","linux3:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
cluster.routing.allocation.cluster_concurrent_rebalance: 16
cluster.routing.allocation.node_concurrent_recoveries: 16
cluster.routing.allocation.node_initial_primaries_recoveries: 16

node3的配置文件

linux 复制代码
cluster.name: cluster-jamysong
node.name: node-3
network.host: linux3
node.master: true
node.data: true
http.port: 9200 
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
cluster.initial_master_nodes: ["node-1"]
discovery.seed_hosts: ["linux1:9300", "linux2:9300","linux3:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
cluster.routing.allocation.cluster_concurrent_rebalance: 16
cluster.routing.allocation.node_concurrent_recoveries: 16
cluster.routing.allocation.node_initial_primaries_recoveries: 16
(2)启动elasticsearch

现在直接去启动每台服务器上面的elasticsearch

复制代码
su jamysong
cd /opt/elasticsearch7.8/bin
./elasticsearch

注意:elasticsearch是不允许root用户启动的,这里使用上面创建的安装用户(jamysong)启动

!

查看启动日志如下,表示启动成功!

(3)检测elasticsearch集群

这里可以直接访问浏览器来检测一下集群是否搭建成功,这里可以看到node-1是主节点,node-2和node-3是从节点

相关推荐
weixin_549808363 小时前
以运营为核心的智能劳动力管理系统,破解连锁零售、制造业排班难题
大数据·人工智能·零售
SunTecTec4 小时前
Flink Docker Application Mode 命令解析 - 修改命令以启用 Web UI
大数据·前端·docker·flink
喜欢猪猪5 小时前
系统架构师---基于规则的系统架构
大数据·elasticsearch·搜索引擎
2401_871290585 小时前
如何在idea中写spark程序
大数据·spark·intellij-idea
小吕学编程5 小时前
ES练习册
java·前端·elasticsearch
三块钱07946 小时前
【原创】从s3桶将对象导入ES建立索引,以便快速查找文件
大数据·elasticsearch·搜索引擎·s3
拓端研究室TRL7 小时前
PyMC+AI提示词贝叶斯项目反应IRT理论Rasch分析篮球比赛官方数据:球员能力与位置层级结构研究
大数据·人工智能·python·算法·机器学习
漂流瓶6666668 小时前
如何搭建spark yarn 模式的集群
大数据·spark·eclipse
啊喜拔牙9 小时前
如何搭建spark yarn模式的集群
大数据·分布式·spark
Elasticsearch9 小时前
Elastic Security 简化了预构建 SIEM 检测规则的自定义
elasticsearch