Centos elasticsearch 7.16 集群搭建

官方指引:​​​​​​Install Elasticsearch with RPM | Elasticsearch Guide [7.16] | Elastic

准备3台虚拟机centos7,每个虚拟机挂一块硬盘/esdata。按照官方指引安装

挂载硬盘、开防火墙等参考:Centos8 常用_leoppeng的专栏-CSDN博客

1、

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

2、vim常用的功能要熟,编辑文件会用到

vim /etc/yum.repos.d/elasticsearch.repo

[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md

3、

sudo yum install --enablerepo=elasticsearch elasticsearch

到这就算安装完成、接下来是配置

给elasticsearch用户授权、安装的时候创建的

chown -R elasticsearch:elasticsearch /esdata

修改配置文件,多台机器节点配置文件基本一样:

节点名称(node.name)和节点网络(network.host)改成各个虚拟机的

数据目录(path.data)和日志(path.logs)改成实际的路径

集群名称(cluster.name)一致

discovery.seed_hosts 把所有节点的ip加进来

cluster.initial_master_nodes 主节点

vim /etc/elasticsearch/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: my-cluster-yq
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-222
#
# 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: /esdata/data
#
# Path to log files:
#
path.logs: /esdata/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: 10.10.30.222
#
# 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: ["10.10.30.220:9300", "10.10.30.221:9300","10.10.30.222:9300"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-220", "node-221","node-222"]
#
# 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

设置防火墙、开9200和9300端口号。

然后启动

systemctl start elasticsearch
systemctl enable elasticsearch

浏览器输入http://ip:9200.出现如下界面说明已成功

Centos elasticsearch 7.16 集群搭建_第1张图片

输入如下连接http://ip:9200/_cat/health?v​,查看集群状态

Centos elasticsearch 7.16 集群搭建_第2张图片

输入如下连接http://ip:9200/_cat/nodes?v查看节点情况

 Centos elasticsearch 7.16 集群搭建_第3张图片

 可以看到222是主节点。

用yum的安装方式,比较方便。如果自己下载压缩包,解压,创建启动用户、设置权限、编写服务脚本会很麻烦。稍微不注意就会出问题。用yum安装,这些工作都自动完成了

我们查看服务启动脚本可以看到:/usr/lib/systemd/system/elasticsearch.service

如果自己安装是要去修改系统的配置文件的

Centos elasticsearch 7.16 集群搭建_第4张图片

 后期实际使用过程,再记录相关问题和优化配置

你可能感兴趣的:(系统配置,elasticsearch,big,data,大数据)