elasticsearch安裝和配置,elasticsearch啓動報錯:can not run elasticsearch as root

elasticsearch安裝和配置java

elasticsearch啓動報錯:can not run elasticsearch as rootnode

elasticsearch啓動報錯:ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]      
[2]: max number of threads [3818] for user [es] is too low, increase to at least [4096]                        
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]es6

 

================================bootstrap

©Copyright 蕃薯耀 2021-02-20centos

https://www.cnblogs.com/fanshuyao/瀏覽器

 

1、elasticsearch解壓安裝
一、解壓elasticsearchapp

cd /java/es6/
tar -zxvf elasticsearch-6.8.13.tar.gz

 

二、修改文件夾名稱和移動位置curl

mv elasticsearch-6.8.13 /java/elasticsearch6

 

三、進入配置文件目錄jvm

cd /java/elasticsearch6/config

[root@host-12 java]# cd /java/elasticsearch6/config
[root@host-12 config]# ll
總用量 32
-rw-r-----. 1 631 503 2853 10月 16 17:04 elasticsearch.yml
-rw-r-----. 1 631 503 3885 10月 16 17:04 jvm.options
-rw-r-----. 1 631 503 13085 10月 16 17:17 log4j2.properties
-rw-r-----. 1 631 503 473 10月 16 17:17 role_mapping.yml
-rw-r-----. 1 631 503 197 10月 16 17:17 roles.yml
-rw-r-----. 1 631 503 0 10月 16 17:17 users
-rw-r-----. 1 631 503 0 10月 16 17:17 users_rolesjsp

 


四、建立數據和日誌目錄

mkdir -p /java/elasticsearch6/esdata

mkdir -p /java/elasticsearch6/eslogs

 

五、修改配置文件:

vi /java/elasticsearch6/config/elasticsearch.yml

 

修改內容:

#集羣名稱
cluster.name: myes6
#節點名稱
node.name: node-11
#數據目錄
path.data: /java/elasticsearch6/esdata
#日誌目錄
path.logs: /java/elasticsearch6/eslogs
# 是否鎖定內存在啓動時
bootstrap.memory_lock: false
#centos6.x操做系統不支持SecComp,默認bootstrap.system_call_filter爲true進行檢測,因此致使檢測失敗,失敗後直接致使ES不能啓動。
#若是不配置,會出現錯誤:system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
bootstrap.system_call_filter: false
#IP地址
network.host: 192.168.170.11
#端口號
http.port: 9200
#集羣發現
discovery.zen.ping.unicast.hosts: ["192.168.170.11", "192.168.170.12", "192.168.170.13"]

 


2、elasticsearch設置環境變量

一、配置elasticsearch運行的環境變量,簡化命令,配置後,不用拼寫完整路徑:

vi /etc/profile

 

二、在文件的最後加上:

ELASTICSEARCH_HOME=/java/elasticsearch6/
PATH=$PATH:$ELASTICSEARCH_HOME/bin
export ELASTICSEARCH_HOME PATH

 

三、讓環境變量配置當即生效:

source /etc/profile

 

3、啓動elasticsearch

/java/elasticsearch6/bin/elasticsearch

若是設置環境變量,則能夠:

elasticsearch

 

elasticsearch啓動時報錯:can not run elasticsearch as root

不能使用root啓動

Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-6.8.13.jar:6.8.13]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-6.8.13.jar:6.8.13]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.13.jar:6.8.13]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.13.jar:6.8.13]
... 6 more

 

增長es用戶:

groupadd es

useradd es -g es

passwd es

新的 密碼:
從新輸入新的 密碼:
passwd:全部的身份驗證令牌已經成功更新。

#設置文件夾的權限

cd /java

chown -R es:es elasticsearch6

 

切換爲es用戶:

su es

 

再次啓動:

/java/elasticsearch6/bin/elasticsearch


ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3818] for user [es] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2021-02-04T16:28:09,472][INFO ][o.e.n.Node ] [node-11] stopping ...
[2021-02-04T16:28:09,546][INFO ][o.e.n.Node ] [node-11] stopped
[2021-02-04T16:28:09,546][INFO ][o.e.n.Node ] [node-11] closing ...
[2021-02-04T16:28:09,576][INFO ][o.e.n.Node ] [node-11] closed

切換到Root用戶:

su root

 

[1][2]解決(切換到root用戶):

vi /etc/security/limits.conf

 

文件後面添加下面的內容:

# soft表示爲超過這個值就會有warnning
# hard則表示不能超過這個值
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

 

若是[1]方法沒有解決[2],能夠再執行下面的解決[2](切換到root用戶):
【20-nproc.conf】這個文件可能每一個人都不同,能夠進入目錄查看具體的文件

vi /etc/security/limits.d/20-nproc.conf

 

Centos7默認就是:4096,不須要再修改,若是不是,請修改

* soft nproc 4096
root soft nproc unlimited

 

[3]解決(切換到root用戶):

vi /etc/sysctl.conf

 

增長內容:

vm.max_map_count=655360

保存後,執行命令:

sysctl -p


最後重啓Linux系統(必須),不重啓不生效

切換爲es用戶:

su es

 

再次啓動:

/java/elasticsearch6/bin/elasticsearch

或後臺啓動:

/java/elasticsearch6/bin/elasticsearch -d


後臺啓動能夠經過jsp查看有沒有進程。
[root@host-11 ~]# jps
992 QuorumPeerMain
1490 Elasticsearch
1551 Jps


啓動成功後,進行驗證:
[node-11] publish_address {192.168.170.11:9200}, bound_addresses {192.168.170.11:9200}
[node-11] license [bf28e518-3560-4e69-a605-4e97b2055ba7] mode [basic] - valid


進行驗證:
瀏覽器打開:

http://192.168.170.11:9200/

或者在Linux命令窗口驗證:

curl http://192.168.170.11:9200/

返回結果:
{
"name" : "node-11",
"cluster_name" : "myes6",
"cluster_uuid" : "xDGeM7glQECODLuS32Qo9A",
"version" : {
"number" : "6.8.13",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "be13c69",
"build_date" : "2020-10-16T09:09:46.555371Z",
"build_snapshot" : false,
"lucene_version" : "7.7.3",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

查看集羣狀態:

http://192.168.170.11:9200/_cluster/stats?pretty

 

查看單個節點狀態:

http://192.168.170.11:9200/_nodes/node-11/process?pretty

 

查看ES集羣健康狀態

http://192.168.170.11:9200/_cluster/health?pretty

{
"cluster_name" : "myes6", //集羣名稱
"status" : "green", //集羣的狀態紅綠燈,綠:健康,黃:亞健康,紅:病態
"timed_out" : false,
"number_of_nodes" : 2, //節點數
"number_of_data_nodes" : 2, //數據節點數
"active_primary_shards" : 12,
"active_shards" : 24,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}

查看指定索引庫的健康狀態

http://192.168.170.11:9200/_cluster/health/stu?pretty

 

多個索引:

http://192.168.170.11:9200/_cluster/health/index_name1,index_name2?pretty

 

查看集羣的主節點:
瀏覽器打開:

http://192.168.170.12:9200/_cat/master?v

 

或者在Linux命令窗口驗證:

curl 192.168.170.12:9200/_cat/master?v

 

輸出內容:
id host ip node
CDH9HpfRRmaAN3VBbj4Vow 192.168.170.11 192.168.170.11 node-11

 

(若是文章對您有所幫助,歡迎捐贈,^_^)

 

================================

©Copyright 蕃薯耀 2021-02-20

https://www.cnblogs.com/fanshuyao/

相關文章
相關標籤/搜索