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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Android实战——ShareSDk的使用,实现一键分享微信好友、朋友圈、QQ

    Android实战——ShareSDk的使用,实现一键分享微信好友、朋友圈、QQShareSDk的使用,实现一键分享微信好友、朋友圈、QQ事先说明:ShareSDK默认QQ可以分享,微信分享则需要在微信的开放平台上认证并申请应用填入对应信息即可微信认证和申请应用涉及到打包和签名APK,请大家自行查询相关资料进行操作关于ShareSDK的开发,参考ShareSDK官网为准欢迎关注CSDN博客:Hensen_的个人主

    2022年5月2日
    28
  • policy服务器未能登录,win7电脑提示group policy client服务未能登录的解决方法[通俗易懂]

    policy服务器未能登录,win7电脑提示group policy client服务未能登录的解决方法[通俗易懂]我们都清楚电脑使用久了总是会出现各种各样的问题,其中比较常见的就是系统提示了,最近有位win7系统用户使用电脑的过程中,系统总是会提示“grouppolicyclient服务未能登录”,用户不知道怎么解决,我们都清楚电脑使用久了总是会出现各种各样的问题,其中比较常见的就是系统提示了,最近有位win7系统用户使用电脑的过程中,系统总是会提示“grouppolicyclient服务未能登录”,…

    2022年5月14日
    76
  • 机器学习算法(一):逻辑回归模型(Logistic Regression, LR)[通俗易懂]

    机器学习算法(一):逻辑回归模型(Logistic Regression, LR)[通俗易懂]线性分类器:模型是参数的线性函数,分类平面是(超)平面;非线性分类器:模型分界面可以是曲面或者超平面的组合。典型的线性分类器有感知机,LDA,逻辑斯特回归,SVM(线性核);典型的非线性分类器有朴素贝叶斯(有文章说这个本质是线性的,http://dataunion.org/12344.html),kNN,决策树,SVM(非线性核)https://www.cnblogs.com/sparkw…

    2022年7月14日
    14
  • latex公式换行后保证括弧大小相同

    latex公式换行后保证括弧大小相同latex公式换行方法一:\left\{xxxxx\right.\left.xxxxx\right\}此方法可能导致上下括号大小不同为解决此问题,需要自定义括号大小,自带的大小控制符有\big,\Big,\bigg,\Bigg\big\{xxxxxxxxx\big\}这样人为定义了同样大小的括弧,根据需要调整括弧控制符即可…

    2022年5月2日
    78
  • python中的eval函数的用法_isnan函数

    python中的eval函数的用法_isnan函数eval函数在Python中具有非常重要的地位,熟练的使用eval函数能够为我们的Python编程提供很多的便利之处。在本文中我将详细记录eval函数在Python中的使用方法及它带来便利时带来的一些其他危害,希望您阅读完本文后能够有所收获。欢迎在文章下方留言共同交流学习。

    2022年10月23日
    0
  • J2me开发大致框架「建议收藏」

    J2me开发大致框架「建议收藏」J2me开发名目繁多.但大致框架还算有规律可寻,我根据开发经验给大家提点意见,做下总结:游戏的结构很多,不过基本上都是在一个游戏主循环内实现。程序里面的主循环包含了程序框架的最主要的结构体。J2me的程序一般都包含两个class文件,一个是MIDlet,一个是Displayable。一般我都是把游戏的主要代码放在Displayable这个类里面。这个类是基

    2022年7月27日
    3

发表回复

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

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