准备:
elasticsearch-7.15.0-x86_64.rpm
kibana-7.15.0-x86_64.rpm
注:一定要同版本
三台服务器(虚拟ip)
192.168.21.11
192.168.21.12
192.168.21.13
关闭防火墙(所有):
启动:systemctl start firewalld
关闭:systemctl stop firewalld
查看状态:systemctl status firewalld
开机禁用:systemctl disable firewalld
开机启用:systemctl enable firewalld
安装步骤首先安装Elasticsearch(所有))
使用命令
rpm -ivh elasticsearch-7.15.0-x86_64.rpm
进行安装安装后
执行命令进行启动
systemctl start elasticsearch.service
启动成功后执行命令
curl 192.168.21.11:9200
返回如下表示成功
按照如下修改配置文件 /etc/elasticsearch (所有节点)
# ======================== 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-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
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: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- 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: ["192.168.21.11:9300", "192.168.21.12:9300","192.168.21.13:9300"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["192.168.21.11:9300"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
其中 cluster.name :集群名 (注:需三台全部一致)
node.name:节点名 (注:三台不能一致)
discovery.seed_hosts:所有节点的ip
cluster.initial_master_nodes: master预选节点 只有master配置就行 只需一个节点配
其余按文档固定配置就可以,配置完成后执行命令(所有)
/etc/security/limits.conf文件下end前添加:
* soft nofile 65536
* hard nofile 65536
添加后执行:
echo 'vm.max_map_count=655360' >> /etc/sysctl.conf
#查看配置,如果未生效重启配置
ulimit -n
修改后执行命令重启(所有)
systemctl restart elasticsearch.service
重启后,在网页执行
http://192.168.21.11:9200/_cluster/state?pretty
得到如图结果
表示集群配置完毕。
接下来安装Kibana (选择一台进行安装即可)
使用命令安装rpm
rpm -ivh kibana-7.15.0-x86_64.rpm
安装后修改kibana.yml配置文件使用如下配置:
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]
i18n.locale: "zh-CN"
配置完成执行命令进行启动
//启动服务
systemctl start kibana.service
//查看状态
systemctl status kibana.service
//停止服务
systemctl stop kibana.service
启动后通过 http://192.186.21.11:5601/ 进行访问
附录
访问后可通过
栏输入
GET /_cat/nodes?v
查询当前集群节点。
通过执行如下命令设置开机自启动:
// kibana 设置服务开机自启
systemctl enable kibana.service
// es 开机自启
systemctl daemon-reload
systemctl enable elasticsearch.service