rhel6.8安裝elasticsearch-6.1.3.tar.gz遇到的問題以及集羣配置

一、下載

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
bin  config  data  lib  LICENSE.txt  logs  modules  NOTICE.txt  plugins  README.textile
[root@zdhdbbsj elasticsearch-6.1.3]# cd bin/
[root@zdhdbbsj bin]# ls
elasticsearch      elasticsearch-env.bat       elasticsearch-plugin       elasticsearch-service-mgr.exe  elasticsearch-translog.bat
elasticsearch.bat  elasticsearch-keystore      elasticsearch-plugin.bat   elasticsearch-service-x64.exe
elasticsearch-env  elasticsearch-keystore.bat  elasticsearch-service.bat  elasticsearch-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    65536

3、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
bin  config  data  lib  LICENSE.txt  logs  modules  NOTICE.txt  plugins  README.textile
[elasticsearch@zdhdbbsj elasticsearch-6.1.3]$ cd bin/
[elasticsearch@zdhdbbsj bin]$ ls
elasticsearch      elasticsearch-env.bat       elasticsearch-plugin       elasticsearch-service-mgr.exe  elasticsearch-translog.bat
elasticsearch.bat  elasticsearch-keystore      elasticsearch-plugin.bat   elasticsearch-service-x64.exe
elasticsearch-env  elasticsearch-keystore.bat  elasticsearch-service.bat  elasticsearch-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

查看集羣狀態

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章