离线部署Elasticsearch集群

准备条件

三台服务器:
172.16.72.201   
172.16.72.202  
172.16.72.203 

es下载
官网下载地址:elasticsearch-7.16.3-linux-x86_64.tar.gz

一. 服务器配置

1. 配置服务器,设置固定IP

根据自己需求设置ip我的设置的是172.16.72.*网段
vi /etc//sysconfig/network-scripts/ifcfg-ens33

修改BOOTPROTO=“dhcp” 为 BOOTPROTO=“static”
添加 IPADDR、GATEWAY、NETMASK

IPADDR="172.16.72.201"
GATEWAY="172.16.72.1"
NETMASK="255.255.255.0"

在这里插入图片描述

2. 关闭防火墙

为了简单操作直接关闭了防火墙,用户可根据实际情况如不能关闭防火墙可开启3306与8848端口

systemctl stop firewalld

3. 服务器分配

172.16.72.201    es1   
172.16.72.202    es2
172.16.72.203    es3

二. 部署Java

1. 下载Java

1.1 官网下载
1.2 百度云下载jdk-8u301-linux-x64.tar.gz 提取码: 6a95

2. 上传172.16.72.201服务器的/usr/local/下解压

```
cd /usr/local/
tar -zxvf jdk-8u301-linux-x64.tar.gz
```

3. 修改/etc/profile

```
vi /etc/profile
```

在文件末尾添加
#JAVA_HOME export JAVA_HOME=/usr/local/jdk1.8.0_301 export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin

4. 刷新

```
source /etc/profile 
```

5. 在172.16.72.202、172.16.72.203服务器上执行步骤2、3、4

三. 部署es

1. 解压es至/usr/local/下 修改文件名为 elasticsearch

```
tar -zxvf elasticsearch-7.16.3-linux-x86_64.tar.gz 
mv elasticsearch-7.16.3-linux-x86_64 elasticsearch
```

2. 新建elasticsearch用户 并将elasticsearch文件夹赋予elasticsearch用户权限

```
useradd elasticsearch
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch 
```

3. 修改配置文件

3.1 修改elasticsearch.yml

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# 集群名称 三台服务器相同
cluster.name: es-study
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# 此参数集群唯一 linux102服务器为  node-2  linux103服务器为  node-3
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /usr/local/elasticsearch/data
#
# Path to log files:
#
path.logs: /usr/local/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
# 服务器本身IP
network.host: 172.16.72.101
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["172.16.72.101", "172.16.72.102","172.16.72.103"]
transport.tcp.port: 9300
transport.tcp.compress: true
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
#discovery.zen.ping.unicast.hosts: ["172.16.72.101:9200", "172.16.72.102:9200","172.16.72.103:9200"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features.
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html
#开启鉴权 
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
#xpack.security.transport.ssl.verification_mode: certificate
#xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

3.2 修改/etc/security/limits.conf 在文件末尾中增加下面内容

elasticsearch hard nofile 65536
elasticsearch soft nofile 65536

3.3 修改/etc/security/limits.d/20-nproc.conf # 在文件末尾中增加下面内容

*          soft    nproc     4096
root       soft    nproc     unlimited

3.4 修改/etc/sysctl.conf # 在文件中增加下面内容

vm.max_map_count=655360

3.5 重新加载

sysctl -p

3.6 在 linux102、linux103 服务器下执行3.2、3.3、3.4、3.5

4. 打包 elasticsearch 文件夹传输到linux102、linux103上解压 并修改 elasticsearch.yml的 node.name network.host 参数

linux102的 elasticsearch.yml配置:

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# 集群名称 三台服务器相同
cluster.name: es-study
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# 此参数集群唯一 linux102服务器为  node-2  linux103服务器为  node-3
node.name: node-2
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /usr/local/elasticsearch/data
#
# Path to log files:
#
path.logs: /usr/local/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
# 服务器本身IP
network.host: 172.16.72.102
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["172.16.72.101", "172.16.72.102","172.16.72.103"]
transport.tcp.port: 9300
transport.tcp.compress: true
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
#discovery.zen.ping.unicast.hosts: ["172.16.72.101:9200", "172.16.72.102:9200","172.16.72.103:9200"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features.
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html
#开启鉴权 
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
#xpack.security.transport.ssl.verification_mode: certificate
#xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

linux103的 elasticsearch.yml配置:

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# 集群名称 三台服务器相同
cluster.name: es-study
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# 此参数集群唯一 linux102服务器为  node-2  linux103服务器为  node-3
node.name: node-3
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /usr/local/elasticsearch/data
#
# Path to log files:
#
path.logs: /usr/local/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
# 服务器本身IP
network.host: 172.16.72.103
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["172.16.72.101", "172.16.72.102","172.16.72.103"]
transport.tcp.port: 9300
transport.tcp.compress: true
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
#discovery.zen.ping.unicast.hosts: ["172.16.72.101:9200", "172.16.72.102:9200","172.16.72.103:9200"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features.
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html
#开启鉴权 
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
#xpack.security.transport.ssl.verification_mode: certificate
#xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

四. 启动服务器

  1. 切换 elasticsearch用户 进入 /usr/local/elasticsearch下执行 ./bin/elasticsearch -d
    su elasticsearch
    cd  /usr/local/elasticsearch
    ./bin/elasticsearch -d
    
  2. 在linux102、linux103上执行上述操作
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值