我的环境是centos7.5 Java1.8

第一步下载
ElasticSearch官网
ElasticSearch下载页面
PS:安装时多种多样,试过yum可能是我操作有问题三次没安对,wget之后下载tar试了两次都是下载一半就失败了,最后还是在PC上下载的tar包在上传到linux上才正式完成了下载功能.

解压缩刚才下载的压缩包 tar -xzf elasticsearch-7.2.0-linux-x86_64.tar.gz;
PS:如果失败首先就要看下载的压缩包大小是不是321M,因为我就遇到了下载下载22M

切换到你的安装目录 cd /opt/elasticsearch-7.2.0

不要急着启动,因为ElasticSearch是不允许使用root账户启动的:
#创建分组
groupadd ealstic
#创建用户
useradd ealsticUser
#给用户设置密码
passwd ealsticUser
#用户加入分组
usermod -G elastic elasticUser
#给用户分配ealstic目录权限
chown -R elasticUser:ealstic /opt/elasticsearch-7.2.0
到这里权限就分配好了

补上root允许报错信息:
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:163) ~[elasticsearch-7.2.0.jar:7.2.0]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.2.0.jar:7.2.0]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.2.0.jar:7.2.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.2.0.jar:7.2.0]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.2.0.jar:7.2.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.2.0.jar:7.2.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.2.0.jar:7.2.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.2.0.jar:7.2.0]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.2.0.jar:7.2.0]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.2.0.jar:7.2.0]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.2.0.jar:7.2.0]
… 6 more

#切换到elasticUser用户下
su elasticUser
#因为分配全线之前已经进入到安装目录了使用直接启动
bin/elasticsearch
如果是大吉大利到这里就完成了.

问题一:
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error=‘Cannot allocate memory’ (errno=12)
at org.elasticsearch.tools.launchers.JvmErgonomics.flagsFinal(JvmErgonomics.java:111)
at org.elasticsearch.tools.launchers.JvmErgonomics.finalJvmOptions(JvmErgonomics.java:79)
at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:57)
at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:89)
修改config目录下的jvm.options里面的参数(最好切换回root用户)
vi /opt/elasticsearch-7.2.0/config/jvm.options
修改jvm内存(这有个上限32G,默认是1G,建议是总内存的一半,由于我这个服务器本身内存较小就随便设置一个先启动再说)
-Xms100m
-Xmx100m
(某些软件包启动的时候默认启用 -XX:+AssumeMP,参考链接)
-XX:-AssumeMP
看到上面的错误描述中有XX:ParallelGCThreads可能这里的设置也有问题但是配置上面三个之后这个问题就解决了以后再研究.

问题二:
Exception in thread “main” org.elasticsearch.bootstrap.BootstrapException: java.nio.file.AccessDeniedException: /opt/elasticsearch-7.2.0/config/elasticsearch.keystore
Likely root cause: java.nio.file.AccessDeniedException: /opt/elasticsearch-7.2.0/config/elasticsearch.keystore
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at org.apache.lucene.store.SimpleFSDirectory.openInput(SimpleFSDirectory.java:77)
at org.elasticsearch.common.settings.KeyStoreWrapper.load(KeyStoreWrapper.java:206)
at org.elasticsearch.bootstrap.Bootstrap.loadSecureSettings(Bootstrap.java:234)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:305)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
Refer to the log for complete error details.
问题不大,在bin目录下已经提供elasticsearch-keystore工具了,
bin/elasticsearch-keystore create 在config目录创建一个elasticsearch.keystore文件

问题三:
重启了没复制下来 大概就是vm.max_map_count 这个东西大小的一个错误
切换root账户 vim /etc/sysctl.conf
增加一行 vm.max_map_count=655360
接着执行 sysctl -p

