我已经买了一年的腾讯云轻量级服务器,并且安装好了ES,也做了一些系统配置,比如 修改vm.max_map_count修改文件描述符数量

同时,也用ES安装目录下的 bin/elasticsearch 脚本尝试了第一次启动 ES,并且用 https://localhost:9200 来访问它。

本文,我打算在我的腾讯云服务器上搭一个双节点的环境,并且用上 kibana 来管理。

网上给出了两种方案:

  1. 把 elasticsearch.tar.gz 解压多次到不同的文件夹,每个文件夹作为一个节点,然后分别修改每个文件夹中的 elasticsearch.yml,再分别启动。比如 Elasticsearch 在本地单机多节点部署集群
  2. 把 elasticsearch.tar.gz 解压一次,然后准备多个YAML配置文件,然后启动时,每个节点用上不同的配置文件。比如 配置Elasticsearch

我倾向于第2种,可以把集群中的各个节点的配置文件放到一个文件夹下,方便查看。

1. 查看可执行文件 elasticsearch

使用命令 more bin/elasticsearch 查看启动脚本,如下图所示:

从启动脚本 elasticsearch 的头部注释可以看出,可以使用

ES_PATH_CONF=/path/to/custom/config ./bin/elasticsearch

这样的命令来指定启动节点时,使用不同的配置文件!

有了思路之后,接下来就开始实践。

2. 准备两个配置文件

配置项 节点1 节点2
节点名称 node1 node2
配置文件目录 /opt/config/es-cluster/node1/ /opt/config/es-cluster/node2/
data目录 /var/lib/es-cluster/node1 /var/lib/es-cluster/node2
log目录 /var/log/es-cluster/node1 /var/log/es-cluster/node2

执行以下命令创建目标文件夹和文件:

[lighthouse@centos ~]$ cd /opt
[lighthouse@centos opt]$ sudo mkdir config
[lighthouse@centos opt]$ cd config
[lighthouse@centos config]$ sudo mkdir es-cluster
[lighthouse@centos config]$ sudo chown elastic:elastic es-cluster/
[lighthouse@centos config]$ ls -al
total 12
drwxr-xr-x 3 root root 4096 0ct 9 17:59 .
drwxr-xr-x. 6 root root 4096 0ct 9 17:59 ..
drwxr-xr-x. 2 elastic elastic 4096 0ct 9 17:59 es-cluster
[lighthouse@centos config]$ su elastic
Password:
[elastic@centos config]$ cd es-cluster
[elastic@centos es-cluster]$ mkdir node1
[elastic@centos es-cluster]$ mkdir node2
[elastic@centos es-cluster]$ touch node1/elasticsearch.yml
[elastic@centos es-cluster]$ touch node2/elasticsearch.yml
[elastic@centos es-cluster]$ exit
[lighthouse@centos es-cluster]$ cd /var/lib
[lighthouse@centos lib]$ sudo mkdir es-cluster
[lighthouse@centos lib]$ cd es-cluster
[lighthouse@centos es-cluster]$ sudo mkdir node1
[lighthouse@centos es-cluster]$ sudo mkdir node2
[lighthouse@centos es-cluster]$ cd ..
[lighthouse@centos lib]$ sudo chown -R elastic:elastic es-cluster/
[lighthouse@centos lib]$ cd /var/log
[lighthouse@centos log]$ sudo mkdir es-cluster
[lighthouse@centos log]$ cd es-cluster
[lighthouse@centos es-cluster]$ sudo mkdir node1
[lighthouse@centos es-cluster]$ sudo mkdir node2
[lighthouse@centos es-cluster]$ cd ..
[lighthouse@centos log]$ sudo chown -R elastic:elastic es-cluster/

修改 node1/elasticsearch.yml 内容如下:

cluster.name: es-cluster
node.name: node1
node.roles: ["master", "data", "ingest"]
network.host: 10.0.4.10
http.port: 9200
transport.port: 9300
path:
data: /var/lib/es-cluster/node1
logs: /var/log/es-cluster/node1
discovery.seed_hosts:
- 10.0.4.10:9300
- 10.0.4.10:9301
cluster.initial_master_nodes:
- node1
- node2
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false

修改 node2/elasticsearch.yml 内容如下:

