官方地址
https://www.elastic.co/downloads/elasticsearch
解压
tar -zxvf elasticsearch-5.3.2.tar.gz
启动
运行
bin/elasticsearch
(注:Windows平台运行bin\elasticsearch.bat)
报错
不允许使用root用户执行
[root@scanner-sec bin]# ./elasticsearch
[2017-05-02T17:14:36,120][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
解决方案一:Des.insecure.allow.root=true
修改/usr/local/elasticsearch-2.4.0/bin/elasticsearch,添加 ES_JAVA_OPTS=”-Des.insecure.allow.root=true”
或执行时添加: sh /usr/local/elasticsearch-2.4.0/bin/elasticsearch -d -Des.insecure.allow.root=true
注意:正式环境用root运行可能会有安全风险,不建议用root来跑。
解决方案二:添加专门的用户
useradd elastic
chown -R elastic:elastic elasticsearch-5.3.2
su elastic
cd /server/elasticsearch-5.3.2/bin/
sh elasticsearch -d
访问ES
curl http://localhost:9200/
安装成功
{
"name" : "FFg-8sN",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "xxxxxx",
"version" : {
"number" : "5.3.2",
"build_hash" : "3068195",
"build_date" : "2017-04-24T16:15:59.481Z",
"build_snapshot" : false,
"lucene_version" : "6.4.2"
},
"tagline" : "You Know, for Search"
}
增加外网访问权限
按照默认配置安装,可以访问127.0.0.1:9200,但不能访问外部IP:9200
解决办法:
找到Elasticsearch的配置文件,修改下network.host即可。
修改配置文件 config/elasticsearch.yml
network.host: 0.0.0.0
查看端口情况
netstat -an | grep 9200
查看es运行情况
报错1
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
由于elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配
vim config/jvm.options
-Xms2g
-Xmx2g
修改为
-Xms512m
-Xmx512m
报错2
max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]
修改 /etc/security/limits.d/90-nproc.conf 从1024改成2048
- soft nproc 1024
- soft nproc 2048
报错3
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf配置文件,
cat /etc/sysctl.conf | grep vm.max_map_count
vm.max_map_count=262144
如果不存在则添加
echo “vm.max_map_count=262144” >>/etc/sysctl.conf
运行命令使生效:sysctl -p
报错4
max file descriptors [65535] for elasticsearch process likely too low, increase to at least [65536]
ulimit -n 65536
报错5
启动异常:ERROR: bootstrap checks failed
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.1默认
bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。详见:https://github.com/elastic/elasticsearch/issues/22899
解决方法:在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false