elasticsearch-5.1.2 安装,部署
1.准备好3个安装文件
部署elasticsearch-head-master该项目,可以查看elasticsearch的状态
apache-tomcat-8.5.9.tar.gz
elasticsearch-5.1.2.tar.gz
elasticsearch-head-master.zip
2.安装apache-tomcat-8.5.9
tar -zxvf apache-tomcat-8.5.9.tar.gz
3.安装elasticsearch-5.1.2
tar -zxvf elasticsearch-5.1.2.tar.gz
3.1安装好elasticsearch-5.1.2执行如下命令
./elasticsearch
报错:
[2017-01-14T18:35:29,164][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.1.2.jar:5.1.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:100) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:176) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:306) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.1.2.jar:5.1.2]
... 6 more
解决办法:
elasticsearch为了安全起见,不允许使用root用户进行直接操作,所以我们新创建一个用户
创建用户组
groupadd elsearch
创建用户
useradd elsearch -g elsearch -p elsearch
更改elasticsearch-5.1.2 文件夹及内部文件的所属用户及组为elsearch:elsearch
chown -R elsearch:elsearch /data/www/search/es/elasticsearch-5.1.2
切换到elsearch用户下进行执行,启动elasticsearch
停止elasticsearch
修改配置文件elasticsearch.yml
cluster.name: application
node.name: node-3
network.host: 192.168.100.12
http.port: 9200
多次启动以后,由于每一个线程启动以后占用文件个数限制导致elasticsearch无法启动,报错如下
ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2017-01-14T18:50:27,955][INFO ][o.e.n.Node ] [node-3] stopping ...
[2017-01-14T18:50:27,965][INFO ][o.e.n.Node ] [node-3] stopped
[2017-01-14T18:50:27,965][INFO ][o.e.n.Node ] [node-3] closing ...
[2017-01-14T18:50:27,977][INFO ][o.e.n.Node ] [node-3] closed
解决方法:
修改文件个数
vi /etc/sysctl.conf
vm.max_map_count=655360
fs.file-max = 6815744
并执行命令:
sysctl -p
修改文件限制数和进程限制数
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vi /etc/security/limits.d/90-nproc.conf
修改如下内容:
* soft nproc 1024
#修改为
* soft nproc 2048
3.2在浏览器的地址栏输入 http://192.168.100.12:9200
若出现如下界面
{
"name" : "node-3",
"cluster_name" : "application",
"cluster_uuid" : "YgeNRQvxRn2mTpWxUWM34A",
"version" : {
"number" : "5.1.2",
"build_hash" : "c8c4c16",
"build_date" : "2017-01-11T20:18:39.146Z",
"build_snapshot" : false,
"lucene_version" : "6.3.0"
},
"tagline" : "You Know, for Search"
}
恭喜你,elasticsearch
3.3安装elasticsearch-head-master来管理elasticsearch的状态
unzip elasticsearch-head-master.zip
3.4 将elasticsearch-head-master解压以后的_site目录拷贝到tomcat的webapp目录下面,启动tomcat
cp -R /data/www/search/es/elasticsearch-head-master/_site /data/www/search/es/apache-tomcat-8.5.9/webapps/
3.5 修改elasticsearch-head-master中的配置文件,执行elasticsearch可以访问的路径
修改_site/app.js第4328行,将localhost修改成机器的IP
3.6 启动tomcat,出现如下界面,恭喜你,安装成功
---------------------
作者:王stone
来源:CSDN
原文:https://blog.csdn.net/wangguoqing_it/article/details/70762743
版权声明:本文为博主原创文章,转载请附上博文链接!
网友评论