第一步:必须要有jre支持

elasticsearch是用Java实现的,跑elasticsearch必须要有jre支持,所以必须先安装jre

第二步:下载elasticsearch

进入官方下载 https://www.elastic.co/downloads/elasticsearch

因为是centos中运行 所以我们选 tar.gz压缩包;

下载后 用ftp上传到centos里 我们把这个文件上传到 /home/data/下

第三步:安装和配置elasticsearch

进入data目录  解压

[root@bogon ~]# cd /home/data/

[root@bogon data]# tar -zxvf elasticsearch-5.5.2.tar.gz

新建目录 剪切文件到新目录

[root@bogon data]# cd

[root@bogon ~]# mkdir /home/es/

[root@bogon ~]# mv /home/data/elasticsearch-5.5.2 /home/es/

我们执行,来启动 elasticsearch

[root@bogon ~]# sh /home/es/elasticsearch-5.5.2/bin/elasticsearch

报错了:

[2017-09-07T19:43:10,628][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:127) ~[elasticsearch-5.5.2.jar:5.5.2]

at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) ~[elasticsearch-5.5.2.jar:5.5.2]

at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) ~[elasticsearch-5.5.2.jar:5.5.2]

at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.5.2.jar:5.5.2]

at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.5.2.jar:5.5.2]

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.5.2.jar:5.5.2]

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.5.2.jar:5.5.2]

Caused by: java.lang.RuntimeException: can not run elasticsearch as root

at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.5.2.jar:5.5.2]

at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194) ~[elasticsearch-5.5.2.jar:5.5.2]

at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:351) ~[elasticsearch-5.5.2.jar:5.5.2]

at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) ~[elasticsearch-5.5.2.jar:5.5.2]

... 6 more

意思是不能用root用户来启动,那我们新建一个用户来启动

[root@bogon ~]# useradd elastic

[root@bogon ~]# chown -R elastic:elastic /home/es/elasticsearch-5.5.2/

新建elastic用户 并且把目录权限赋予给elastic

我们切换成elastic用户,然后执行

[root@bogon ~]# su elastic

[elastic@bogon root]$ sh /home/es/elasticsearch-5.5.2/bin/elasticsearch

出来一大串info 说明成功了,但是这种方式是前台运行,不方便我们操作其他的 我们加下 -d 后台运行

先ctrl+c退出执行;

[elastic@bogon root]$ sh /home/es/elasticsearch-5.5.2/bin/elasticsearch -d

我们来检查下是否启动成功

[elastic@bogon root]$  ps -ef | grep elasticsearch

