Elasticsearch在Centos 7上的安装与配置及可能出现的问题

环境的搭建

配置前的准备工作

  • 1.编辑网卡
    vi /etc/sysconfig/network-scripts/ifcfg-en33
  • 2.重启网络服务
    systemctl restart network.service
  • 3.关闭防火墙
    systemctl stop firewalld.service
  • 4.设置防火墙开机不启动
    systemctl disable firewalld.service
  • 5.查看防火墙运行状态
    firewall-cmd --state
  • 6.查看IP
    ip addr
    1.安装java环境
es要求JDK版本1.8以上

2.安装 Elasticsearch

使用wget命令下载安装包到本地

wget
 https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.2.tar.gz

解压到/usr/local/

tar -zxvf elasticsearch-6.4.2.tar.gz -C /usr/local/

3.运行Elasticsearch

Elasticsearch 要求不能使用超级用户root运行,所以我们建立一个esuser账号

# 创建esuser账户
adduser esuser
# 修改密码
passwd esuser

然后,给esuser用户elasticsearch目录的授权。

chown -R esuser /usr/local/elasticsearch-6.4.2/

切换至elasticsearch目录,并以esuser用户运行

cd /usr/local/elasticsearch-6.4.2
su esuser

运行elasticsearch,如果想后台运行后面加 -d

./bin/elasticsearch

如果没有没有error,就运行成功啦

新开一个终端,用curl访问

[root@es ~]# curl -XGET 'http://localhost:9200?pretty'
{
  "name" : "eXXXFT6",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "VO4MJrYART-ekstJ-2n74A",
  "version" : {
    "number" : "6.4.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "04711c2",
    "build_date" : "2018-09-26T13:34:09.098244Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

3.其他配置

elasticsearch指定ip地址

编辑es的配置文件

vi ./config/elasticsearch.yml

找到network.host: 一行,去除#号,修改为:

network.host: 0.0.0.0

可能遇到的问题

问题一

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

max_map_count 的值是指一个进程最多可用于的内存映射区(memory map areas),在调用malloc会用到,由mmap/mprotect生成。

解决办法:

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

su root
vi /etc/sysctl.conf

加入

vm.max_map_count=655360

然后使其生效

sysctl -p

问题二

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

文件描述符太低

解决办法:

切换到root用户修改/etc/security/limits.conf

su root
vi /etc/security/limits.conf

加入

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096 

问题三

使用supervisor启动时,查看日志仍然报下面的错误

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

解决办法:

切换到root用户修改vi /etc/supervisord.d/elasticsearch.conf

[supervisord]
minfds=65536
minprocs=32768

[program:es]
process_name=%(program_name)s_%(process_num)02d
directory=/usr/local/elasticsearch-5.6.3/
command=/usr/local/elasticsearch-5.6.3/bin/elasticsearch
;autostart=true
autorestart=false
user=esuser
numprocs=1

到此es的配置及问题就全部解决了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值