Centos7下安装ElasticSearch及常见错误

1. 下载安装包并解压

下载地址

在这里插入图片描述

  • 或直接在虚拟机中输入:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz

  • 解压

tar -zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz

2. 配置

  • 在文件末尾添加如下配置

[root@ywq5 ~]# vim /etc/security/limits.conf

* soft nofile 65536
* hard nofile 131072 
* soft nproc 2048
* hard nproc 4096
  • 修改/etc/security/limits.d/20-nproc.conf

[root@ywq5 ~]# $sudo vim /etc/security/limits.d/90-nproc.conf

* soft nproc 4096
#将该条目修改成4096
  • 在/etc/sysctl.conf文件末尾添加

vm.max_map_count=655360

  • 然后

[root@ywq5 ~]# sysctl -p

  • 进入Elasticsearch安装目录

[root@ywq5 ywq]# cd elasticsearch-5.6.2/

  • 创建Elasticsearch数据文件夹data

[root@ywq5 ywq]# mkdir data

  • 创建Elasticsearch日志文件夹log

[root@ywq5 ywq]# mkdir log

  • 修改Elasticsearch配置文件

[root@ywq5 ywq]# vim /config/elasticsearch.yml

cluster.name: es-cluster
#设置集群的名称
node.name: es-node 
#修改当前节点的名称
path.data: /usr/ywq/elasticsearch-7.0.0/data
#修改数据路径
path.logs: /usr/ywq/elasticsearch-7.0.0/logs 
#修改日志路径
bootstrap.memory_lock: false
#设置ES节点允许内存交换
bootstrap.system_call_filter: false 
#禁用系统调用过滤器
network.host: 192.168.xx.xx
#设置当前主机名称,默认只允许本机访问,改为0.0.0.0后可以让任何人访问,这里我们改成自己的ip即可。
discovery.zen.ping.unicast.hosts: ["192.168.xx.xx"]    
#设置集群的主机列表

3. 启动Elasticsearch

[root@ywq5elasticsearch-7.0.0]#bin/elasticsearch

  • 发现报错: java.lang.RuntimeException:can not run elasticsearch as root

  • 报错原因:elasticsearch不允许使用root用户启动

  • 解决方法一:

在执行elasticsearch时加上参数-Des.insecure.allow.root=true

bin/elasticsearch -Des.insecure.allow.root=true
  • 解决方法二:

在elasticsearch执行文件中添加ES_JAVA_OPTS="-Des.insecure.allow.root=true"

[外链图片转存失败(img-37p4atk7-1563097021987)(https://github.com/yinwenqing/MyPostImage/blob/master/elasticsearch2.jpg?raw=true)]
这样以后就不用添加参数也可以以root身份运行了

  • 解决方法三:

添加一个用户

adduser ***   //添加用户
passwd ***  //给用户赋值

添加完用户之后:

用root用户执行 : chown -R 文件夹名 用户名

将所在的文件夹及解压完的文件夹权限给你新建的用户。之后再使用新用户启动就OK了。

然后使用bin/elasticsearch 就可以启动elasticsearch了,或者使用bin/elasticsearch -d命令在后端启动

4. 其他常见错误

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

这个是因为/etc/sysctl.conf文件中修改不成功导致的

  • 切换到root用户修改配置sysctl.conf

vi /etc/sysctl.conf

添加下面配置:
vm.max_map_count=655360

并执行命令:
sysctl -p

    1. max number of threads [40] for user [ywq] is too low, increase to at least [2048]

设置/etc/security/limits.conf

# 结尾部分
* soft nofile 65536
* hard nofile 131072 
* soft nproc 2048
* hard nproc 4096

然后重启服务器生效

    1. org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: Property [elasticsearch.version] is missing for plugin [head]

原因:elasticsearch新版本是不允许安装插件在文件目录plugins下面的
解决:将plugins下面的插件目录放到其他目录即可

    1. BindTransportException[Failed to bind to [9300-9400]]; nested: BindException[Can’t assign requested address]

打开配置文件elasticsearch.yml 将 network.host: 192.168.0.1 修改为本机IP 0.0.0.0

    1. JNA Warning: IOException removing temporary files: JNA temporary directory ‘/home/yutao/tmp/elasticsearch’ is not writable

在jvm.options 末尾加上下面的配置信息

-Djava.io.tmpdir=/home/yutao/tmp/elasticsearch
-Djna.tmpdir=/home/yutao/tmp/elasticsearch
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值