服務器環境: CentOS6
jdk 安裝
jdk最低版本為1.8版本,如果服務器中JAVA_HOME的版本低于1.8, 則可安裝好jdk1.8之后,在 /bin/elasticsearch 中配置JAVA_HOME下載ElasticSearch5.2
下載地址: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz
分別使用的命令如下:
wget "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz"
tar -zxvf elasticsearch-5.2.2.tar.gz服務器參數配置
切換到root用戶下
sysctl -w vm.max_map_count=262144 #定義了一個進程能擁有的最多的內存區域-
elasticsearch 配置
cluster.name: es_test # 同一個集群需要同一個cluster.name
node.name: es_node_1 # 不同的節點配置不同的node namepath.data: /data/to/data # es數據存儲的目錄
path.logs: /data/to/logs # es日志存儲的地方bootstart.memory_lock: true # es所占內存鎖,防止內存溢出
bootstrap.system_call_filter: false # Centos6不支持SecComp,而ES5.2.0默認bootstrap.system_call_filter為truenetwork 對外暴露的端口
network.host: 0.0.0.0 # 默認為 192.168.0.1 需要改為0.0.0.0 否則外網訪問不到
http.port: 9200 # 設置對外的http端口Discovery 服務發現(用來集群之間互相發現的)
transport.tcp.port: 9300 #默認的集群間通信的端口號為9300
discovery.zen.ping.unicast.hosts: ["IP:Port", "IP:PORT", "IP:PORT"] # ip:port 為集群中所有節點的ip和端口號,端口號沒有時默認為9300
discovery.zen.minimum_master_nodes: 2 # 防止腦裂,最好設置為 (master_eligible_nodes / 2) + 1
discovery.zen.ping_timeout: 10s # master節點選舉超時設置 elasticsearch 啟動
在bin目錄下使用如下命令: ./elasticsearch
如果想將其運行在后臺: nohup ./elasticsearch &查看是否成功運行
http://localhost:9200/_cat/health?v # 能夠成功獲取到當前集群情況
http://localhost:9200/ # 獲取當前版本情況高級參數設置
(1) Elasticsearch使用線程池來運行不同的操作,確保Elasticsearch用戶可以創建至少為2048個
ulimit -u 2048
(2) 線程池設置
參考文檔:https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-threadpool.html
(3) gateway 主要用來對數據進行持久化,整個集群重啟之后可以通過gateway重新恢復數據
參考文檔:https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html插件安裝
使用 命令進行安裝 (注意:elasticsearch-plugin 的java_home 也需要設置為1.8):
bin/elasticsearch-plugin install [plugin_name]