elasticsearch集群安装(代码片段)

wlwl wlwl     2023-02-21     658

关键词:

安装环境: 1核 2g jdk1.8+

  1. 下载 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.2.tar.gz
  2. 解压 tar -zxvf elasticsearch-6.2.2.tar.gz
  3. 设置权限 chmod -R 777 elasticsearch-6.2.2
  4. 添加非root用户 adduser wulei && passwd wulei 参考https://blog.csdn.net/u010454261/article/details/70227164/
  5. 切换登陆用户 su - wulei
  6. 启动 cd elasticsearch-6.2.2/bin && ./elasticsearch
  7. 检查是否启动成功 curl localhost:9200

  技术分享图片

  启动es出现相关问题处理:
  1、问题一

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error=‘Cannot allocate memory‘ (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 986513408 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/local/software/temp/elasticsearch-6.2.2/hs_err_pid1912.log
解决:内存不够,增加服务器内存(2g以上)

  2、问题二

[[email protected] bin]# ./elasticsearch
[2018-02-22T20:14:04,870][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.2.2.jar:6.2.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.2.2.jar:6.2.2]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.2.2.jar:6.2.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.2.2.jar:6.2.2]
解决:使用非root用户启动

  3、问题三

./elasticsearch
Exception in thread "main" java.nio.file.AccessDeniedException: /usr/local/software/temp/elasticsearch-6.2.2/config/jvm.options
解决:权限不够 chmod 777 -R 当前es目录
常见配置问题资料:https://www.jianshu.com/p/c5d6ec0f35e0elasticsearch

ElasticSearch配置与性能优化:

  1. es的jvm参数配置文件(只需要代xmx xms就好了)

技术分享图片
## JVM configuration   JVM 配置
################################################################
## IMPORTANT: JVM heap size   重要信息:JVM堆大小
################################################################
# Xms和Xmx值最好一致,避免经常触发GC回收。大小一般为服务器运行内存的(1/2~2/3)
# Xms 初始堆大小
# Xmx 最大

-Xms1g
-Xmx1g

################################################################
## Expert settings
## 下面这些配置策略几乎不用动
################################################################

## GC configuration
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly

## optimizations

# pre-touch memory pages used by the JVM during initialization
-XX:+AlwaysPreTouch

## basic

# explicitly set the stack size
-Xss1m

# set to headless, just in case
-Djava.awt.headless=true

# ensure UTF-8 encoding by default (e.g. filenames)
-Dfile.encoding=UTF-8

# use our provided JNA always versus the system one
-Djna.nosys=true

# turn off a JDK optimization that throws away stack traces for common
# exceptions because stack traces are important for debugging
-XX:-OmitStackTraceInFastThrow

# flags to configure Netty
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0

# log4j 2
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true

-Djava.io.tmpdir=$ES_TMPDIR

## heap dumps
# ensure the directory exists and has sufficient space
#-XX:HeapDumpPath=/heap/dump/path

## JDK 8 GC logging

8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
# time/date parsing will break in an incompatible way for some date patterns and locals
9-:-Djava.locale.providers=COMPAT
jvm.options4

  2. 主配置文件(自定义node.name节点名称   和   http.port端口  network.host服务器地址 就好了)

技术分享图片
# ======================== 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.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster集群 -----------------------------------
#
# 集群名称: 同一网段如果有多个节点,集群名称相同情况下,会自动加入成一个集群
cluster.name: wuleiCluster
#
# ------------------------------------ Node ------------------------------------
#
# 节点名称: 类似于pid
node.name: node-1
#
# Add custom attributes to the node:向节点添加自定义属性
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# 存储数据的目录路径(用逗号分隔多个位置)
#
#path.data: /path/to/data
#
# 日志文件
#
#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.
#
# ---------------------------------- Network -----------------------------------
#
# 指定服务器ip,否则只能内网访问无法外网访问
network.host: 0.0.0.0
#
# 对外提供的端口
http.port: 9200
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

elasticsearch.yml
elasticsearch.yml

如果仅仅只是修改节点名称和端口还是可以启动的,但是如果要外网(浏览器)可以访问,必须指定network.host。这个时候启动就会报错。

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决办法:
1. vim /etc/security/limits.conf在文件默认追加下面配置
* soft nofile 65536
* hard nofile 65536
2. vim /etc/sysctl.conf在文件末尾追加 vm.max_map_count=655360保存后执行sysctl -p
3. 重启服务器   reboot

技术分享图片

集群安装:集群安装其实很简单:只需要指定同一个 集群名称 ,修改每个节点的节点名称(唯一)就好了,我用伪集群为例。(伪集群还要修改端口)

 技术分享图片

 








2022elasticsearch-7.17.6集群部署(代码片段)

目录0.环境系统1.安装es集群2.配置es集群2.1.修改es配置文件2.2.修改JVM配置3.系统配置4.启动es集群0.环境系统1.安装es集群下载及安装wgethttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.6-x86_64.rpmwgethttps://artifacts.elastic.co 查看详情

elasticsearch集群安装插件滚动重启步骤(代码片段)

elasticsearch集群安装插件滚动重启步骤1.先安装好插件(每个节点都要装,root用户执行)2.禁用分片分配。这可以防止Elasticsearch重新平衡(reblance)丢失的分片,可以按如下方式禁用分配3.为了提升集群恢复速度,... 查看详情

docker-compose安装elasticsearch集群(代码片段)

文件目录:1、编写docker-compose文件version:‘3‘services:es-master:image:elasticsearch:6.4.3container_name:es-masterrestart:alwaysvolumes:-./master/data:/usr/share/elasticsearch/data:rw-./master/conf/elasticsearc 查看详情