elastic    2962      1 23 19:48 pts/1    00:00:02 /home/java/jdk1.8.0_144/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Des.path.home=/home/es/elasticsearch-5.5.2 -cp /home/es/elasticsearch-5.5.2/lib/* org.elasticsearch.bootstrap.Elasticsearch -d

elastic    2977   2849  0 19:48 pts/1    00:00:00 grep --color=auto elasticsearch

注意 有朋友经常出现 如下错误

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]

解决方案:

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 [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

修改/etc/security/limits.conf文件,添加或修改如下行: (请切换到root用户 然后强制修改文件)

*        hard    nofile           65536

*        soft    nofile           65536

问题2  [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

$ sudo sysctl -w vm.max_map_count=2621441

或者修改 /etc/sysctl.conf 文件,添加 “vm.max_map_count”设置 永久改变(sudo sysctl -p /etc/sysctl.conf生效)。

/sbin/sysctl -p 执行下 让/etc/sysctl.conf 立即生效

设置后,可以使用

我们来验证下服务是否正常运行 curl http://localhost:9200

[elastic@bogon root]$ curl http://localhost:9200

{

"name" : "K22mJd5",

"cluster_name" : "elasticsearch",

"cluster_uuid" : "R2qfXKtrQl2PwKdJMmPuMA",

"version" : {

"number" : "5.5.2",

"build_hash" : "b2f0c09",

"build_date" : "2017-08-14T12:33:14.154Z",

"build_snapshot" : false,

"lucene_version" : "6.6.0"

},

"tagline" : "You Know, for Search"

}

出来这个 说明配置OK。

第四步:允许外网连接配置

前面我们配置的仅仅是本机使用 但是我们比如集群以及其他机器连接 ,则需要配置下。

可以修改 /home/es/elasticsearch/config/elasticsearch.yml 文件

把 network.host 和 http.port 前面的 备注去掉 然后Host改成你的局域网IP即可

修改后 保存退出

然后我们把防火墙也关了

systemctl stop firewalld.service

systemctl disable firewalld.service   禁止防火墙开机启动

  

Elasticsearch6.3 max number of threads [2048] for user [*] is too low, increase to at least [4096]异常

根据linux系统差异,有时候需要来点终极解决方案

新建: /etc/security/limits.d/test-limits.conf

cat>>test-limits.conf

然后加下内容:

* soft nofile 65536

* hard nofile 131072

* soft nproc 4096

* hard nproc 4096

ctrl+d保存即可;

然后重启服务器即可;

最后我们重启下elasticsearch服务

ps -ef | grep elasticsearch 找到进程号

然后kill -9 进程号

再启动下elasticsearch

我们用谷歌浏览器请求下 http://192.168.1.108:9200/

OK 出现这东西 才算配置完成;

Centos7中安装elasticsearch的更多相关文章

  1. Centos7 中安装Elasticsearch

    1.下载安装包 1.1 下载elasticsearch 7.13.3 curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/e ...

  2. 在Centos7中安装elasticsearch5.5

    在Centos7中安装elasticsearch5.5 第一步:必须要有jre支持 elasticsearch是用Java实现的,跑elasticsearch必须要有jre支持,所以必须先安装jre ...

  3. 在centos7中安装Robot Framework

    安装前景介绍: 最初,我们是在Windows环境下搭建Robot Framework来对我们的服务进行接口测试的(想知道如何在Windows下安装Robot Framework,可以参考我同事的博客h ...

  4. centos7中安装、配置、验证、卸载redis

    本文介绍在centos7中安装.配置.验证.卸载redis等操作,以及在使用redis中的一些注意事项. 一 安装redis 1 创建redis的安装目录 利用以下命令,切换到/usr/local路径 ...

  5. centos7中安装mongodb3.6

    centos7中安装mongodb3.6 首先更新系统 yum -y update 1.安装Mongodb 编辑Mongodb安装源 vim /etc/yum.repos.d/mongodb-org- ...

  6. centos7中安装mysql

    centos7中安装mysql网上已经很多资源了,我就不在赘述了.我这里只是记录下我安装的时候出现的一些问题. 原文:https://www.cnblogs.com/bigbrotherer/p/72 ...

  7. Centos7下安装Elasticsearch 5.6.6

    环境 因为elasticsearch是用java编写的,所以需要先安装JDK ES 5,安装需要 JDK 8 以上ES 6.5,安装需要 JDK 11 以上ES 7.2.1,内置了 JDK 12 安装 ...

  8. CentOS7中安装MySQL(简便)及 网站的搭建

    一.首先,我们需要配置CentOS7中网络环境的搭建,物理机IP为192.168.100.39,虚拟机IP为192.168.100.139,网络模式设置为桥接模式 ,再进入系统挂载光盘.输入命令   ...

  9. CentOS7中安装redis5.0

    1. 环境介绍 CentOS7 (未安装Development Tools) 2. 下载Redis5.0-rc3 wget -O redis-5.0-rc3.tar.gz https://github ...

随机推荐

  1. scala :: , +:, :+ , ::: , ++ 的区别

    4 种操作符的区别和联系 :: 该方法被称为cons,意为构造,向队列的头部追加数据,创造新的列表.用法为 x::list,其中x为加入到头部的元素,无论x是列表与否,它都只将成为新生成列表的第一个元 ...

  2. c# sql在where查询语句中使用字符串变量与int型变量

    使用where语句访问数据库时where语句用上文中以及定义过的变量来查询. string sql3 = string.Format("update Ships set ContainerN ...

  3. 『政善治』Postman工具 — 14、NewMan工具的使用详解

    目录 1.NewMan工具的介绍 2.NewMan的安装 (1)安装 (2)验证NewMan环境: (3)NewMan卸载命令 3.NewMan执行Postman测试集 (1)导出collection ...

  4. lighttpd 轻量级WEB服务器

    Lighttpd 是一款开源 Web 服务器软件.Lighttpd 安全快速,符合行业标准,适配性强并且针对高配置环境进行了优化.相对于其它的 Web 服务器而言,Lighttpd 占用内存更少:因其 ...

  5. 用navigation的大致图

  6. ubuntu下 SVN 服务器搭建及使用

    简化篇 http://blog.csdn.net/Eric_lmy/article/details/51942931 详细篇 1.安装Subversion ServerSubversion serve ...

  7. mysql数据库-运维合集

    目录 RDBMS 术语 整删改查操作 库操作 表操作 账号与授权 匹配符(条件查询) MySQL三大类数据类型 函数 其他操作 查看数据库的占用空间大小 开启慢查询 状态查询 字符集设置 忘记密码重置 ...

  8. Redis 内存大小限制+键值淘汰策略配置

    限制最大内存 windows 的 maxmemory-policy 策略可能会少一些 # 指定 Redis 最大内存限制,Redis 在启动时会把数据加载到内存中,达到最大内存后,Redis 会先尝试 ...

  9. GO学习-(11) Go语言基础之map

    Go语言基础之map Go语言中提供的映射关系容器为map,其内部使用散列表(hash)实现. map map是一种无序的基于key-value的数据结构,Go语言中的map是引用类型,必须初始化才能 ...

  10. Nginx限制访问速率和最大并发连接数模块--limit

    Nginx限制访问速率和最大并发连接数模块--limit Tengine版本采用http_limit_req_module进行限制 具体连接请参考 http://tengine.taobao.org/ ...