elasticsearch 6.5.4集群 安装在centos 6.5 一主两从
系统环境
3台阿里云centos 6.5 8G内存
elasticsearch部署一主两从
查看centos版本
lsb_release -a
CentOS release 6.5 (Final)
java安装(3台分别安装)
yum list installed | grep java
yum -y list java*
yum install java-1.8.0-openjdk.x86_64
elasticsearch安装(3台分别安装)
cd /data/eshome
mkdir es
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.zip
unzip elasticsearch-6.5.4.zip
mv elasticsearch-6.5.4 es
cd es
关闭防火墙(centos6.5)(3台分别执行)
service iptables stop
chkconfig iptables off
service iptables status
#因阿里云服务器有防火墙设置,这里关闭系统自带防火墙
创建elasticsearch用户(3台分别执行)
es 规定 root 用户不能启动 es,所以需要创建一个用户来启动 es
# 创建用户名为 es 的用户
useradd es
# 设置 es 用户的密码
passwd es
#pass:123456
# 将 /data/eshome/es 的拥有者设置为 es
chown -R es:es /data/eshome/es
配置阿里云服务器(ECS)内网hosts(3台分别配置)
vim /etc/hosts:
#elasticsearch
111.111.111.111 es-node-1
222.222.222.222 es-node-2
333.333.333.333 es-node-3
#以上ip为虚拟ip,实际是阿里内网IP,内网互通速度更快流量免费,不作为外网访问地址,需要这3台主机hosts文件设置,
编辑elasticsearch配置文件(3台分别配置)
node-1服务器 vim config/elasticsearch.yml
cluster.name: searchname
node.name: node-1
network.host: 0.0.0.0
network.publish_host: es-node-1
#默认访问端口
#http.port: 9200
#集群主机互相访问地址
discovery.zen.ping.unicast.hosts: ["node-2", "node-3"]
#防止脑裂
discovery.zen.minimum_master_nodes: 2
#锁定物理内存
bootstrap.memory_lock: true
#阿里云服务器报错解决
bootstrap.system_call_filter: false
#以下head插件用(可选)
http.cors.enabled: true
http.cors.allow-origin: "*"
node-2服务器 vim config/elasticsearch.yml
cluster.name: searchname
node.name: node-2
network.host: 0.0.0.0
network.publish_host: es-node-2
#默认访问端口
#http.port: 9200
#集群主机互相访问地址
discovery.zen.ping.unicast.hosts: ["node-1", "node-3"]
#防止脑裂
discovery.zen.minimum_master_nodes: 2
#锁定物理内存
bootstrap.memory_lock: true
#阿里云服务器报错解决
bootstrap.system_call_filter: false
#以下head插件用(可选)
http.cors.enabled: true
http.cors.allow-origin: "*"
node-3服务器 vim config/elasticsearch.yml
cluster.name: searchname
node.name: node-3
network.host: 0.0.0.0
network.publish_host: es-node-3
#默认访问端口
#http.port: 9200
#集群主机互相访问地址
discovery.zen.ping.unicast.hosts: ["node-1", "node-2"]
#防止脑裂
discovery.zen.minimum_master_nodes: 2
#锁定物理内存
bootstrap.memory_lock: true
#阿里云服务器报错解决
bootstrap.system_call_filter: false
#以下head插件用(可选)
http.cors.enabled: true
http.cors.allow-origin: "*"
安装elasticsearch-head插件(可以安装在其中一台、也可以安装在其他服务器)
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
启动elasticsearch(3台分别启动)
切换到 es 用户,启动 es
su es
前台启动:./bin/elasticsearch
后台启动:./bin/elasticsearch -d
关闭后台启动:
ps -ef | grep elasticsearch
kill -9 [进程号]
Elasticsearch启动常见问题(可以启动之前先配置好)
问题1:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决方法:
#切换到root用户修改 vim /etc/security/limits.conf # 在最后面追加下面内容 es hard nofile 65536 es soft nofile 65536
修改后重新登录 es 用户,使用如下命令查看是否修改成功
ulimit -Hn 65536
问题2:
max number of threads [1024] for user [es] is too low, increase to at least [4096]
解决方法:vi /etc/security/limits.d/90-nproc.conf ,修改配置如下:
* soft nproc 1024
增加:
#es用户名
es soft nproc 4096
问题3:
ERROR: [3] bootstrap checks failed
max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
修改:vim /etc/security/limits.conf
soft nofile 65536
问题4:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方法: 提高vm.max_map_count 的大小
# 切换到root用户 vim /etc/sysctl.conf # 在最后面追加下面内容 vm.max_map_count=262144 # 使用 sysctl -p 查看修改后的结果 sysctl -p
问题5:
memory locking requested for elasticsearch process but memory is not locked
原因:锁定内存失败
解决方法:
需要修改
vim /etc/security/limits.conf
es soft memlock unlimited
es hard memlock unlimited
修改:vim /etc/sysctl.conf
vm.swappiness=0
以上修改之后重启机器
问题6:
Likely root cause: java.nio.file.AccessDeniedException: /data/eshome/es/config/elasticsearch.keystore
设置用户权限
chown -R es:es /data/eshome/es
参考:
更多推荐
所有评论(0)