使用docker安装elasticsearch伪分布式集群(代码片段)

docker安装elasticsearch伪分布式集群0.在安装es之前,首先编辑一下宿主机的内核参数,否则配置es集群的时候极有可能启动不成功:[[email protected]~]#vim/etc/sysctl.confvm.max_map_count=655360[[email protected]~]#sysctl-p#加载参数1.搜索es的镜... 查看详情

一.elasticsearch7.7.0安装与集群配置(代码片段)

Elasticsearch安装与集群配置一、软件版本操作系统:CentOSLinuxrelease7.6.1810(Core)ES版本:7.7.0主机:192.168.3.120docker0主机:192.168.3.121docker1主机:192.168.3.122docker2二、部署环境规划:需求:jdk:open-jdk.1.8#java-versionopenjdkversion"1. 查看详情

《果然新鲜》电商项目(47)-docker下搭建elasticsearch集群(代码片段)

文章目录1.为什么要安装ElasticSearch集群?2.Docker下安装ElasticSearch集群的步骤2.1.关闭防火墙2.2.添加环境参数2.3.拉取镜像2.4.准备虚拟网络和挂载目录2.5.启动Elasticsearch集群2.6.访问3.配置分词4.总结1.为什么要安装ElasticSearch集群&#... 查看详情

elasticsearch7.8.0版本进阶——分布式集群(单节点集群)(代码片段)

目录一、Elasticsearch集群的安装1.1、Elasticsearch集群的安装(win10环境)1.2、Elasticsearch集群的安装(linux环境)二、单节点集群(win10环境集群演示)2.1、单节点集群的概述2.2、单节点集群的示例一、Elasticsearc... 查看详情

elasticsearch集群安装(代码片段)

...:1核2gjdk1.8+  1.下载wgethttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.2.tar.gz  2.解压tar-zxvfelasticsearch-6.2.2.tar.gz  3.设置权限chmod-R777elasticsearch-6.2.2  4.添加非root用户adduserwulei&&passwdwulei参考https://blog.csdn.net/u0... 查看详情

elasticsearch7.8.0版本进阶——分布式集群(水平扩容)(代码片段)

目录一、Elasticsearch集群的安装1.1、Elasticsearch集群的安装(win10环境)1.2、Elasticsearch集群的安装(linux环境)二、水平扩容(win10环境集群演示)三、想要扩容超过6个节点怎么办3.1、主分片和副分片数目3.2... 查看详情

elasticsearch篇--elasticsearch从初识到安装和应用(代码片段)

一、前述ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTfulweb接口,在企业中全文搜索时,特别常用。二、常用概念cluster代表一个集群,集群中有多个节点,其中有一个为主节... 查看详情

树莓派部署elasticsearch6集群(代码片段)

欢迎访问我的GitHub本篇概览今天在两个树莓派3B上部署了Elasticsearch6.7.1版本的集群,和在一般Linux服务器上部署区别不大,现在把过程小结一下,希望能给您一些参考;环境信息树莓派操作系统是64位Ubuntu,该系统的安装步骤请参... 查看详情

elasticsearch集群环境搭建(代码片段)

一、环境说明搭建一个三个节点的集群环境,模拟搭建为了方便在一台机器上搭建,需要3G以上的内存节点#192.168.200.136安装elasticsearch集群elasticsearch0:192.168.200.136:9200elasticsearch1:192.168.200.136:9201elasticsearch2: 查看详情

elasticsearch集群环境搭建(代码片段)

一、环境说明搭建一个三个节点的集群环境,模拟搭建为了方便在一台机器上搭建,需要3G以上的内存节点#192.168.200.136安装elasticsearch集群elasticsearch0:192.168.200.136:9200elasticsearch1:192.168.200.136:9201elasticsearch2: 查看详情

elasticsearch8集群搭建安全功能配置详述(代码片段)

ElasticStack产品栈包含Beats、APM、Elasticsearch、ElasticsearchHadoop、Kibana、Logstash,这些产品常被作为一个整体搭配使用,其部署需要使用同样的版本,这样子能够有效简化部署操作。本文主要记录Elasticsearch8.4.3的安装过程,... 查看详情

elasticsearch的安装部署(代码片段)

https://blog.csdn.net/lubin2016/article/details/81606753 1.elasticsearch的安装1.1集群规划上传elasticsearch的tar.gz包至规划的集群各节点的目录下(规划两个节点rc-fhcb-10-es001,rc-fhcb-10-es002),如:本项目安装在/opt/fhcb/目录下注意:建议elasticse 查看详情

elasticsearch-5.3.1集群环境搭建,安装elasticsearch-head插件,安装错误解决(代码片段)

...也是忙的不行,一直也没时间好好的研究一下,惭愧。《Elasticsearch服务器开发》已经备好,只能边学边开发了,希望本篇拙文 查看详情

elasticsearch集群环境搭建(代码片段)

...机器上搭建,需要3G以上的内存节点#192.168.200.136安装elasticsearch集群elasticsearch0:192.168.200.136:9200elasticsearch1:192.168.200.136:9201elasticsearch2:192.168.200.136:9202#192.168.200.142安装elasticsearch-headelasticsearch-head:192.168.200.142... 查看详情

elasticsearch集群部署(代码片段)

...1、检索2、如果用MySQL来做关键词检索3、倒排索引ELK简介ElasticSearch集群部署01、集群规划+集群网络配置02、CentOS7创建新用户+免密登录(可选)03、安装JDK04、环境变量(可选)05、ES的下载、上传、解压、修... 查看详情