ElasticSearch集群环境搭建

1、准备三台服务器

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

IP地址主机名节点名
192.168.225.65linux1node-1
192.168.225.66linux2node-2
192.168.225.67linux3node-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的配置文件

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的配置文件

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的配置文件

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
当前窗口启动es(es服务会随着终端退出停止运行)
./elasticsearch
后台启动es(这种方式不会因为关闭当前终端窗口而停止es服务运行)
nohup  ./elasticsearch  &

注意:elasticsearch是不允许root用户启动的,这里使用上面创建的安装用户(jamysong)启动
!
在这里插入图片描述

查看启动日志如下,表示启动成功!
在这里插入图片描述

(3)检测elasticsearch集群

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

下雨天的太阳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值