rhel6.8安装elasticsearch-6.1.3.tar.gz遇到的问题以及集群配置

2018-02-06 09:43:31来源:oschina作者:雁南飞丶人点击

分享

一、下载


wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.3.tar.gz

二、解压


1、解压
tar xvf elasticsearch-6.1.3.tar.gz -C /usr/local/
2、执行
[root@zdhdbbsj local]# cd elasticsearch-6.1.3/
[root@zdhdbbsj elasticsearch-6.1.3]# ls
binconfigdatalibLICENSE.txtlogsmodulesNOTICE.txtpluginsREADME.textile
[root@zdhdbbsj elasticsearch-6.1.3]# cd bin/
[root@zdhdbbsj bin]# ls
elasticsearchelasticsearch-env.batelasticsearch-pluginelasticsearch-service-mgr.exeelasticsearch-translog.bat
elasticsearch.batelasticsearch-keystoreelasticsearch-plugin.bat elasticsearch-service-x64.exe
elasticsearch-envelasticsearch-keystore.batelasticsearch-service.batelasticsearch-translog
[root@zdhdbbsj bin]# pwd
/usr/local/elasticsearch-6.1.3/bin
[root@zdhdbbsj bin]# ./elasticsearch
[2018-02-05T12:03:43,449][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-6.1.3.jar:6.1.3]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.1.3.jar:6.1.3]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.1.3.jar:6.1.3]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.1.3.jar:6.1.3]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.1.3.jar:6.1.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.1.3.jar:6.1.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.1.3.jar:6.1.3]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.1.3.jar:6.1.3]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.1.3.jar:6.1.3]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:322) ~[elasticsearch-6.1.3.jar:6.1.3]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-6.1.3.jar:6.1.3]
... 6 more
[root@zdhdbbsj bin]#

3、报错不能已root运行,添加用户


[root@zdhdbbsj bin]# useradd elasticsearch
[root@zdhdbbsj bin]# passwd elasticsearch
更改用户 elasticsearch 的密码 。
新的 密码:
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。
[root@zdhdbbsj bin]# chown -R elasticsearch.elasticsearch /usr/local/elasticsearch-6.1.3/

4、报错解决


ERROR: bootstrap checks failed


1、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.4.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


2、max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]


在文件/etc/security/limits.conf添加


* hard nofile 65536 * soft nofile 655363、max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]


原因:无法创建本地线程问题,用户最大可创建线程数太小 解决方案:切换到root用户,进入limits.d目录下,修改90-nproc.conf 配置文件。 vi /etc/security/limits.d/90-nproc.conf 找到如下内容: * soft nproc 1024 #修改为 * soft nproc 2048


4、max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]


虚拟内存太小下,修改文件/etc/sysctl.conf添加


vm.max_map_count=262144


sysctl -p 生效


以上问题解决后,es启动成功了,但又遇到了新的问题,本地机器无法访问虚拟机的服务,两个原因:


1)9200被限制为本机访问,需要在es的配置文件elasticsearch.yml中新增配置:


network.bind_host:9.1.6.140


2)关闭虚拟机防火墙


解决了这个两个问题后,本地能够顺利访问虚拟机的ES服务了。


启动成功