问题四:
max number of threads [3883] for user [elasticUser] is too low, increase to at least [4096]
线程太少.Elasticsearch通过将请求分解为多个阶段并将这些阶段交给不同的线程池执行程序来执行请求。Elasticsearch中的各种任务有不同的线程池执行程序。因此,Elasticsearch需要能够创建大量线程。坑爹的是:此检查仅在Linux上强制执行。通过/etc/security/limits.conf 使用nproc设置来完成(可能还必须增加root用户的限制).
通过 ulimit -Hu ulimit -Su查看当前设置的线程数
vim /etc/security/limits.conf
添加下面四行
root soft nproc 4096
root hard nproc 4096

  • soft nproc 4096
  • hard nproc 4096

问题五:跨域无法访问
修改config下elasticsearch.yml文件
#允许任意IP访问
network.host: 0.0.0.0
#修改开放的端口
http.port: 9200
#最后添加跨域
http.cors.enabled: true
http.cors.allow-origin: “*”
设置防火墙
#查看防火墙状态
firewall-cmd --state
#开放9200端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent
#重启
firewall-cmd --reload
如果是云服务器还需要设置白名单和安全组策略

下面是我的 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: elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# 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: /var/lib/elasticsearch
#
# Path to log files:
#
#path.logs: /var/log/elasticsearch
#
# ----------------------------------- 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
# 允许任意IP访问
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#修改开放的端口
http.port: 9200
#
# 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"]#########这是为解决错误儿添加的 如果没有这个错误请不要添加这个以防出现问题############
#the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] #must be configured
cluster.initial_master_nodes: ["node-1"]#
# For more information, consult the discovery and cluster formation 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# 最后添加跨域
http.cors.enabled: true
http.cors.allow-origin: "*"

最后结果

接下来的操作我是使用的postman,路径就是http://ip:9200/你的索引/类型 将headers设置成application/json,发送json数据就好了.

问题六:
在启动的时候一直会提示一个Java版本的错误但是不影响运行和使用,
future versions of Elasticsearch will require Java 11; your Java version from [/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre] does not meet this requirement
查看了elasticsearch和jvm的版本对照表没有发现问题.后来查询到elasticsearch7.2.0版本自带JDK所以不用安装.猜想是我的环境中已经安装了JDK1.8并设置了环境变量所以有个提示.要去掉就需要指定elasticsearch使用本地环境.
#杀掉自带的jdk环境
kill -9 $(ps -ef|grep elasticsearch-7.2.0/jdk/bin/java|grep -v grep |awk ‘{print $2}’)
#以不挂断的方式启动elasticsearch 并且输出到文件:2>&1是将标准错误(2)重定向到标准输出(&1),标准输出(&1)再被重定向输入到#log.out 文件中。
nohup bin/elasticsearch > ./log.out 2>&1 &
#实时查看日志文件
tail -f log.out

上面这种方式无法control+c主动退出
#查看进程
#1.1用ps -def | grep xxx(查找进程很方便,最后一行总是会grep自己)| grep -v grep(用grep -v参数可以将grep命令排除掉)
#1.2用 ps -aux | grep elasticsearch (a:显示所有程序 u:以用户为主的格式来显示 x:显示所有程序,不以终端机来区分)
#2再用awk提取一下进程ID 
ps -aux|grep elastic| grep -v grep | awk ‘{print $2}’
#杀掉进程
kill -9 进程号

