centos7 安装 elasticsearch.7.2.0

centos7 安装 elasticsearch.7.2.0

本篇文章是记录了我安装elasticsearch 的过程和遇到的坑的解决办法,我之前曾经安装过几次都失败了,这次成功我还是遇到了不少坑,安装简单,但是避坑难。我会按照步骤来讲一下坑的解决办法。

一、获取安装包

两种方法,一种直接到官网或者国内镜像网站下载(推荐一个网站:速度很快:es国内镜像)还有通过wget 来下载。

wget https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.2.0-linux-x86_64.tar.gz

二、解压安装软件配置

1、解压elasticsearch压缩文件
tar -zxvf  elasticsearch-7.2.0.tar.gz
2、进入解压后的elasticsearch目录
2.1 新建数据文件
mkdir -p data
2.2 修改config/elasticsearch.yml:
vim config/elasticsearch.yml

在文件里面修改成一下内容:

cluster.name: my-cluster #集群名称
node.name: node-1 #节点名称
#数据和日志的存储目录
path.data: /home/software/elasticsearch-6.8.3/data
path.logs:/home/software/elasticsearch-6.8.3/logs
#设置绑定的ip,设置为0.0.0.0以后就可以让任何计算机节点访问到了
network.host: 0.0.0.0
http.port: 9200 #端口
#设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前是单机,放入一个节点即可
cluster.initial_master_nodes: ["node-1"]

三、启动elasticsearch

1、启动需要切换成非root 用户
su xxxx
./elasticsearch-6.8.3/bin/elasticsearch
2、修改配置文件
2.1 修改节点名称 :一个是cluster.name还有一个是node.name修改节点名
2.2 修改集群网络配置

在这里插入图片描述

2.3 设置密码

先设置X-pack

#----------------------------------- X-Pack ------------------------------------
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true

重启elasticsearch

./elasticsearch -d
./elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y   #y同意

#依次设置以下一个账号的密码
Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana]: 
Reenter password for [kibana]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Passwords do not match.
Try again.
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 
Changed password for user [apm_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
3、开始遇到坑,我们来填坑
3.1坑一

错误信息:

 max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

原因是进程不够用了
解决方法:
切换到root用户,修改文件

vi /etc/security/limits.conf

//在文件末尾添加下面的参数值

* soft nofile 65536
* hard nofile 65536

在这里插入图片描述
在切换到普通用户,使用命令查看进程数

ulimit -Hu
ulimit -Su

保存并退出,再次启动es

3.2 坑二

错误信息:

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)

解决方法:
修改elasticsearch下config jvm.options

vim ./config/jvm.options 

修改该内容:

 -Xms512m
 -Xmx512m

在这里插入图片描述
保存并退出,再次启动es

3.3 坑三

错误信息:

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

原因:elasticsearch用户拥有的内存权限太小,至少需要262144;

解决方法:
切换到root用户

执行命令:

sysctl -w vm.max_map_count=262144

查看结果:

sysctl -a|grep vm.max_map_count

显示:

vm.max_map_count = 262144

上述方法修改之后,如果重启虚拟机将失效,所以:

在 /etc/sysctl.conf文件最后添加一行

vm.max_map_count=262144

即可永久修改

保存并退出,重启一下系统然后再次重启es

在这里插入图片描述
成功!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值