CentOS7安装elasticsearch-8.5.3集群、kibana-8.5.3

一、官网下载elasticsearch-8.5.3和kibana-8.5.3 linux下的安装包

注意:安装前要确定系统安装了JDK8环境

官网下载地址:https://www.elastic.co/cn/downloads/?elektra=home&storm=hero

CentOS7安装elasticsearch-8.5.3集群、kibana-8.5.3_第1张图片
CentOS7安装elasticsearch-8.5.3集群、kibana-8.5.3_第2张图片

二、安装elasticseatch

2.1 将压下载的压缩包上传到linux系统的 /opt 目录下

2.2 在 /opt 目录下创建soft目录并解压 elasticsearch

下面我将 elasticsearch 简称为 es 哈

#创建soft目录
mkdir soft

#解压elasticsearch-8.5.3-linux-x86_64.tar.gz
tar -zxvf elasticsearch-8.5.3-linux-x86_64.tar.gz

#解压的es目录移动到 soft 目录下
mv elasticsearch-8.5.3  soft/

2.3 在es目录下创建 数据目录 data 和日志目录 logs

#切换到es目录下
cd /opt/soft/elasticsearch-8.5.3

#新建data和logs目录
mkdir data
mkdir logs

2.4 因为es不允许用root用户启动,所以创建用户es

#创建用户组与用户
groupadd es
useradd es -g es -p es

#给es目录授权
chown -R es:es /opt/soft/elasticsearch-8.5.3/

2.5 修改用户资源限制

vim /etc/security/limits.conf

添加以下内容

* hard nofile 65536
* soft nofile 131072
* hard nproc 4096
* soft nproc 4096

2.6 修改系统配置

vim /etc/sysctl.conf

添加

fs.file-max=655360
vm.max_map_count=655360

2.7 使以上修改生效

/sbin/sysctl -p

2.8 修改 config/elasticsearch.yml 文件

配置如下

我虚拟机中三个centos系统IP是:192.168.29.188 , 192.168.29.189 , 192.168.29.190;你们根据自己系统IP修改哈

#集群名称
cluster.name: my-app
#节点名称
node.name: node-1
#节点角色
node.roles: [master,data]
path.data: /opt/soft/elasticsearch-8.5.3/data
path.logs: /opt/soft/elasticsearch-8.5.3/logs
#绑定的IP
network.host: 192.168.29.188
#暴露的http端口
http.port: 9200
#使用head等插件监控集群信息,需要打开以下配置项
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#集群成员
discovery.seed_hosts: ["192.168.29.188:9300","192.168.29.189:9300","192.168.29.190:9300"]
cluster.initial_master_nodes: ["node-1"]

# 注意这里改成false
xpack.security.enabled: false

xpack.security.enrollment.enabled: true

# 注意这里改成false
xpack.security.http.ssl:
  enabled: false
  keystore.path: certs/http.p12

# 注意这里改成false
xpack.security.transport.ssl:
  enabled: false
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12

完整配置如下

# ======================== 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-app
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
node.roles: [master,data]
#
# 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: /opt/soft/elasticsearch-8.5.3/data
#
# Path to log files:
#
path.logs: /opt/soft/elasticsearch-8.5.3/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: 192.168.29.188
#
# 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

http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#
# 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: ["192.168.29.188:9300","192.168.29.189:9300","192.168.29.190:9300"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# --------------------------------- Readiness ----------------------------------
#
# Enable an unauthenticated TCP readiness endpoint on localhost
#
#readiness.port: 9399
#
# ---------------------------------- 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 12-01-2023 02:34:39
#
# --------------------------------------------------------------------------------

# Enable security features
xpack.security.enabled: false

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

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: false
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
#----------------------- END SECURITY AUTO CONFIGURATION ------------------------

2.9 修改es目录下config目录下的jvm.options 文件

-Xms512m
-Xmx512m
CentOS7安装elasticsearch-8.5.3集群、kibana-8.5.3_第3张图片

2.10 启动es

切换到es用户

su es

进入es目录下bin目录下执行指令

./elasticsearch -d

浏览器访问 IP:9200

CentOS7安装elasticsearch-8.5.3集群、kibana-8.5.3_第4张图片

访问成功

2.11 关闭es

ps -ef | grep elasticsearch
CentOS7安装elasticsearch-8.5.3集群、kibana-8.5.3_第5张图片
kill -9 1823

三、搭建另外两个es节点

3.1将centos系统一下es目录复制到centos系统二和三


scp -r  /opt/soft/elasticsearch-8.5.3 [email protected]:/opt/soft/elasticsearch-8.5.3

scp -r  /opt/soft/elasticsearch-8.5.3 [email protected]:/opt/soft/elasticsearch-8.5.3

3.2 在centos系统二和三重复2.4 2.5 2.6 2.7 步骤

3.3 修改centos系统二和三的config/elasticsearch.yml 文件

只需修改以下部分

node.name: node-2
network.host: 192.168.29.189

节点三亦是如此

node.name: node-3
network.host: 192.168.29.190

3.4 查看集群节点数

启动系统二三的es

浏览输入(换成你的IP):http://192.168.29.188:9200/_cat/nodes

CentOS7安装elasticsearch-8.5.3集群、kibana-8.5.3_第6张图片

浏览器显示三个节点

四、安装Kibana-8.5.3

4.1 安装kibana

解压压缩包

tar -zxvf kibana-8.5.3-linux-x86_64.tar.gz

移动到 /opt/soft 目录下

mv kibana-8.5.3  soft/

授权

chown -R es:es kibana-8.5.3/

切换到es用户

su es

修改 kibana-8.5.3 目录下 config 目录下 kibana.yml 文件

server.port: 5601

server.host: "192.168.29.188"

elasticsearch.hosts: ["http://192.168.29.188:9200","http://192.168.29.189:9200","http://192.168.29.190:9200"]

i18n.locale: "zh-CN"

进入kibana目录,启动kibana

nohup ./bin/kibana > kibana.log 2>&1 &

浏览器输入:http://192.168.29.188:5601/

CentOS7安装elasticsearch-8.5.3集群、kibana-8.5.3_第7张图片

看到如上界面,即安装启动成功

4.2 杀死kibana进程

netstat -tunlp | grep 5601
#1953是进程号  看上截图
kill -9 1953

你可能感兴趣的:(中间件,elasticsearch)