elasticsearch是分佈式文本搜索工具,ES是Java編寫的須要機器上已經安裝JDK環境,JDK的安裝這裏不介紹,其安裝以下。 一、elasticsearch 下載連接地址:https://www.elastic.co/products/elasticsearch 下載最新版本 解壓縮: tar -zxvf elasticsearch.XXX.tar.gz -C /usr/local/ 修改配置文件 ``` cd /usr/local/elasticsearch 配置文件在 conf 目錄下 vi elasticsearch.yml
cluster.name: market_dev
node.name: dev05_111 path.data: /usr/local/elasticsearch/data
path.logs: /usr/local/elasticsearch/logs
network.host: 0.0.0.0 http.port: 9200 discovery.zen.ping.unicast.hosts: ["192.168.137.2", "192.168.137.3","192.168.137.4","192.168.137.5"]java
將上面elasticsearch分發到其餘節點上 啓動ES
cd /usr/local/elasticsearch/bin ./elasticsearch -dnode
![輸入圖片說明](https://static.oschina.net/uploads/img/201610/24155954_vlJp.png "在這裏輸入圖片標題") 二、head插件暗轉 安裝可視化插件head。下載elasticsearch-head-master.zip 插件 解壓縮
unzip elasticsearch-head-master.zip mv elasticsearch-head-master /usr/local/elasticsearch/plugins/ mv elasticsearch-head-master headapp
頁面中輸入http://192.168.137.2:9200/_plugin/head/ ![輸入圖片說明](https://static.oschina.net/uploads/img/201610/24160442_XHHp.png "在這裏輸入圖片標題") 三、遇到的問題
(1)Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: MarkedYAMLException[while scanning a simple key in 'reader', line 23, column 2: node.name:"master" ^ could not find expected ':' in 'reader', line 24, column 2: index.number_of_replicas:2 解決:node.name:"master" 冒號是要有空格的,修改成:node.name: "ster"elasticsearch
(2) Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ElasticsearchParseException[malformed, expected end of settings but encountered additional content starting at line number: [70], column number: [1]]; nested: MarkedYAMLException[expected '<document start>', but found BlockMappingStart 一樣是上述問題: discovery.zen.ping.unicast.hosts: ["192.168.137.2", "192.168.137.3", "192.168.137.4", "192.168.137.5"] hosts後面的冒號須要空格,IP地址之間須要空格,discovery須要空一格 (3) java.net.NoRouteToHostException: No route to host 添加 索引時 出現 503 查看日誌報這個錯誤 解決:檢查防火牆是否關閉,查看防火牆是沒有關閉的 service iptables stop 關閉以後能夠 (4) 啓動ES時不能以root用戶啓動否則會報錯