Linux centos安裝Elasticsearch7.8單機安裝


linux上elasticSearch7.8安裝配置

 

 


轉載原文地址: https://blog.csdn.net/han949417140/article/details/107614240

      https://blog.csdn.net/qq_38380025/article/details/105263797

https://www.cnblogs.com/zlslch/p/6614037.html

一、資源准

名稱 地址  
elasticSearch7.8 https://www.oracle.com/java/technologies/javase-jdk11-downloads.html es安裝包
jdk11 https://www.oracle.com/java/technologies/javase-jdk11-downloads.html jdk安裝包

    

jdk1.8以上都可以,本人就是jdk1.8,只是安裝的時候會提示以后的版本需要jdk11

上傳資源包到到自己的安裝目錄下。

二、安裝配置

 1. 解壓

cd /opt/resources
tar -zxvf elasticsearch-7.8.0-linux-x86_64.tar.gz

  

 

2. 修改elasticsearch.yml配置文件
vim 安裝路徑下的/elasticsearch-7.8.0/config/elasticsearch.yml
cluster.name: es-hld   	#為集群提供一個名稱
node.name: hld-1 		  	#此節點名稱
path.data: /opt/es/data  	#數據存放的地址
path.logs: /opt/es/logs  	#日志存放地址
network.host: 0.0.0.0 		#網絡綁定這樣設置就好了
cluster.initial_master_nodes: ["hld-1"] #將es-node1設置為master節點

 3. 修改系統進程內存限制

  vim /etc/security/limits.conf

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

  vim /etc/sysctl.conf

  

vm.max_map_count=262145 	 #(es需要262144,我們在基礎上+1,保證它啟動)

  保存退出過后在執行 

  sysctl -p #刷新命令

 4. 創建用戶

由於elasticsearch不允許root用戶操作,所以需要建立子用戶
useradd esuser  #增加一個子用戶
chown -R esuser:esuser /usr/local/elasticsearch-7.4.2  #賦權
su esuser 	#切換成子用戶
#進入 es/bin命令啟動
cd /usr/local/elasticsearch-7.7.0/bin
./elasticsearch -d    #-d表示后台啟動,不是后台啟動,不加 "-d" 即可

 5. 校驗

http:ip:9200 如果返回json字符串則安裝成功,如圖:

 

 

 

以上的常見問題以及解決辦法

 

1、./elasticsearch-7.6.1/bin/elasticsearch 啟動報以殺死  這個問題 沒有生成其他日志 只有gc的,根據gc 日志分析 分配內存問題


Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
已殺死

 解決:

編輯   vi config/jvm.options  文件

找到

-Xms1g
-Xmx1g

修改成你本身機器所能承受的范圍即可 如 512m

2、type [START_OBJECT] but found [VALUE_STRING]];

[elsearch@k8a elasticsearch-7.6.1]$ ./bin/elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Exception in thread "main" 2020-04-02 10:33:21,459 main ERROR No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]];
    at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1097)
    at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1070)
    at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:83)
    at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:100)
    at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:91)
    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)
Caused by: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]]
    at org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken(XContentParserUtils.java:78)
    at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:617)
    at org.elasticsearch.common.settings.Settings.access$400(Settings.java:82)
    at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1093)
 

解決:

這個是因為編輯   vi config/elasticsearch.yml  的key 和value 寫錯了導致, 仔細檢查你所修改的地方就可以發現問題

提示,key 和value 之間除了:還有個 空格 如:    key: (空格)value

3、

[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,

這里是三個問題

[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
ERROR: Elasticsearch did not exit normally - check the logs at /home/elsearch/elasticsearch-7.6.1/logs/elasticsearch.log

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

解決 

編輯文件 用root 用戶

 vi /etc/security/limits.conf

 請將es修改為你對應的 啟動 elasticsearch 用戶名 

  1.  
    es hard nofile 65536
  2.  
    es soft nofile 65536

重啟服務器  在重新啟動es即可

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

解決:

切換到root用戶修改配置sysctl.conf

vi /etc/sysctl.conf 

添加下面配置:

vm.max_map_count=655360 

並執行命令:

sysctl -p 

然后,重新啟動elasticsearch,即可啟動成功。

[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts,

解決

修改 

vi /conf/elasticsearch.yml

找到  默認是有注釋的,把注釋去掉 后保存  

cluster.initial_master_nodes: ["node-1"]
 

重啟es 即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM