03_ElasticSearch下载安装

概述

ElasticSearch是java开发的,jdk环境是必不可少的,至少有jre环境

1 下载ElasticSearch

最新版本需要访问 ElasticSearch 官网下载:https://www.elastic.co/cn/downloads/elasticsearch,

其他版本见Elastic 中文社区,地址:https://elasticsearch.cn/download

注意版本,不同的版本差异比较大,选择适合自己的版本

2. 安装

java 程序启动在不同的环境下是不一样的,但是解压后不需要特殊的安装,只需要找到bin目录使用命令启动即可

2.1 配置环境变量, 方便后期使用命令启动,而不是每次都去bin目录

我用的mac本就截图了 其他的自己百度吧 比较简单

java 复制代码
vim ~/.bash_profile 

增加内容:

java 复制代码
自己的解压目录
ES_HOME=/Users/XXX/java/es/elasticsearch-7.17.3 
PATH=$PATH:$ES_HOME/bin
export ES_HOME

配置问就可以 在终端 执行

正常 应该是elasticsearch 命令, 我为了简单 修改成 es 命令了

java 复制代码
es
在后端启动
es -d 

启动后直接访问:

localhost:9200

mac 环境变量 终端关闭后不生效问题

在 ~/.bash_profile 中配置环境变量, 每次重启终端后配置的环境变量不生效。

需要重新执行 : $source ~/.bash_profile才可以。

是因为zsh加载的是 ~/.zshrc文件,而 '.zshrc'文件中并没有定义环境变量。

解决办法:

vi ~/.zshrc

在~/.zshrc文件最后,增加一行:

source ~/.bash_profile

最后

source ~/.zshrc

已经解决了问题,那么我们想问 .bash_profile 和 .zshrc 这两个文件有什么区别呢?

.bash_profile 修改的环境变量只对当前窗口有效,而且需要 source 一下,.zshrc 则相当于 win 开机启动的环境变量,可以在 .zshrc 中加上一个 source 更新 .bash_profile 命令即可解决问题

集群配置

如果刚开始学习,完全没必要配置集群 直接单机学习就可以, 集群反正各种问题,这里我只写一个配置文件,遇到问题自己百度吧/

把自己的解压文件拷贝几分,修改 config下的配置文件

java 复制代码
# Use a descriptive name for your cluster:
##集群名称,节点之间要保持一致
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# #节点名称,集群内要唯一
node.name: node-1
node.master: true
node.data: true
#
# 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: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/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.
# node-01
# 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:
# #ip 地址
network.host: 10.0.72.59
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
# #http 端口
http.port: 1001
#tcp 监听端口
transport.tcp.port: 9301
#
# 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: ["host1", "host2"]
#
# 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 -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don't have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features. 
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html


discovery.seed_hosts: ["localhost:9301", "localhost:9302","localhost:9303"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
#集群内的可以被选为主节点的节点列表
cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
#跨域配置
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"

访问集群是否正常启动:

GET http://127.0.0.1:1001/_cluster/health

GET http://127.0.0.1:1002/_cluster/health

GET http://127.0.0.1:1003/_cluster/health

返回结果:

java 复制代码
{
    "cluster_name": "my-application",
    "status": "green",
    "timed_out": false,
    "number_of_nodes": 3,
    "number_of_data_nodes": 3,
    "active_primary_shards": 0,
    "active_shards": 0,
    "relocating_shards": 0,
    "initializing_shards": 0,
    "unassigned_shards": 0,
    "delayed_unassigned_shards": 0,
    "number_of_pending_tasks": 0,
    "number_of_in_flight_fetch": 0,
    "task_max_waiting_in_queue_millis": 0,
    "active_shards_percent_as_number": 100.0
}

status字段指示着当前集群在总体上是否工作正常。它的三种颜色含义如下:

green:所有的主分片和副本分片都正常运行。

yellow:所有的主分片都正常运行,但不是所有的副本分片都正常运行。

red:有主分片没能正常运行。

配置内存设置文件jvm.options

文件路径:/var/huaxing/elasticsearch-7.4.2/config

内存容量较小时修改默认配置:-Xms1g -Xmx1g为-Xms512m -Xmx512m。

相关推荐
不是万能的豆学长11 小时前
filetidy 文件整理助手:一键归类 + 规范重命名(Python 零依赖单文件工具)
大数据·开发语言·python·技术美术
库库的数据库笔记18 小时前
国产信创数据库的MySQL兼容性深度对比解析
大数据·数据库·mysql·oceanbase·政务
Elastic 中国社区官方博客19 小时前
我们如何通过 70 多个拉取请求,将 OpenTelemetry Java agent 迁移到 invokedynamic
java·大数据·开发语言·elasticsearch·搜索引擎·全文检索·es
珠海西格电力20 小时前
零碳园区管理系统的性能评估体系的行业标准
大数据·网络·人工智能·物联网·机器学习·架构·能源
杨先生哦21 小时前
SOC告警研判实战:海量告警降噪、误报甄别、内网风险处置全流程(上岗必用)
大数据
一线数智21 小时前
朱鹰:人的判断力,比算力更重要
大数据·人工智能
用户36105886261221 小时前
Flink ResourceManager启动流程源码深度剖析:从ClusterEntrypoint到Slot分配的完整链路
大数据
用户3610588626121 天前
Flink ApplicationMaster启动流程源码深度剖析:从YARN提交到JobMaster启动的完整链路
大数据·flink
初心未改HD1 天前
DSH Skill开发实战:SKILL.md是给LLM看的操作手册,不是给人看的README,踩了4个坑
java·大数据·开发语言
程序 代码狂人1 天前
据仓库常见表类型详解(面试完整版,金融数仓适用)
大数据