elasticsearch(es)的安装-macOs

elasticsearch(es)的安装-macOs前提:已经安装过jdk1.8java-version#查看jdk版本1.es的安装和访问es安装brewinstallelasticsearch#安装brewinfoelasticsearch#查看es信息brewservicesstartelasticsearch#启动浏览器输入:localhost:9200查看es2.kibana的安装和访问kibana可以通过可视化的界面操作访问eskibana安装brewinstallkiban

大家好,又见面了,我是你们的朋友全栈君。

前提:已经安装过jdk1.8

java -version #查看jdk版本 

在这里插入图片描述

1.es的安装和访问

es安装

brew install elasticsearch #安装
brew info elasticsearch # 查看es信息
brew services start elasticsearch # 启动

在这里插入图片描述
浏览器输入:localhost:9200 查看es
在这里插入图片描述

2.kibana的安装和访问

kibana可以通过可视化的界面操作访问es

  • kibana安装
brew install kibana #安装
brew info kibana # 查看信息
brew services start kibana #启动
  • kibana访问:浏览器访问 localhost:5601,找到开发工具(Dev Tools),向es中插入数据&搜索数据
    在这里插入图片描述

3.es集群搭建

之前是通过brew命令安装的es,虽然一键很爽,但是要搭建集群,按照下述文章搭建单机版es集群的说法,需要找到安装包

## 查看全部安装路径
brew list 
## 查看指定软件安装路径
brew list 软件名 

实战

brew list elasticsearch
## 结果
/usr/local/Cellar/elasticsearch/7.10.2/.bottle/etc/ (3 files)
/usr/local/Cellar/elasticsearch/7.10.2/bin/elasticsearch
/usr/local/Cellar/elasticsearch/7.10.2/bin/elasticsearch-keystore
/usr/local/Cellar/elasticsearch/7.10.2/bin/elasticsearch-plugin
/usr/local/Cellar/elasticsearch/7.10.2/bin/elasticsearch-shard
/usr/local/Cellar/elasticsearch/7.10.2/homebrew.mxcl.elasticsearch.plist
/usr/local/Cellar/elasticsearch/7.10.2/libexec/bin/ (8 files)
/usr/local/Cellar/elasticsearch/7.10.2/libexec/lib/ (42 files)
/usr/local/Cellar/elasticsearch/7.10.2/libexec/modules/ (93 files)

查看通过安装包安装es的文章安装包安装es-mac,可以看到,/usr/local/Cellar/elasticsearch/7.10.2/ 其实就是安装包,试着复制,然后安装。

cp -R 7.10.2 7.10.2.backup1
cp -R 7.10.2 7.10.2.backup2

得到两个安装包的副本后,修改副本中的配置文件
但是进文件夹里看,并没有config文件夹,通过brew命令查看es安装情况,可以得到config路径:/usr/local/etc/elasticsearch/
和我假设的不一致。/usr/local/Cellar/elasticsearch/7.10.2/ 并不是安装包,只是通过brew命令后的安装路径。

brew info elasticsearch
## 结果
From:https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/elasticsearch.rb
Config:  /usr/local/etc/elasticsearch/

通过brew命令还可以得到安装包路径:https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/elasticsearch.rb 点进去后得到rul:https://github.com/elastic/elasticsearch/archive/v7.10.2.tar.gz。点击下载、解压后目录如下,也没有config目录。
在这里插入图片描述
考虑从官网下载:https://www.elastic.co/cn/start ,此时有config目录了
在这里插入图片描述
检查已有es的config文件里的cluster name。将两者修改成一致。cyx_elasticsearch

## 通过brew安装的es的yml文件,路径:/usr/local/etc/elasticsearch/
cluster.name: elasticsearch_brew
## 通过官网下载的es里的yml文件,路径:~/software/es/es-a/elasticsearch-8.0.1/config
cluster.name: my-application

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: cyx-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
# 是否有资格选举为主节点
node.master: true
# 是否存储数据
node.data: true
# 最大集群节点数
node.max_local_storage_nodes: 3
#
# 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: /Users/yuxichen/software/es/es-a/data
#
# Path to log files:
#
path.logs: /Users/yuxichen/software/es/es-a/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.0.1
#
# 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: 9201
# 内部节点之间沟通端口
transport.tcp.port: 9500
#
# 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: ["127.0.0.1:9300", "127.0.0.1:9400"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false

总结下,yml文件需要修改的配置

cluster.name: cyx-application
node.name: node-1
node.master: true
node.data: true
node.max_local_storage_nodes: 3
path.data: /Users/yuxichen/software/es/es-a/data
path.logs: /Users/yuxichen/software/es/es-a/logs
http.port: 9201
transport.tcp.port: 9500
discovery.seed_hosts: ["127.0.0.1:9200", "127.0.0.1:9201"]
cluster.initial_master_nodes: ["node-1", "node-2"]

配置完三个节点的yml后,开始关闭已经启动的es

​brew services stop elasticsearch
#输出
Stopping `elasticsearch`... (might take a while)
==> Successfully stopped `elasticsearch` (label: homebrew.mxcl.elasticsearch)

试着启动三个节点

#通过brew安装的
brew services start elasticsearch
#输出
==> Successfully started `elasticsearch` (label: homebrew.mxcl.elasticsearch)
#通过下载的安装包启动
./bin/elasticsearch
##输出
报错一:node.master设置找不到
报错二:transport.tcp.port: 设置找不到

把这些都删除后,直接在浏览器中输入localhost:9201,提示需要用户名密码,但是我又没设置过,在官网文档elasticsearch8.0.1
和网上的文档也没有找到第一次登陆需要用户名密码的原因。就在配置文件中设置了不需要鉴权
可以启动的官网下载的elasticsearch8.0.1版本的yml文件修改如下

cluster.name: cyx-application
node.name: node-1
path.data: /Users/yuxichen/software/es/es-a/data
path.logs: /Users/yuxichen/software/es/es-a/logs
http.port: 9201
cluster.initial_master_nodes: ["node-1", "node-2"]
xpack.security.enabled: false

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
接下来测试集群是否搭建成功&配置kibana
测试集群,输出结果如下,可以看出节点总数为1,所以集群没有搭建成功,需要找下原因

http://localhost:9200/_cat/health?v

在这里插入图片描述
实在是找不到原因,只好放弃8.0.1这个版本太新了,下载了稍微老一点的版本:7.16.0,按照常见文章的配置,看上去是成功了
在这里插入图片描述
配置了下kibana,然后查看集群健康,发现竟然是red,我要哭了
在这里插入图片描述
整了半天还是一直是yellow,且node-2、3启动时候报错,搞不定了,先去洗漱睡了好困啊啊啊啊

[2022-03-04T00:24:07,468][ERROR][o.e.i.g.DatabaseNodeService] [node-3] failed to download database [GeoLite2-City.mmdb]
org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];
	at org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedException(ClusterBlocks.java:179) ~[elasticsearch-7.16.0.jar:7.16.0]
	at org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedRaiseException(ClusterBlocks.java:165) ~[elasticsearch-7.16.0.jar:7.16.0]
	at org.elasticsearch.action.search.TransportSearchAction.executeSearch(TransportSearchAction.java:927) ~[elasticsearch-7.16.0.jar:7.16.0]
	at org.elasticsearch.action.search.TransportSearchAction.executeLocalSearch(TransportSearchAction.java:761) ~[elasticsearch-7.16.0.jar:7.16.0]
	at org.elasticsearch.action.search.TransportSearchAction.lambda$executeRequest$6(TransportSearchAction.java:397) ~[elasticsearch-7.16.0.jar:7.16.0]
	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) ~[elasticsearch-7.16.0.jar:7.16.0]
	at org.elasticsearch.index.query.Rewriteable.rewriteAndFetch(Rewriteable.java:112) ~[elasticsearch-7.16.0.jar:7.16.0]
	at org.elasticsearch.index.query.Rewriteable.rewriteAndFetch(Rewriteable.java:77) ~[elasticsearch-7.16.0.jar:7.16.0]

参考:https://www.cnblogs.com/chenyanbin/p/13493920.html

参考:
Mac安装es

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/151083.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 中国知网爬虫

    中国知网爬虫中国知网爬虫一、知网介绍提起中国知网,如果你曾经写过论文,那么基本上都会与中国知网打交道,因为写一篇论文必然面临着各种查重,当然翟博士除外。但是,本次重点不在于写论文跟查重上,而在于我们要爬取知网上一些论文的数据,什么样的数据呢?我们举一个例子来说,在知网上,搜索论文的方式有很多种,但是对于专业人士来说,一般都会使用高级检索,因为直接去查找作者的话,容易查找到很多重名作者,所以我们本次的爬…

    2022年7月26日
    12
  • MPEG4 MP4和AVC H264 MP4有什么不同

    MPEG4 MP4和AVC H264 MP4有什么不同H264  一、H.264与其他标准的比较  1.1在画质上  H.264概述随着市场的需求,在尽可能低的存储情况下获得好的图像质量和低带宽图像快速传输已成为视频压缩的两大难题。为此IEO/IEC/和ITU-T两大国际标准化组织联手制定了新一代视频压缩标准H.264。  MPEG4H.264标准LOGO1.2在编码上  H.264和以前的标准一样,也是DPCM加变换编码

    2022年10月17日
    2
  • 永磁同步电机矢量控制(一)——数学模型

    导师研究的课题是永磁同步电机的控制,首先给我安排的任务就是将其矢量控制系统仿真搭建出来。本文记录矢量控制系统学习过程。因为是初学我的理解可能不够,其中每个内容的出处都会在文章内标注出来,大家可以参考原文原著。1、永磁同步电机的数学模型(参考于解小刚、陈进采用Id=0永磁同步电机矢量控制文章)永磁同步电机是一个非线性系统,具有多变量、强耦合的特点。我们对其分析的时候有以下假设:…

    2022年4月6日
    122
  • iPython的安装过程

    iPython的安装过程

    2021年9月18日
    37
  • jediscluster 关闭 连接池_Redis——JedisCluster

    jediscluster 关闭 连接池_Redis——JedisClustersmart客户端实现原理(追求性能,不使用代理)从集群中选一个可运行节点,使用clusterslots初始化槽和节点映射。将clusterslots的结果映射到本地,为每个节点创建JedisPool。执行命令执行命令执行命令的过程简单来说,就是通过CRC16计算出key的槽,根据节点映射直接访问目标节点,如果出错,就随机挑选一个节点,通过moved重定向访问目标节点,并且重新初始化节点映射。好…

    2022年10月10日
    2
  • vscode设置终端_vscode 关联PDF

    vscode设置终端_vscode 关联PDFhttps://blog.csdn.net/qq_36743482/article/details/103487025

    2025年5月27日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号