centos7环境Elasticsearch5.5.2安装

Elasticsearch安装

1、下载ES

2、修改配置

修改conifig/elasticsearch.yml(主节点)
cluster.name: ahszf-application
node.name: node-1-master-175-9200
node.master: true
#node.attr.rack: r1
node.data: true
path.data: /usr/local/elasticsearch/elasticsearch-5.5.2/data
path.logs: /usr/local/elasticsearch/elasticsearch-5.5.2/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.1.175
http.port: 9200
transport.tcp.port: 9300

#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点。
discovery.zen.ping.unicast.hosts: ["192.168.1.175:9300"]
# 为了避免脑裂,集群节点数最少为 半数+1
discovery.zen.minimum_master_nodes: 1
#discovery.zen.ping_timeout: 120s
#gateway.recover_after_nodes: 2
#gateway.recover_after_time: 5m
#gateway.expected_nodes: 1
#script.engine.groovy.inline.search: on
#script.engine.groovy.inline.aggs: on
#indices.recovery.max_bytes_per_sec: 20mb
node.max_local_storage_nodes: 3
action.destructive_requires_name: false
# 增加新的参数,这样head插件可以访问es,解决跨域访问问题
http.cors.enabled: true
http.cors.allow-origin: "*"

从节点

cluster.name: ahszf-application
node.name: node-2-176-9200
node.master: false
#node.attr.rack: r1
node.data: true
path.data: /usr/local/elasticsearch/elasticsearch-5.5.2/data
path.logs: /usr/local/elasticsearch/elasticsearch-5.5.2/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300

#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点。
discovery.zen.ping.unicast.hosts: ["192.168.1.175:9300"]
# 为了避免脑裂,集群节点数最少为 半数+1
discovery.zen.minimum_master_nodes: 1
#discovery.zen.ping_timeout: 120s
#gateway.recover_after_nodes: 2
#gateway.recover_after_time: 5m
#gateway.expected_nodes: 1
#script.engine.groovy.inline.search: on
#script.engine.groovy.inline.aggs: on
#indices.recovery.max_bytes_per_sec: 20mb
node.max_local_storage_nodes: 3
action.destructive_requires_name: false
# 增加新的参数,这样head插件可以访问es,解决跨域访问问题
http.cors.enabled: true
http.cors.allow-origin: "*"

3、新建用户es,分配文件权限

es启动需要在非root账号下,所以需要新建一个用户。新建用户后,需要分配文件权限,否则会报错:

groupadd es
useradd es -g es -p es
chown -R es:es  /usr/local/elasticsearch
chmod 775 /usr/local/elasticsearch

可能的报错:

java.nio.file.AccessDeniedException: 或
bash: ./elasticsearch: Permission denied

4、 启动,报错处理

启动命令 ./bin/elasticsearch
查看日志和报错:

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [65535] 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]

原因
每个进程最大打开文件数大小太小,用户拥有的内存权限太小,查看命令如下:
ulimit -Hn
ulimit -Sn

解决
切换到root账户下:
vi /etc/security/limits.conf添加或修改以下配置(用户退出后重新登录生效):

* hard nofile 65536
* soft nofile 65536

然后修改内存分配:
sudo sysctl -w vm.max_map_count=262144

5、重启脚本


#!/bin/sh

NAME=elasticsearch
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -9 $id
echo "killed $id"
done
/usr/local/elasticsearch/elasticsearch-5.5.2/bin/elasticsearch -d
tail -300f /usr/local/elasticsearch/elasticsearch-5.5.2/logs/ahszf-application.log
echo "---------------"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

坚持是一种态度

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值