cluster.name: es-cluster
node.name: node2
node.roles: ["master", "data", "ingest"]
network.host: 10.0.4.10
http.port: 9201
transport.port: 9301
path:
data: /var/lib/es-cluster/node2
logs: /var/log/es-cluster/node2
discovery.seed_hosts:
- 10.0.4.10:9300
- 10.0.4.10:9301
cluster.initial_master_nodes:
- node1
- node2
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false

3. 启动两个es实例

[lighthouse@centos es-cluster]$ su elastic
Password:
[elastic@centos es-cluster]$ cd /opt/elasticsearch-8.1.0
[elastic@centos elasticsearch-8.1.0]$ ES_PATH_CONF=/opt/config/es-cluster/node1 ES_JAVA_OPTS="-Xms256m -Xmx256m" ./bin/elasticsearch -d
[elastic@centos elasticsearch-8.1.0]$ ES_PATH_CONF=/opt/config/es-cluster/node2 ES_JAVA_OPTS="-Xms256m -Xmx256m" ./bin/elasticsearch -d

首次尝试启动时,遇到异常报错 Exception in thread "main" java.nio.file.NoSuchFileException: /opt/config/es-cluster/node1/jvm.options

于是,执行命令拷贝 jvm.options 文件:

[elastic@centos elasticsearch-8.1.0]$ cp config/jvm.options /opt/config/es-cluster/node1
[elastic@centos elasticsearch-8.1.0]$ cp config/jvm.options /opt/config/es-cluster/node2

类似地,还会出现错误 ERROR: no log4j2.properties found; tried [/opt/config/es-cluster/node2] and its subdirectories

因此,执行命令拷贝 log4j2.properties 文件:

[elastic@centos elasticsearch-8.1.0]$ cp config/log4j2.properties /opt/config/es-cluster/node1
[elastic@centos elasticsearch-8.1.0]$ cp config/log4j2.properties /opt/config/es-cluster/node2

4. Kibana

4.1 下载Kibana

https://www.elastic.co/cn/downloads/past-releases#kibana

选择:8.1.0版本下载,如下图所示:

选择:LINUX_X86_64,如下图所示:

解压并把 kibana 移动到目标文件夹:

[lighthouse@centos Downloads]$ tar -zxvf kibana-8.1.0-linux-x86_64.tar.gz
[lighthouse@centos Downloads]$ sudo mv kibana-8.1.0 /opt/kibana-8.1.0

4.2 修改kibana.yml配置

使用命令 cd /opt/kibana-8.1.0/config 进入配置文件夹,再用命令 vim kibana.yml 修改文件

server.port: 5601
server.host: "10.0.4.10"
elasticsearch.hosts: ["http://10.0.4.10:9200"]
server.publicBaseUrl: "http://10.0.4.10:5601"

server.publicBaseUrl is missing and should be configured when running in a production environment. Some features may not behave correctly. See the documentation.

报错解决方案

4.3 启动kibana

nohup ./bin/kibana --allow-root & > /dev/null 2>&1

kibana 使用 ps -ef|grep kibana查不到进程的,主要原因大概是因为 kibananode 写的。所以 kibana 运行的时候是运行在 node 里面。

所以,可以使用 ps -ef|grep node 查看到进程。

kibana 启动成功后,可以在浏览器中访问:

选择 Explore on my own,新手暂时不需要添加整合 Add integrations

2. 单主机 Elasticsearch 双节点或多节点集群环境部署的更多相关文章

  1. MySQL+MGR 单主模式和多主模式的集群环境 - 部署手册 (Centos7.5)

    MySQL Group Replication(简称MGR)是MySQL官方于2016年12月推出的一个全新的高可用与高扩展的解决方案.MGR是MySQL官方在5.7.17版本引进的一个数据库高可用与 ...

  2. Centos7.5基于MySQL5.7的 InnoDB Cluster 多节点高可用集群环境部署记录

    一.   MySQL InnoDB Cluster 介绍MySQL的高可用架构无论是社区还是官方,一直在技术上进行探索,这么多年提出了多种解决方案,比如MMM, MHA, NDB Cluster, G ...

  3. Kafka 单节点多Kafka Broker集群

    Kafka 单节点多Kafka Broker集群 接前一篇文章,今天搭建一下单节点多Kafka Broker集群环境. 配置与启动服务 由于是在一个节点上启动多个 Kafka Broker实例,所以我 ...

  4. windows单节点下安装es集群

    linux下的es的tar包,拖到windows下,配置后,启动bin目录下的bat文件,也是可以正常运行的. 从linux下拷的tar包,需要修改虚拟机的内存elasticsearch.in.bat ...

  5. redhat6.5 redis单节点多实例3A集群搭建

    在进行搭建redis3M 集群之前,首先要明白如何在单节点上完成redis的搭建. 单节点单实例搭建可以参看这个网:https://www.cnblogs.com/butterflies/p/9628 ...

  6. ElasticSearch高可用集群环境搭建和分片原理

    1.ES是如何实现分布式高并发全文检索 2.简单介绍ES分片Shards分片技术 3.为什么ES主分片对应的备分片不在同一台节点存放 4.索引的主分片定义好后为什么不能做修改 5.ES如何实现高可用容 ...

  7. ELK 中的elasticsearch 集群的部署

    本文内容 背景 ES集群中第一个master节点 ES slave节点 本文总结 Elasticsearch(以下简称ES)搭建集群的经验.以 Elasticsearch-rtf-2.2.1 版本为例 ...

  8. Redis 单例、主从模式、sentinel 以及集群的配置方式及优缺点对比(转)

    摘要: redis作为一种NoSql数据库,其提供了一种高效的缓存方案,本文则主要对其单例,主从模式,sentinel以及集群的配置方式进行说明,对比其优缺点,阐述redis作为一种缓存框架的高可用性 ...

  9. ElasticSearch 5.2.2 集群环境的搭建

    在之前 ElasticSearch 搭建好之后,我们通过 elasticsearch-header 插件在查看 ES 服务的时候,发现 cluster-health 显示的是 YELLOW. Why? ...

随机推荐

  1. Ubu18远程登录密匙设置

    Ubu18设置远程密匙登录 相关文件 /etc/ssh/sshd_config 注意vscode使用博客园插件需要进行端口转发,在vscode端口处设置41385 本地生成密匙,任选一种,这里只介绍第 ...

  2. 【P1809 过河问题】题解

    贪心,我们设时间序列为 \(\{a_i\}\),长度为 \(n\)(先排序 \(\{a_i\}\)). 分类讨论(其中的「\(1\)」「\(2\)」等均指「速度第 \(1\) 人」「速度第 \(2\) ...

  3. .NET性能优化-使用SourceGenerator-Logger记录日志

    前言 在现在许许多多的应用系统中,日志非常关键,它即是排查问题的强力工具,也是程序员居家旅行工作甩锅必备良品. 在团队中编码中,我们都要求对于那些会变更数据的接口.调用第三方的接口记录请求和响应参数, ...

  4. 后端Python3+Flask结合Socket.io配合前端Vue2.0实现简单全双工在线客服系统

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_158 在之前的一篇文章中:为美多商城(Django2.0.4)添加基于websocket的实时通信,主动推送,聊天室及客服系统,详 ...

  5. Python3的单元测试模块Mock与性能测试模块CProfile

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_92 我们知道写完了代码需要自己跑一跑进行测试,一个写好的程序如果连测试都没有就上到生产环境是不敢想象的,这么做的人不是太自信就是太 ...

  6. 学python,怎么能不学习scrapy呢!

    摘要:本文讲述如何编写scrapy爬虫. 本文分享自华为云社区<学python,怎么能不学习scrapy呢,这篇博客带你学会它>,作者: 梦想橡皮擦 . 在正式编写爬虫案例前,先对 scr ...

  7. eplan中数据库运行提速

    access,sql,是指部件库的存储方式,eplan支持两种方式即Microsoft Office access,Microsoft SQL Server,可以通过这两种方式打开部件库,如果要打开数 ...

  8. Serverless之Knative部署应用实例;

    1.什么是Knative? Knative是Google2018的Google Cloud Next大会上发布的一款基于kubernetes的Serverless框架. knative的目的是在kub ...

  9. 深入理解Aarch64内存管理

    本文是对learn_the_architecture_-_aarch64_memory_management的部分翻译和个人注解.个人英文水平有限,若有翻译不当,欢迎加我私人微信LinuxDriver ...

  10. day21--Java集合04

    Java集合04 9.Set接口方法 Set接口基本介绍 无序(添加和取出的顺序不一致),没有索引 不允许重复元素,所以最多只有一个null JDK API中接口的实现类有: Set接口的常用方法:和 ...