安裝最新的 Elasticsearch 5 須要Java 8。全部先要肯定環境中是否有Java 8。若是沒有則須要安裝。java
1. 安裝Java 8node
首先使用 yum list installed | grep java 查看安裝的Java版本bootstrap
若是不是Java 8,則使用 yum -y remove java-1.7.0-openjdk* 卸載已經安裝的Java。vim
卸載完成以後,使用 yum -y list java* 查看當前的Java版本,使用 yum install java-1.8.0-openjdk.x86_64 安裝Java 8。瀏覽器
2. 導入Elasticsearch PGP Key運維
執行命令 curl
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
3. 安裝Elasticsearch的rpm庫使用 ll /etc/yum.repos.d/ 查看當前機器上已經安裝的rpm庫,若是沒有Elasticsearch的話須要建立。用vim建立新的repo文件,vim /etc/yum.repos.d/elasticsearch.repo。文件內容爲:elasticsearch
[elasticsearch-5.x] name=Elasticsearch repository for 5.x packages baseurl=https://artifacts.elastic.co/packages/5.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md
4. 安裝Elasticsearch 安裝好Elasticsearch 的repo後,就能夠經過yum命令安裝 Elasticsearch 了。 測試
sudo yum install elasticsearch
5. 啓動與測試在CentOS6.5下 因爲是init來啓動引導用戶態程序的,要啓動 須要經過命令 sudo chkconfig --add elasticsearch 添加在啓動服務中。ui
sudo chkconfig --add elasticsearch
添加完成之後,使用 sudo -i service elasticsearch start 來啓動 Elasticsearch。啓動完成之後,執行
curl -XGET 'localhost:9200/?pretty'
以下返回,說明安裝成功
{ "name" : "avU0nZX", "cluster_name" : "elasticsearch", "cluster_uuid" : "SY1eB2WTShy6d3sBY5YS5g", "version" : { "number" : "5.0.1", "build_hash" : "080bb47", "build_date" : "2016-11-11T22:08:49.812Z", "build_snapshot" : false, "lucene_version" : "6.2.1" }, "tagline" : "You Know, for Search" }
默認狀況下,Elasticsearch 是綁定的IP是localhost,因此其餘機器是沒有辦法經過http://IP:9200 的方式來訪問Elasticsearch 的。須要修改Elasticsearch 的配置。路徑在:/etc/elasticsearch/elasticsearch.yml。修改其中的配置以下:
network.host: 0.0.0.0
而後重啓Elasticsearch ,這樣你再在瀏覽器中輸入:http://IP:9200 來驗證是否安裝運行成功。以下圖:說明安裝成功。
使用Yum安裝Elasticsearch的相關路徑文件以下:
若是在重啓的時候,
Elasticsearch 沒有起來,查看日誌文件:cat /var/log/elasticsearch/elasticsearch.log 發現這麼一段話:
[ERROR][o.e.b.Bootstrap ] [avU0nZX] node validation exception bootstrap checks failed max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]
那麼你須要修改 /etc/security/limits.conf。添加
Elasticsearch 用戶的配置。以下:
elasticsearch soft nproc 2048 elasticsearch hard nproc 4096
問題記錄:
1. 在啓動是報錯:system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
修改配置elasticsearch.yml,添加配置項:bootstrap.system_call_filter: false
運維API:
1. 集羣狀態:http://10.23.22.242:9200/_cluster/health?pretty
2. 節點狀態:http://10.23.22.242:9200/_nodes/process?pretty
3. 分片狀態:http://10.23.22.242:9200/_cat/shards
4. 索引分片存儲信息:http://10.23.22.242:9200/index/_shard_stores?pretty
5. 索引狀態:http://10.23.22.242:9200/index/_stats?pretty
6. 索引元數據:http://10.23.22.242:9200/index?pretty