一、因Elasticsearch是基于Java写的,因此它的运行环境中须要java的支持,在Linux下执行命令:java -version,检查Jar包是否安装java
安装java版本至少是1.8以上node
二、首先准备下载Elasticsearch5.5.2 安装包linux
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gzexpress
三、下载到/usr/local 目录下,解压bootstrap
tar -zxvf elasticsearch-5.2.2.tar.gzvim
四、由于Elasticsearch5.0以后,不能使用root帐户启动,咱们先建立一个elasticsearch组和帐户app
groupadd elasticsearchless
useradd elasticsearch -g elasticsearch -p elasticsearchcurl
chown -R elasticsearch:elasticsearch elasticsearch-5.2.2elasticsearch
或者sudo chown -R myes elasticsearch
五、启动elasticsearch
cd /usr/local/elasticsearch5.2.2/
su elasticsearch
./bin/elasticsearch
这时候咱们看见下面的提示,说明就成功了
这时候咱们看见下面的提示,说明就成功了
[plain] view plain copy
执行 curl http://localhost:9200
打开另外一个终端进行测试:
curl 'http://localhost:9200/?pretty'
你能看到如下返回信息:
{
"status": 200,
"name": "Shrunken Bones",
"version": {
"number": "1.4.0",
"lucene_version": "4.10"
},
"tagline": "You Know, for Search"
}
说明安装成功。
可是咱们但愿可以使用ip访问,那么还须要设置相关内容
跳转到Elasticsearch的config配置文件下,使用vim打开elasticsearch.yml,找到里面的"network.host",将其改成本机IP,保存。
cd elasticsearch/config/
vim elasticsearch.yml
重启ElasticSearch,而后使用http://192.168.37.137:9200/访问。
咱们常见错误:
问题一:警告提示
[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
at org.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]
报了一大串错误,其实只是一个警告。
解决:使用心得linux版本,就不会出现此类问题了。
问题二:ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]
解决:切换到root用户,编辑limits.conf 添加相似以下内容
vi /etc/security/limits.conf
添加以下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
问题三:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]
解决:切换到root用户,进入limits.d目录下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
修改以下内容:
* soft nproc 1024
#修改成
* soft nproc 2048
问题四:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
解决:切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
而后,从新启动elasticsearch,便可启动成功。
启动elasticsearch 报以下错误:
[2017-05-10T10:04:50,648][WARN ][o.e.b.JNANatives ] unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:363) ~[elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:638) ~[elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:215) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:99) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:204) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:360) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:58) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.cli.Command.main(Command.java:88) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.3.2.jar:5.3.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.3.2.jar:5.3.2]
解决方法:
修改elasticsearch.yml 添加一下内容
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
常见问题:http://blog.csdn.net/u012246178/article/details/63253531
再次启动linux可能出现以下相似错误
bootstrap checks failed
max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
解决方案
一、vi /etc/sysctl.conf
设置fs.file-max=655350
保存以后sysctl -p使设置生效
二、vi /etc/security/limits.conf 新增
* soft nofile 655350
* hard nofile 655350
三、从新使用SSH登陆,再次启动elasticsearch便可。
外网访问:serverip:9200/