Linux安裝Elasticsearch-7.6.x遇到的問題處理

1.啓動時報錯

[root@localhost bin]# ./elasticsearch
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[2020-04-02T15:45:21,761][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [localhost.localdomain] 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:174) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.6.2.jar:7.6.2]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.6.2.jar:7.6.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.6.2.jar:7.6.2]
	... 6 more
uncaught exception in thread [main]
java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105)
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349)
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
For complete error details, refer to the log at /usr/local/elasticsearch-7.6.2/logs/elasticsearch.log

解決方法:這裏是es 規定 root 用戶不能啓動 es,所以需要創建一個用戶來啓動 es

# 創建用戶名爲 es 的用戶
$ useradd es
# 設置 es 用戶的密碼,輸入下面命令,回車後輸入密碼
$ passwd es
# 將elasticsearch目前的擁有者與所屬組設置爲 es
$  chown -R es:es /usr/local/elasticsearch-7.2.x
# 切換到es用戶後,運行es即可
$ su es
....

2.切換到es用戶啓動後,還是報錯

ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

解決方法: 每個進程最大同時打開文件數太小,可通過下面 2 個命令查看當前數量ulimit -Hnulimit -Sn

修改/etc/security/limits.conf 文件,增加配置,用戶退出後重新登錄生效

$ vim /etc/security/limits.conf
#加入一下內容
*               soft    nofile           65536
*               hard    nofile           65536

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解決方法: 提高 vm.max_map_count 的大小(記得切換到root用戶進行操作)

$ vim /etc/sysctl.conf
# 在最後面追加下面內容
vm.max_map_count=262144 
...
# 使用 sysctl -p 查看修改後的結果
sysctl -p

[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

這裏是沒有配置es初始化集羣節點,編輯elasticsearch.yml文件,將 #cluster.initial_master_nodes: [“node-1”, “node-2”] 修改爲 cluster.initial_master_nodes: [“node-1”]

$ vim ./config/elasticsearch.yml
 ...
 cluster.initial_master_nodes: [“node-1”]
 ...
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章