一、准备工作

Elastic 需要 Java 8 环境。如果你的机器还没安装 Java,先需要安装java环境,同时还注意要保证环境变量JAVA_HOME正确设置。

链接:https://pan.baidu.com/s/1X8IMOw9AWsZjQqu8KYX2ww 密码:s1ov//百度云分享链接/如果失效了可以找我要

习惯性下载到/usr/local/src目录下,解压并创建软连接,方便配置环境变量

#tar zxf jdk-8u91-linux-x64.tar.gz -C /usr/local/  //解压
#ln –s /usr/local/jdk1..0_91 /usr/local/jdk //创建软连接
# vim /etc/profile                    //把下面三行代码放在底部
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
# source /etc/profile                //编辑完成之后执行命令生效
# java -version   //执行命令,出现下面三行代码表示成功
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) -Bit Server VM (build 25.91-b14, mixed mode)

二、配置安装ElasticSearch(这里是源码包方式安装版本elasticsearch-2.4.1,rpm包形式安装)

下载安装

链接:https://pan.baidu.com/s/1nQw03ONklUyYWRQ2hKaHUw 密码:pmj5  //百度云地址
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.4.1/elasticsearch-2.4.1.rpm  //直接命令下载
# yum -y install elasticsearch-2.4.1.rpm  

修改配置文件

# vim /etc/elasticsearch/elasticsearch.yml
#集群名称
cluster.name: my-application
#节点名称
node.name: node-
#数据存储路径
path.data: /var/lib/elasticsearch
#日志存储路径
path.logs: /var/log/elasticsearch
#将来访问elastic的话,都是通过API访问,在这我们要提供一个http主机地址,这里就是本机IP
network.host: 192.168.9.155
#默认端口
http.port:

启动ElasticSearch

#servicc elasticsearch start //启动测试

这里遇到了几个错误~

错误一:不能root用户启动

[--11T09::,][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-] 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:) ~[elasticsearch-5.1..jar:5.1.]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:) ~[elasticsearch-5.1..jar:5.1.]
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:) ~[elasticsearch-5.1..jar:5.1.]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:) ~[elasticsearch-5.1..jar:5.1.]
at org.elasticsearch.cli.Command.main(Command.java:) ~[elasticsearch-5.1..jar:5.1.]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:) ~[elasticsearch-5.1..jar:5.1.]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:) ~[elasticsearch-5.1..jar:5.1.]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:) ~[elasticsearch-5.1..jar:5.1.]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:) ~[elasticsearch-5.1..jar:5.1.]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:) ~[elasticsearch-5.1..jar:5.1.]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:) ~[elasticsearch-5.1..jar:5.1.]
... more

解决(创建新用户)

#groupadd elasticsearch
#useradd elasticsearch -g elasticsearch -p elasticsearch
#cd /opt
#chown -R elasticsearch:elasticsearch /usr/local/elasticsearch

错误二:启动检查没有通过

[--11T09::,][INFO ][o.e.p.PluginsService     ] [node-] loaded module [transport-netty4]
[--11T09::,][INFO ][o.e.p.PluginsService ] [node-] no plugins loaded
[--11T09::,][INFO ][o.e.n.Node ] [node-] initialized
[--11T09::,][INFO ][o.e.n.Node ] [node-] starting ...
[--11T09::,][INFO ][o.e.t.TransportService ] [node-] publish_address {192.168.9.149:}, bound_addresses {192.168.9.149:}
[--11T09::,][INFO ][o.e.b.BootstrapCheck ] [node-] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: bootstrap checks failed
max file descriptors [] for elasticsearch process is too low, increase to at least []
max virtual memory areas vm.max_map_count [] is too low, increase to at least []
[--11T09::,][INFO ][o.e.n.Node ] [node-] stopping ...
[--11T09::,][INFO ][o.e.n.Node ] [node-] stopped
[--11T09::,][INFO ][o.e.n.Node ] [node-] closing ...
[--11T09::,][INFO ][o.e.n.Node ] [node-] closed

①解决max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]。记住root用户修改完文件,切换到elasticsearch用户启动服务时,还会报错,记得一定再切换root,再切回elasticsearch用户启动方可成功

#vim  /etc/security/limits.conf //在底部添加两行代码,让人需要切换到root用户哦
* soft nofile
* hard nofile

②解决max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

# vim  /etc/security/limits.conf       //添加下面一行
vm.max_map_count=          //添加此行
#sysctl -p //添加完成执行此命令

切换到elasticsearch用户重新启动服务,返回下面提示即表示成功~

[--11T09::,][INFO ][o.e.p.PluginsService     ] [node-] loaded module [transport-netty3]
[--11T09::,][INFO ][o.e.p.PluginsService ] [node-] loaded module [transport-netty4]
[--11T09::,][INFO ][o.e.p.PluginsService ] [node-] no plugins loaded
[--11T09::,][INFO ][o.e.n.Node ] [node-] initialized
[--11T09::,][INFO ][o.e.n.Node ] [node-] starting ...
[--11T09::,][INFO ][o.e.t.TransportService ] [node-] publish_address {192.168.9.149:}, bound_addresses {192.168.9.149:}
[--11T09::,][INFO ][o.e.b.BootstrapCheck ] [node-] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[--11T09::,][INFO ][o.e.c.s.ClusterService ] [node-] new_master {node-}{Tjz6HoyoR1KhuIuhE7A8FA}{CTQ4R5bjQ02yNoPlUwasQw}{192.168.9.149}{192.168.9.149:}, reason: zen-disco-elected-as-master ([] nodes joined)
[--11T09::,][INFO ][o.e.h.HttpServer ] [node-] publish_address {192.168.9.149:}, bound_addresses {192.168.9.149:}
[--11T09::,][INFO ][o.e.n.Node ] [node-] started
[--11T09::,][INFO ][o.e.g.GatewayService ] [node-] recovered [] indices into cluster_state

错误三:java_path路径

which: no java in (/sbin:/usr/sbin:/bin:/usr/bin)
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME

解决办法:

# vim /etc/sysconfig/elasticsearch  //添加下面一行到末尾
JAVA_HOME=/usr/local/jdk

OK~~启动成功

# service elasticsearch start
Starting elasticsearch: [ OK ]

试着curl访问

关掉防火墙浏览器访问

OK~

ElasticSearch(二)CentOs6.4下安装ElasticSearch的更多相关文章

  1. ElasticSearch入门 :Windows下安装ElasticSearch

    这是ElasticSearch 2.4 版本系列的第一篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...

  2. linux下安装Elasticsearch(单机版和集群版)

    一.linux下安装Elasticsearch(单机) 1.软件下载 下载地址:https://www.elastic.co/cn/downloads/past-releases/elasticsea ...

  3. 记录Linux下安装elasticSearch时遇到的一些错误

    记录Linux下安装elasticSearch时遇到的一些错误 http://blog.sina.com.cn/s/blog_c90ce4e001032f7w.html (2016-11-02 22: ...

  4. ES1:Windows下安装ElasticSearch

    ElasticSearch(简称ES)是一个基于Lucene的分布式全文搜索服务器,本随笔演示在Windows安装ElasticSearch和用于管理ES的Head插件. ElasticSearch官 ...

  5. ElasticSearch入门 第一篇:Windows下安装ElasticSearch

    这是ElasticSearch 2.4 版本系列的第一篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...

  6. 【转载】CentOS6.5_X64下安装配置MongoDB数据库

    [转载]CentOS6.5_X64下安装配置MongoDB数据库 2014-05-16 10:07:09|  分类: 默认分类|举报|字号 订阅      下载LOFTER客户端 本文转载自zhm&l ...

  7. CentOS6.5下安装Apache2.4+PHP7

    CentOS6.5下安装Apache2.4+PHP7 http://blog.csdn.net/along602/article/details/42695779 http://www.th7.cn/ ...

  8. 在CentOS6.8下安装Docker

    在CentOS6.8下安装Docker 一.查看系统版本 [root@localhost opt]# uname -a Linux localhost.localdomain -.el6.x86_64 ...

  9. coreseek/sphinx CentOS6.4下安装

    一.在CentOS6.4下安装coreseek之前需要预先安装以下软件 1.打开终端 输入 su 获取管理员权限 2.输入命令 yum install make gcc g++ gcc-c++ lib ...

随机推荐

  1. 【Java】-NO.16.EBook.4.Java.1.003-【疯狂Java讲义第3版 李刚】- oop

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.003-[疯狂Java讲义第3版 李刚]- oop Style:EBook Series:Java S ...

  2. 2019.03.30 Head first

    第一节 认识python python.exe -V python 会进入解释器 quit()命令会退出解释器 IDEL,一个python的集成开发环境,能够利用颜色突出语法的编辑器,一个调试工具,P ...

  3. vector erase的错误用法

    直接写 a.erase(it)是错误的,一定要写成it=a.erase(it)这个错误编译器不会报错.而且循环遍历删除的时候,删除了一个元素,容器里会自动向前移动,删除一个元素要紧接着it--来保持位 ...

  4. js函数中写默认值的几种方式(常见的)

    <script> <!--第一种写法,我更喜欢第一种写法直观一些--> function Person(name){ this.name = name || '默认名字乔丹'; ...

  5. cocos2d-x JS 复选按钮checkBox的单选与多选

    var HZ_createRoom = jx.BaseView.extend({//红中麻将 ctor : function() { this._super(); this.addLayout(res ...

  6. catalog start with + switch database to copy的妙用

    catalog start with + switch database to copy的妙用 环境:RHEL6.4 + Oracle 11.2.0.4 Primary RAC + Standby R ...

  7. CRUD简单查询

    一.查询所有数据 select * from car 二.查询指定列 select code , price from car 三.修改查询出的列名 select code as '代号' , nam ...

  8. 9.if/else/elif

    简单的条件是通过使用 if/else/elif 语法创建的.条件的括号是允许的,但不是必需的.考虑到基于表的缩进的性质,可以使用 elif 而不是 else/if 来维持缩进的级别. if [expr ...

  9. Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04(转)

    http://www.powerxing.com/install-hadoop/ http://blog.csdn.net/beginner_lee/article/details/6429146 h ...

  10. BestCoder Round #55 ($)

    C 构造一个矩阵,然后采用矩阵快速幂 #include <iostream> #include <algorithm> #include <string.h> #i ...