elasticsearch 8.17.3部署文档

elasticsearch 8.17.3部署文档

一、架构拓扑

ip 主机名 角色
192.168.241.151 slave1 master
192.168.241.152 slave2 node1
192.168.241.153 slave3 node2

二、安装包下载------分别下载上传至所有的节点

下载地址https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.17.3-linux-x86_64.tar.gz

shell 复制代码
##可以使用wget
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.17.3-linux-x86_64.tar.gz

三、master节点部署

3.1 调整服务器参数
shell 复制代码
 cat >> /etc/security/limits.conf << EOF
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
EOF
echo "vm.max_map_count=655360" >> /etc/sysctl.conf
sysctl  -p
useradd elastic
echo "elastic" | passwd --stdin elastic
3.2 解压并赋权
shell 复制代码
tar xf elasticsearch-8.17.3-linux-x86_64.tar.gz  -C /opt/
ln -s /opt/elasticsearch-8.17.3 /opt/elasticsearch
chown -R elastic:elastic /opt/elasticsearch*
su elastic
cd /opt/elasticsearch
3.3 修改配置文件

vi /opt/elasticsearch/config/elasticsearch.yml

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: myes
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: slave1
#
# 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: /home/elastic/es/data
#
# Path to log files:
#
path.logs: /home/elastic/es/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:
#
network.host: 0.0.0.0
#
# 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: ["slave1", "slave2", "slave3"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["slave1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false
3.4 启动es-master
shell 复制代码
/opt/elasticsearch/bin/elasticsearch

显示下图表示初始化成功,图中包含账号密码

浏览器输入https://192.168.241.150:9200验证

输入账号elastic

密码BOOIaTVR1B78EqALY*e1

3.5 调整配置

首次启动使用/opt/elasticsearch/bin/elasticsearch命令可以帮助我们自动生成证书以及账号密码,若使用其他命令需要自己使用bin/elasticsearch-reset-password -u elastic设置密码

启动后可以查看配置文件目录会生成certs目录

使用ctrl + c 退出 ,查看新的配置文件注释掉cluster.initial_master_nodes: ["slave1"]

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: myes
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: slave1
#
# 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: /home/elastic/es/data
#
# Path to log files:
#
path.logs: /home/elastic/es/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:
#
network.host: 0.0.0.0
#
# 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: ["slave1", "slave2", "slave3"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["slave1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically
# generated to configure Elasticsearch security features on 11-03-2025 12:44:07
#
# --------------------------------------------------------------------------------

# Enable security features
xpack.security.enabled: true

xpack.security.enrollment.enabled: true

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
#----------------------- END SECURITY AUTO CONFIGURATION -------------------------
3.6 后台重新启动
shell 复制代码
cd /opt/elasticsearch
nohup ./bin/elasticsearch > logs/elasticsearch.log 2>&1 &

4 从节点部署

4.1 调整服务器参数

同3.1

4.2 解压并赋权

同3.2

4.3 修改配置文件

vi /opt/elasticsearch/config/elasticsearch.yml

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: myes
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: slave2
node.roles: [ data, ingest ]
#
# 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: /home/elastic/es/data
#
# Path to log files:
#
path.logs: /home/elastic/es/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:
#
network.host: 0.0.0.0
#
# 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: ["slave1", "slave2", "slave3"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["slave1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically
# generated to configure Elasticsearch security features on 11-03-2025 12:44:07
#
# --------------------------------------------------------------------------------

# Enable security features
xpack.security.enabled: true

xpack.security.enrollment.enabled: true

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
#----------------------- END SECURITY AUTO CONFIGURATION -------------------------
4.4 获取master相关认证密码------master节点

在slave1节点把证书拷贝到其他节点

shell 复制代码
scp -r /opt/elasticsearch/config/certs slave2:/opt/elasticsearch/config/
/opt/elasticsearch/bin/elasticsearch-keystore list
/opt/elasticsearch/bin/elasticsearch-keystore show xpack.security.http.ssl.keystore.secure_password
/opt/elasticsearch/bin/elasticsearch-keystore show xpack.security.transport.ssl.keystore.secure_password
/opt/elasticsearch/bin/elasticsearch-keystore show xpack.security.transport.ssl.truststore.secure_password
4.5 slave节点加载密码------slave节点
shell 复制代码
/opt/elasticsearch/bin/elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
/opt/elasticsearch/bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
/opt/elasticsearch/bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password
4.6 启动slave节点
shell 复制代码
nohup /opt/elasticsearch/bin/elasticsearch > /opt/elasticsearch/logs/elasticsearch.log 2>&1 &

5 浏览器使用elasticvue查看es集群状态

5.1 在浏览器点击扩展,搜索elasticvue
5.2 获取添加扩展
5.3 连接集群

成功

相关推荐
SelectDB3 小时前
SelectDB 实时分析性能突出,宝舵成本锐减与性能显著提升的双赢之旅
大数据·数据库·数据分析
BigBookX3 小时前
通过 ElasticSearch的Python API和`curl` 命令获取Elasticsearch 所有索引名称
大数据·elasticsearch·jenkins
kcarly4 小时前
N-Triples, Turtle, RDF/XML 都是什么?还有其他类似的么?
大数据·知识图谱·turtle·rdf·rdf格式·n-triples
Fulima_cloud5 小时前
智慧锂电:开启能源新时代的钥匙
大数据·人工智能·物联网
jinan8866 小时前
车间图纸安全传输需要注意什么?
大数据·运维·服务器·安全
阿里云大数据AI技术7 小时前
Hologres 计算组实例&分时弹性入门实践
大数据·serverless
港股研究社7 小时前
重估首程控股:一只产业生态完整的“机器人ETF”
大数据·人工智能·机器人
atbigapp.com8 小时前
AI数据分析:一键生成可视化分析思路
大数据·人工智能·数据分析
叶域9 小时前
正则表达式(复习)
大数据·python·正则表达式