此文摘自https://www.linuxidc.com/Linux/2018-08/153718.htm 作了部分修改java
ElasticSearch是一個基於Lucene的搜索服務器。它提供了一個分佈式多用戶能力的全文檢索引擎,基於RESTful web接口。Elasticsearch是用Java開發的,並做爲Apache許可條款下的開放源碼發佈,是當前流行的企業級搜索引擎。設計用於雲計算中,可以達到實時搜索,穩定,可靠,快速,安裝使用方便。node
1)JDK8以上環境 2)CentOS7.3,IP地址:192.168.144.112 3)elasticsearch6.3.1
yum install java -y
java -version 查看java版本
首先在官網當中下載es的軟件包,本文采用壓縮包解壓縮安裝方式啓動服務。linux
tar zxvf elasticsearch-6.3.1.tar.gz -C /opt/
groupadd ela 建立ela組 useradd -g ela ela 建立ela用戶,而且加入ela組 passwd ela 爲ela用戶設定登陸密碼 visudo(或者vim /etc/sudoers)
chown -R ela.ela /opt/elasticsearch-6.3.1/ ls -l /opt/elasticsearch-6.3.1/
su ela [ela@localhost ~]$ cd /opt/elasticsearch-6.3.2/config/ [ela@localhost config]$ sudo vim elasticsearch.yml # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # cluster.name: abner //打開設定es羣集名稱 # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: node-1 //es當前節點名稱,用於區分不一樣節點 # # 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: /data/es-data //修改數據目錄,此目錄爲自定義,須要在root用戶下建立,且屬主屬組更改成ela # # Path to log files: # path.logs: /var/log/elasticsearch //日誌目錄位置,需本身建立,方式同上 //yum安裝則系統自定義,在軟件版本或者系統升級時會被刪除,因此建議修改 # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # bootstrap.memory_lock: true //elasticsearch官網建議生產環境須要設置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: 0.0.0.0 //監聽訪問地址爲任意網段 # # Set a custom port for HTTP: # http.port: 9200 //服務監聽端口 #
sudo mkdir -p /data/es-data sudo mkdir -p /var/log/elasticsearch sudo chown -R ela.ela /data/ sudo chown -R ela.ela /var/log/elasticsearch
[ela@localhost /]$ cd /opt/elasticsearch-6.3.2/bin/ [ela@localhost bin]$ ./elasticsearch 後面能夠跟上-d後臺執行
-當發現如上圖沒法分配內存錯誤等,可執行以下操做。(須要在root用戶權限下)web
vim /etc/security/limits.conf
* soft nofile 65536 * hard nofile 131072 ela soft memlock unlimited ela hard memlock unlimited
vim /etc/sysctl.conf vm.max_map_count = 655360 //添加 sysctl -p
[ela@localhost abc]$ cd /opt/elasticsearch-6.3.2/bin/ [ela@localhost bin]$ ./elasticsearch
netstat -ntap | grep 9200 tcp6 0 0 :::9200 :::* LISTEN 2095/java