[elasticsearch@zdhdbbsj ~]$ cd /usr/local/elasticsearch-6.1.3/
[elasticsearch@zdhdbbsj elasticsearch-6.1.3]$ ls
binconfigdatalibLICENSE.txtlogsmodulesNOTICE.txtpluginsREADME.textile
[elasticsearch@zdhdbbsj elasticsearch-6.1.3]$ cd bin/
[elasticsearch@zdhdbbsj bin]$ ls
elasticsearchelasticsearch-env.batelasticsearch-pluginelasticsearch-service-mgr.exeelasticsearch-translog.bat
elasticsearch.batelasticsearch-keystoreelasticsearch-plugin.bat elasticsearch-service-x64.exe
elasticsearch-envelasticsearch-keystore.batelasticsearch-service.batelasticsearch-translog
[elasticsearch@zdhdbbsj bin]$ ./elasticsearch
[2018-02-05T12:16:44,963][INFO ][o.e.n.Node ] [] initializing ...
[2018-02-05T12:16:45,062][INFO ][o.e.e.NodeEnvironment] [JpGTfeO] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [27.3gb], net total_space [43.8gb], types [rootfs]
[2018-02-05T12:16:45,062][INFO ][o.e.e.NodeEnvironment] [JpGTfeO] heap size [990.7mb], compressed ordinary object pointers [true]
[2018-02-05T12:16:45,064][INFO ][o.e.n.Node ] node name [JpGTfeO] derived from node ID [JpGTfeOMRO2nida6MY0-yA]; set [node.name] to override
[2018-02-05T12:16:45,065][INFO ][o.e.n.Node ] version[6.1.3], pid[8135], build[af51318/2018-01-26T18:22:55.523Z], OS[Linux/2.6.32-431.el6.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_131/25.131-b11]
[2018-02-05T12:16:45,065][INFO ][o.e.n.Node ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/elasticsearch-6.1.3, -Des.path.conf=/usr/local/elasticsearch-6.1.3/config]
[2018-02-05T12:16:46,084][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [aggs-matrix-stats]
[2018-02-05T12:16:46,084][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [analysis-common]
[2018-02-05T12:16:46,084][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [ingest-common]
[2018-02-05T12:16:46,084][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [lang-expression]
[2018-02-05T12:16:46,084][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [lang-mustache]
[2018-02-05T12:16:46,085][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [lang-painless]
[2018-02-05T12:16:46,085][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [mapper-extras]
[2018-02-05T12:16:46,085][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [parent-join]
[2018-02-05T12:16:46,085][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [percolator]
[2018-02-05T12:16:46,085][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [reindex]
[2018-02-05T12:16:46,085][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [repository-url]
[2018-02-05T12:16:46,085][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [transport-netty4]
[2018-02-05T12:16:46,086][INFO ][o.e.p.PluginsService ] [JpGTfeO] loaded module [tribe]
[2018-02-05T12:16:46,086][INFO ][o.e.p.PluginsService ] [JpGTfeO] no plugins loaded
[2018-02-05T12:16:47,685][INFO ][o.e.d.DiscoveryModule] [JpGTfeO] using discovery type [zen]
[2018-02-05T12:16:48,462][INFO ][o.e.n.Node ] initialized
[2018-02-05T12:16:48,462][INFO ][o.e.n.Node ] [JpGTfeO] starting ...
[2018-02-05T12:16:48,610][INFO ][o.e.t.TransportService ] [JpGTfeO] publish_address {9.1.6.140:9300}, bound_addresses {9.1.6.140:9300}
[2018-02-05T12:16:48,622][INFO ][o.e.b.BootstrapChecks] [JpGTfeO] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2018-02-05T12:16:51,681][INFO ][o.e.c.s.MasterService] [JpGTfeO] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {JpGTfeO}{JpGTfeOMRO2nida6MY0-yA}{Px-ClZ4aRKas4OIraKwnrQ}{9.1.6.140}{9.1.6.140:9300}
[2018-02-05T12:16:51,687][INFO ][o.e.c.s.ClusterApplierService] [JpGTfeO] new_master {JpGTfeO}{JpGTfeOMRO2nida6MY0-yA}{Px-ClZ4aRKas4OIraKwnrQ}{9.1.6.140}{9.1.6.140:9300}, reason: apply cluster state (from master [master {JpGTfeO}{JpGTfeOMRO2nida6MY0-yA}{Px-ClZ4aRKas4OIraKwnrQ}{9.1.6.140}{9.1.6.140:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2018-02-05T12:16:51,703][INFO ][o.e.h.n.Netty4HttpServerTransport] [JpGTfeO] publish_address {9.1.6.140:9200}, bound_addresses {9.1.6.140:9200}
[2018-02-05T12:16:51,703][INFO ][o.e.n.Node ] [JpGTfeO] started
[2018-02-05T12:16:51,724][INFO ][o.e.g.GatewayService ] [JpGTfeO] recovered [0] indices into cluster_state

查看结果


[root@zdhdbbsj ~]# curl -X GET http://9.1.6.140:9200
{
"name" : "JpGTfeO",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "s3ONF7HATfGnaYgeSO8gzA",
"version" : {
"number" : "6.1.3",
"build_hash" : "af51318",
"build_date" : "2018-01-26T18:22:55.523Z",
"build_snapshot" : false,
"lucene_version" : "7.1.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

集群配置,复制到其他集群机器上修改node.name即可


[elasticsearch@zdhdbbsj config]$ cat elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#Before you set out to tweak and tune the configuration, make sure you
#understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: myes
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#node.master: true
#node.data: true
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
discovery.zen.ping.unicast.hosts: ["node-1","node-2","node-3"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes:
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

host需要解析里面的node-1 node-2 node-3


9.1.6.140 node-1
9.1.8.123 node-2
9.1.8.153 node-3

查看集群状态




最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台