阅读 99

elasticsearch5.1.1 jdk8 linux centos7 全面安装教程

- 前提说明:
本人公司并没有使用elasticsearch,只是在网上看了许多帖子,和很多用人单位大数据方面的都有这些需求,个人所以选了elasticsearch开始学习!注意:该安装教程仅仅用于个人基础安装!
重要:es版本和jdk版本不同,安装有小的差异,各位小伙伴注意啦!

- 基础环境:
1. centos7 云服务器一台(我用的阿里云)
2. jdk环境变量已经配置完成(必须为jdk8,应为对应的es版本为5.1.1)

- 基础环境:
1. 在指定的目录下载elasticsearch

我的目录是 /alidata/server/dev/es5.1.1
执行下载命令 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz
下载完成后执行解压命令 tar -zxf elasticsearch-5.1.1.tar.gz

2.在指定目录进行启动

我的目录 /alidata/server/dev/es5.1.1/elasticsearch-5.1.1/bin
执行命令 ./elasticsearch

2 + 可能会报错

 Memory: 4k page, physical 1882680k(761304k free), swap 0k(0k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (25.111-b14) for linux-amd64 JRE (1.8.0_111-b14), built on Sep 22 2016 16:14:03 by "java_re" with gcc 4.3.0 20080428 (Red Hat 4.3.0-8)

time: Wed Jan 11 17:13:51 2017
elapsed time: 0 seconds (0d 0h 0m 0s)

这是因为es默认配置了jdk的内存大小,因为我的是自己的服务器所以内存特别小
需要修改配置 我的目录是 /alidata/server/dev/es5.1.1/elasticsearch-5.1.1/config (修改jvm.options)
默认的内存是 -Xms2g  -Xmx4g
修改为合适的内存 我修改为  -Xms1g  -Xmx1g

2 ++ 然后再继续执行第二步 ,可能会报错

[2017-01-12T10:50:36,371][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.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.cli.Command.main(Command.java:62) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.1.1.jar:5.1.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:100) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:176) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:306) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.1.1.jar:5.1.1]
    ... 6 more
大概的意思就是 不能用root账户执行 ,需切换一个非root账户进行启动执行
如何开通非root权限用户执行,请亲百度吧!这里给个参考资料

  1. 用非root账户进行启动,可能会报错
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 添加类似如下内容
vim /etc/security/limits.conf 
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
  1. 用非root账户进行启动,可能会报错
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

5.最后启动,发现启动成功

[2017-01-12T11:00:48,427][INFO ][o.e.n.Node               ] [] initializing ...
[2017-01-12T11:00:48,751][INFO ][o.e.e.NodeEnvironment    ] [K8LDTYN] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [29.9gb], net total_space [39.2gb], spins? [unknown], types [rootfs]
[2017-01-12T11:00:48,753][INFO ][o.e.e.NodeEnvironment    ] [K8LDTYN] heap size [1015.6mb], compressed ordinary object pointers [true]
[2017-01-12T11:00:48,758][INFO ][o.e.n.Node               ] node name [K8LDTYN] derived from node ID [K8LDTYNFSZSaYhYeIdCywQ]; set [node.name] to override
[2017-01-12T11:00:48,761][INFO ][o.e.n.Node               ] version[5.1.1], pid[2050], build[5395e21/2016-12-06T12:36:15.409Z], OS[Linux/3.10.0-514.2.2.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_111/25.111-b14]
[2017-01-12T11:00:52,391][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [aggs-matrix-stats]
[2017-01-12T11:00:52,396][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [ingest-common]
[2017-01-12T11:00:52,397][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [lang-expression]
[2017-01-12T11:00:52,397][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [lang-groovy]
[2017-01-12T11:00:52,397][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [lang-mustache]
[2017-01-12T11:00:52,398][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [lang-painless]
[2017-01-12T11:00:52,398][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [percolator]
[2017-01-12T11:00:52,399][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [reindex]
[2017-01-12T11:00:52,399][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [transport-netty3]
[2017-01-12T11:00:52,400][INFO ][o.e.p.PluginsService     ] [K8LDTYN] loaded module [transport-netty4]
[2017-01-12T11:00:52,405][INFO ][o.e.p.PluginsService     ] [K8LDTYN] no plugins loaded
[2017-01-12T11:00:59,810][INFO ][o.e.n.Node               ] initialized
[2017-01-12T11:00:59,814][INFO ][o.e.n.Node               ] [K8LDTYN] starting ...
[2017-01-12T11:01:00,495][INFO ][o.e.t.TransportService   ] [K8LDTYN] publish_address {115.28.155.28:9300}, bound_addresses {0.0.0.0:9300}
[2017-01-12T11:01:00,511][INFO ][o.e.b.BootstrapCheck     ] [K8LDTYN] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-01-12T11:01:03,768][INFO ][o.e.c.s.ClusterService   ] [K8LDTYN] new_master {K8LDTYN}{K8LDTYNFSZSaYhYeIdCywQ}{enLHEaL8QdyisjbNBpkp0A}{115.28.155.28}{115.28.155.28:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-01-12T11:01:03,846][INFO ][o.e.h.HttpServer         ] [K8LDTYN] publish_address {115.28.155.28:9222}, bound_addresses {0.0.0.0:9222}
[2017-01-12T11:01:03,847][INFO ][o.e.n.Node               ] [K8LDTYN] started
[2017-01-12T11:01:03,874][INFO ][o.e.g.GatewayService     ] [K8LDTYN] recovered [0] indices into cluster_state

5 + 可能会发现个问题,外网访问不了的情况,内网可以访问

内网查看是否可以访问(我改了启动端口,默认为9200)

[root@iZ28m8q4tgvZ elasticsearch-head]# curl http://127.0.0.1:9222
{
  "name" : "K8LDTYN",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "2KDpZHX6RTyNpm08lq3Jqg",
  "version" : {
    "number" : "5.1.1",
    "build_hash" : "5395e21",
    "build_date" : "2016-12-06T12:36:15.409Z",
    "build_snapshot" : false,
    "lucene_version" : "6.3.0"
  },
  "tagline" : "You Know, for Search"
}

外网发现ip加端口不能访问

解决办法如下:
我的目录 /alidata/server/dev/es5.1.1/elasticsearch-5.1.1/config
修改 elasticsearch.yml
修改 network.host: 0.0.0.0
  1. 最后再次启动,发现成功,外网也能访问了….

- 总结:
上面都是我遇到的问题,和大家分享,当然如果大家遇到其他问题,可以和我讨论,我也在学习研究中!
沟通qq:2502499681(请说明原因)

                                        **谢谢!**

?

原文:https://blog.51cto.com/rundreams/3311328

文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