摘要:elasticsearch5.6.1集群与问题总结
前置
接着上一篇:大数据学习[06]:elasticsearch5.6.1初探
前面只是感性地看了一眼elasticsearch,还未知道方向,今天学习了一下集群的内容,并把一些数据加入其中,进行了搜索。
配置
位置:elasticsearch/config/elasticsearch.yml
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# 集群名
cluster.name: es-app
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# 节点名
node.name: node-40
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
# 内存/这个跟系统有关的,如果系统底会出现版本太底的错误
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
# 绑定地址
network.host: 主机IP
#
# Set a custom port for HTTP:
# http端口,外部通这个来请求数据;tcp:端口; 当在一台主机上配置多个节点时,这个一定要配置的。
http.port: 9200
transport.tcp.port: 9300
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
# 这个节点的IP:port;默认的是这个端口,在一台机器配置多节点一定要加上port
discovery.zen.ping.unicast.hosts: ["192.168.7.38:9300", "192.168.7.39:9300","192.168.7.40:9300"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
# 防止脑裂
discovery.zen.minimum_master_nodes: 1
配置好之后,向其它节点复制过去就可以了,然后在各个节点把node.name与IP修改就可以了。
启动
每个节点都要手动去开启:启动顺序node-38>node-39>node-40; 每增加一台,前面启动的就会显示增加一台主机的信息:
[2017-09-22T09:56:26,479][INFO ][o.e.c.s.ClusterService ] [node-38] added {{node-39}{x0yI1A95Rem8YPN-W78OQA}{dz54jd_tT3GZ_9briOFjHA}{192.168.137.38}{192.168.137.39:9300}{ml.max_open_jobs=10, ml.enabled=true},}, reason: zen-disco-node-join[{node-39}{x0yI1A95Rem8YPN-W78OQA}{dz54jd_tT3GZ_9briOFjHA}{192.168.137.38}{192.168.137.39:9300}{ml.max_open_jobs=10, ml.enabled=true}]
启动问题
问题1
ERROR: [4] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决在linux系统:vim /etc/security/limits.conf
编辑该文件,后面加上[最前面的hadoop是用户名]:
hadoop soft nofile 65536
hadoop hard nofile 65536
问题2
[2]: max number of threads [1024] for user [hadoop] is too low, increase to at least [2048]
vim /etc/security/limits.d/90-nproc.conf
* soft nproc 2048
root soft nproc unlimited
问题3
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方法:
修改sysctl文件:vi /etc/sysctl.conf ,增加下面配置项:
增加改行配置:vm.max_map_count=655360
保存退出后,执行:
sysctl -p
问题4
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
原因:
这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。
解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
这个设置好,连系统版提示也好了。
问题5
[5] IK加载卡死
有时候会卡死在这里:
[2017-09-22T09:55:19,443][INFO ][o.w.a.d.Monitor ] try load config from /home/hadoop/elasticsearch-5.6.1/config/analysis-ik/IKAnalyzer.cfg.xml
这个重启一下就好。
问题6
[6]JDK问题,要求1.8以上
机器可能会抛出JDK版本不够的异常,在[${elasticsearch_home}/bin/elasticsearch]增加:
export JAVA_HOME={dk1.8.0_101[HOME]}
export PATH=$JAVA_HOME/bin:$PATH
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="/opt/jdk1.8.0_101/bin/java"
else
JAVA=`which java`
fi
问题7
要创建一个非root用户,root用户不行。
问题8
IP与端口问题
配置文件里面写的端口与IP是什么样,访问的时间就用什么样来访问。host配置的好像对这个不喜作用,调用curl时就很显示出现这个问题。例如,配置了主机192.168.137.3:9200在本机用localhost:9200访问是有问题的。
问题9
python API有密码与用户的错误:
这个是因为X-PACK的安全模块引起的。
elasticsearch.exceptions.AuthenticationException: TransportError(401, 'security_exception', 'missing authentication token for REST request [/index]')
解决:
user:secret@ip:port 这样来请求就可以了。
python 操作Elasticsearch 的详情:
http://elasticsearch-py.readthedocs.io/en/master/api.html
演示
来一批量文本,1.5万笔记录,took:36ms;还是挺快的
【作者:happyprince,http://blog.csdn.net/ld326/article/details/78066952】