elasticsearch5.5安装部署
Posted ilifeilong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch5.5安装部署相关的知识,希望对你有一定的参考价值。
Elasticsearch5.5下载
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.tar.gz
JDK1.8下载
1. 新建用户,并为用户配置环境变量
[[email protected]04 ~]# groupadd -r dba [[email protected]-sgmhadoopdn-04 ~]# useradd -r elsearch -g dba -d /home/elsearch [[email protected]-sgmhadoopdn-04 ~]# cat /home/elsearch/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export JAVA_HOME=/usr/java/jdk1.8.0_111 export ES_HOME=/usr/local/elasticsearch export PATH=$JAVA_HOME/bin:$ES_HOME/bin:$PATH:$mysql_HOME/bin
2. 系统和内核参数优化
[[email protected]04 ~]# echo "elsearch soft nproc 8192" /etc/security/limits.conf [[email protected]-sgmhadoopdn-04 ~]# echo "elsearch hard nproc 16384" /etc/security/limits.conf [[email protected]-sgmhadoopdn-04 ~]# echo "elsearch soft nofile 4096" /etc/security/limits.conf [[email protected]-sgmhadoopdn-04 ~]# echo "elsearch hard nofile 65536" /etc/security/limits.conf [[email protected]-sgmhadoopdn-04 ~]# echo "vm.max_map_count=655360" /etc/sysctl.conf [[email protected]-sgmhadoopdn-04 ~]# sysctl -p
注:如果不进行参数优化,启动elasticsearch时候可能会报如下错误
[2018-09-07T09:55:27,564][INFO ][o.e.b.BootstrapChecks ] [sht-sgmhadoopdn-04] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks ERROR: [2] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] [2018-09-07T09:55:27,572][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] stopping ... [2018-09-07T09:55:27,604][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] stopped [2018-09-07T09:55:27,604][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] closing ... [2018-09-07T09:55:27,613][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] closed
注:运行elasticsearch的用户最好为elsearch,我曾试着用mysqladmin用户运行elasticsearch,但是会报java版本不匹配的错,实际上我的mysqladmin用户的环境变量里已经配置了java,并且已经生效,但是elasticsearch还是读取系统全局的变量,暂时不清楚原因,可以理解为一个未知的bug吧
[[email protected]04 bin]$ ./elasticsearch --help Elasticsearch requires at least Java 8 but your Java version from /bin/java does not meet this requirement [[email protected]-sgmhadoopdn-04 bin]$ java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode) [[email protected]-sgmhadoopdn-04 bin]$ which java /usr/java/jdk1.8.0_111/bin/java [[email protected]-sgmhadoopdn-04 bin]$ /bin/java -version java version "1.7.0_40" Java(TM) SE Runtime Environment (build 1.7.0_40-b43) Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
3.修改elasticsearch配置文件
[[email protected]04 config]$ cat elasticsearch.yml | grep -v "$^" | grep -v "^#" cluster.name: mycluster node.name: sht-sgmhadoopdn-04 node.attr.rack: r1 path.data: /usr/local/elasticsearch/data path.logs: /usr/local/elasticsearch/logs network.host: 172.16.101.66 http.port: 9200 [[email protected]-sgmhadoopdn-04 config]$ mkdir /usr/local/elasticsearch/{data,log}
4.启动elasticsearch
[[email protected]04 ~]$ cd /usr/local/elasticsearch/bin [[email protected]-sgmhadoopdn-04 bin]$ ./elasticsearch [2018-09-07T10:08:08,689][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] initializing ... [2018-09-07T10:08:08,812][INFO ][o.e.e.NodeEnvironment ] [sht-sgmhadoopdn-04] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [67.6gb], net total_space [76.4gb], spins? [unknown], types [rootfs] [2018-09-07T10:08:08,812][INFO ][o.e.e.NodeEnvironment ] [sht-sgmhadoopdn-04] heap size [1.9gb], compressed ordinary object pointers [true] [2018-09-07T10:08:08,813][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] node name [sht-sgmhadoopdn-04], node ID [DI0-2k8sTlevPq1S5uPb2Q] [2018-09-07T10:08:08,814][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] version[5.5.0], pid[23592], build[260387d/2017-06-30T23:16:05.735Z], OS[Linux/3.10.0-514.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_111/25.111-b14] [2018-09-07T10:08:08,814][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+DisableExplicitGC, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/elasticsearch] [2018-09-07T10:08:09,836][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [aggs-matrix-stats] [2018-09-07T10:08:09,836][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [ingest-common] [2018-09-07T10:08:09,836][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [lang-expression] [2018-09-07T10:08:09,836][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [lang-groovy] [2018-09-07T10:08:09,837][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [lang-mustache] [2018-09-07T10:08:09,837][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [lang-painless] [2018-09-07T10:08:09,837][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [parent-join] [2018-09-07T10:08:09,837][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [percolator] [2018-09-07T10:08:09,837][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [reindex] [2018-09-07T10:08:09,837][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [transport-netty3] [2018-09-07T10:08:09,837][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] loaded module [transport-netty4] [2018-09-07T10:08:09,837][INFO ][o.e.p.PluginsService ] [sht-sgmhadoopdn-04] no plugins loaded [2018-09-07T10:08:11,723][INFO ][o.e.d.DiscoveryModule ] [sht-sgmhadoopdn-04] using discovery type [zen] [2018-09-07T10:08:12,377][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] initialized [2018-09-07T10:08:12,377][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] starting ... [2018-09-07T10:08:12,520][INFO ][o.e.t.TransportService ] [sht-sgmhadoopdn-04] publish_address {172.16.101.66:9300}, bound_addresses {172.16.101.66:9300} [2018-09-07T10:08:12,531][INFO ][o.e.b.BootstrapChecks ] [sht-sgmhadoopdn-04] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks [2018-09-07T10:08:15,589][INFO ][o.e.c.s.ClusterService ] [sht-sgmhadoopdn-04] new_master {sht-sgmhadoopdn-04}{DI0-2k8sTlevPq1S5uPb2Q}{K1mYnJZ-Q1mnFg3iZCnEbw}{172.16.101.66}{172.16.101.66:9300}{rack=r1}, reason: zen-disco-elected-as-master ([0] nodes joined) [2018-09-07T10:08:15,634][INFO ][o.e.h.n.Netty4HttpServerTransport] [sht-sgmhadoopdn-04] publish_address {172.16.101.66:9200}, bound_addresses {172.16.101.66:9200} [2018-09-07T10:08:15,634][INFO ][o.e.n.Node ] [sht-sgmhadoopdn-04] started [2018-09-07T10:08:15,673][INFO ][o.e.g.GatewayService ] [sht-sgmhadoopdn-04] recovered [0] indices into cluster_state
注:不加任何参数为前台启动,以后台进程启动的话需执行下面的命令
[[email protected] bin]$ ./elasticsearch &
[[email protected] bin]$ ./elasticsearch -d
以上是关于elasticsearch5.5安装部署的主要内容,如果未能解决你的问题,请参考以下文章