一、准备工作

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. js分页器插件

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  2. react native中使用native-echarts

    第一步,下载依赖 npm install native-echarts --save 第二步,引入 import Echarts from 'native-echarts'; 第三步,使用 expor ...

  3. c#之课后习题

    1.折叠代码 #region 折叠内容#endregion 2.保留三位小数 using System; namespace _005_double保留3位小数 { class Program { s ...

  4. equals和==的区别小结

    ==: == 比较的是变量(栈)内存中存放的对象的(堆)内存地址,用来判断两个对象的地址是否相同,即是否是指相同一个对象.比较的是真正意义上的指针操作. 1.比较的是操作符两端的操作数是否是同一个对象 ...

  5. ssh整合not found class 异常总结

    (1)org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqls ...

  6. jar包的读取

    昨天在做项目插件的时候,因为会用到jar包中的一个文件来初始化程序.并且以后还是会访问这个文件,所以就想到干脆吧文件拷贝到指定目录.在拷贝的时候也费了好一会时间,这里涉及到了jar文件的操作,在这里记 ...

  7. JavaScript 创建和浅析自定义对象

    在Js中,除了Array.Date.Number等内置对象外,开发者可以通过Js代码创建自己的对象. 目录 1. 对象特性:描述对象的特性 2. 创建对象方式:对象直接量.new 构造函数.Objec ...

  8. Git branch 分支与合并分支

    Git branch 分支 查看当前有哪些branch bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch * master 新建一 ...

  9. Django 一对一,一对多,多对多 操作、常用方法

    几对几的模型结构的使用场景为:一般根据业务需求,同一业务,需要向相关联的多表插入删除数据时,会用到. 一对一: 创建一个用户表 class Users(models.Model): username ...

  10. Nginx技术研究系列3-OpenResty安装配置

    上两篇中介绍了: Ngnix技术研究系列1-通过应用场景看Nginx的反向代理 Ngnix技术研究系列2-基于Redis实现动态路由 发现,应该加一篇OpenResty的安装部署说明,方便大家按图索骥 ...