Elasticsearch系列--安装相关推荐

  1. ElasticSearch系列 - 安装

    ElasticSearch系列 - 安装 ElasticSearch 安装 elasticSearch下载 选择MACOS 下载,然后解压zip包 Elasticsearch目录结构为: 目录 配置文 ...

  2. Elasticsearch系列-安装部署

    Elasticsearch系列-安装部署 准备 安装 错误 准备 1.服务器创建es用户 useradd es passwd es 2.elasticsearch部署环境JDK 3.安装包 可以去el ...

  3. 【ElasticSearch系列连载】3. 如何安装符合生产环境要求的ES集群

    [ElasticSearch系列连载]3. 如何安装符合生产环境要求的ES集群 通过本文,将会循序渐进地了解到ES的若干部署方案,以及相关的基础操作与配置. 上一节介绍的一键安装方式,可以快速启动一个 ...

  4. Elasticsearch系列之:Centos7安装部署Elasticsearch详细步骤

    Elasticsearch系列之:Centos7安装部署Elasticsearch详细步骤 一.下载ElasticSearch安装包 二.创建ES数据存储目录 三.创建ES所属用户 四.配置用户的打开 ...

  5. ElasticSearch系列——Kibana,核心概念

    ElasticSearch系列--Kibana,核心概念 Kibana 下载地址 Windows安装 修改配置文件 启动Kibana 验证 ES核心概念 Index索引 Mapping映射 Docum ...

  6. Elasticsearch 系列文章(一):Elasticsearch 默认分词器和中分分词器之间的比较及使用方法

    介绍:ElasticSearch 是一个基于 Lucene 的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于 RESTful web 接口.Elasticsearch 是用 Java 开 ...

  7. SQL Server全系列安装程序V1.2中文版

    SQL Server全系列自动安装程序是一款包含所有版本SQL Server的合集软件.SQL Server 在多数系统上的安装都不会一帆风顺,通常会因为缺少必备组件而安装不了,并且其版本繁多,还有3 ...

  8. ELK日志平台一 ElasticSearch的安装

    一.安装 ElasticSearch的版本号从 1.X → 2.X →  5.X  →  6.X 其中ES 5.X开始支持的jdk最低版本为jdk1.8 官网下载地址:https://www.elas ...

  9. 最新版elasticsearch的安装踩坑

    elasticearch是目前最流行的实时的分布式搜索和分析引擎,水平扩展能力非常强,提供restful接口简化使用难度. 文档 学习一个技术最好的方式就是阅读官方文档,英语没有那么好的最好方式就是看 ...

最新文章

  1. HDU1599(最小环)
  2. tomcat的jsp页面超过65535,导致500报错
  3. 【SSL】使用Keytool工具生成证书及签名完整步骤
  4. c语言作业答案N个公约数公倍数,c语言程序题,输入两个正整数m和n,求其最大公约数和最小公倍数。...
  5. 必要时进行保护性拷贝
  6. 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。
  7. u盘镜像制作linux系统,制作iso镜像U盘自动化安装linux系统
  8. 学刘红杰老师博客营销,知如何提高博客访问流量
  9. 监督学习-分类模型1-线性分类器(Linear Classifiers)
  10. 一、jsp和Servlet基础理论及jstl和EL表达式用法
  11. lambda x:x*x
  12. 十分钟搭建私有化人脸识别服务
  13. 南京数海文化传媒有限公司官网上线 | LTD文化传媒行业案例分享
  14. 815. 打印字符串
  15. Windows 7 Build 7068 下载泄露
  16. 硬盘测试软件cry,CrystalDiskMark测试硬盘官方版
  17. 最近看的电影综艺推荐
  18. Hiveserver2源码剖析---如何实现代理用户
  19. PlumeLog分布式日志系统+Spring Boot
  20. 还在找免费的能提供HTTPS协议外链的图床?这个开源插件轻松完成

热门文章

  1. 巧用 Windows 7 键盘快捷键,让您工作更轻松
  2. 爬取BBC评选21世纪电影TOP100
  3. 易课寄在线购课系统开发笔记(三十三)--完成购物车系统的开发
  4. .NET6 上传文件大小,地址栏长度限制
  5. 2020中国程序员调查报告:平均年薪15万,45%单身
  6. Dell键盘卡卡感觉的DIY修复
  7. 平淡了忧伤,习惯了孤独 伤感日志
  8. 当当VP陈立均:当当图书三季度市场份额以45%遥遥领先,四季度开启18周年庆回馈读者阅读盛宴
  9. spring的IOC容器Bean管理(基于xml方式)
  10. OC底层原理-alloc流程