一)下载:
elk系列下载地址: https://www.elastic.co/cn/downloads
国内下载镜像:https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/yum/
二)安装
企业最佳安装实践为rpm包方式安装,通过脚本批量快速部署。
1)RPM包安装方式
rpm安装方式:
wget https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/yum/7.4.2/elasticsearch-7.4.2-x86_64.rpm
rpm -ivh elasticsearch-7.4.2-x86_64.rpm
2)yum安装方式
有启动控制脚本比较方便。如果换成国内yum源仍旧慢,则还是使用rpm包安装方式吧
增加yum仓库:[很遗憾的是国内几乎没法下载,改成清华的源吧]
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch cat >> /etc/yum.repos.d/elk.repo << EOF [elastic-7.x] name=Elastic 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=1 autorefresh=1 type=rpm-md EOF
# 清华yum源,速度也不咋地,还是下载rpm包安装吧
cat >> /etc/yum.repos.d/elk.repo << EOF [elastic-7.x] name=Elastic repository for 7.x packages baseurl=https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/yum/ gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md EOF
yum install -y elasticsearch
三)配置
主配置文件:/etc/elasticsearch/elasticsearch.yml
jvm.options:主要是用于调整内存es内存大小使用,实际根据内存大小进行分配。
1)单机模式
node.name: node-01 path.data: /data/elasticsearch/data path.logs: /data/elasticsearch/logs network.host: 0.0.0.0 http.port: 9200 discovery.seed_hosts: ["127.0.0.1", "[::1]"] discovery.type: single-node http.cors.enabled: true http.cors.allow-origin: "*" # 单机模式开启安全认证添加下面两行 xpack.security.enabled: true xpack.license.self_generated.type: basic
2)集群模式
集群分为多种架构,不同架构每台节点的角色不同。es节点属于哪种角色[工种]由node.data和node.master两个参数确定,两个参数根据布尔值结果有四种组合,每一种组合都确定了一种角色。
默认配置下节点同时为master和data角色,如果集群节点数不是特别多的话,比如三个es节点组成集群,这种模式可以减少运维成本。
混合模式:
cluster.name: es-pre node.name: node-01 path.data: /data/elasticsearch/data path.logs: /data/elasticsearch/logs network.host: 0.0.0.0 http.port: 9200 discovery.seed_hosts: ["172.31.71.134", "172.31.71.135","172.31.71.136"] cluster.initial_master_nodes: ["node-01"] http.cors.enabled: true http.cors.allow-origin: "*" # node.name: node-1 # 给Node起个名字,其他节点配置仅此参数不同node-1/node-2/node-3,其他都一样
data/master分离架构:
cluster.name: es-cluster node.name: es-master01 path.data: /data/elasticsearch/data path.logs: /data/elasticsearch/logs network.host: 0.0.0.0 http.port: 9200 cluster.initial_master_nodes: ["es-master01","es-master02","es-master03"] discovery.seed_hosts: ["192.168.10.21","192.168.10.22", "192.168.10.23"] http.cors.enabled: true http.cors.allow-origin: "*" # 开启安全认证添加如下 xpack.security.enabled: true xpack.license.self_generated.type: basic xpack.security.transport.ssl.enabled: true xpack.security.transport.ssl.verification_mode: certificate xpack.security.transport.ssl.keystore.path: elastic-certificates.p12 xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
除了node.name之外其他配置都一样
如集群节点数比较多,建议master单独部署。此时需要明确声明该节点的角色。
1. master node:
node.master: true
node.data: false
2. data node:
node.master: false
node.data: true
默认情况下虽然没有配置这两个参数,实际上相当于两个参数都为true
还没有评论,来说两句吧...