CentOS 6.5 下安裝 Elasticsearch 5


安裝最新的 Elasticsearch 5 需要Java 8。所有先要確定環境中是否有Java 8。如果沒有則需要安裝。

1. 安裝Java 8

首先使用 yum list installed | grep java 查看安裝的Java版本

如果不是Java 8,則使用 yum -y remove java-1.7.0-openjdk* 卸載已經安裝的Java。

卸載完成之后,使用 yum -y list java* 查看當前的Java版本,使用 yum install java-1.8.0-openjdk.x86_64 安裝Java 8。

 

2. 導入Elasticsearch PGP Key

執行命令

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-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 添加在啟動服務中。

 
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 來驗證是否安裝運行成功。如下圖:說明安裝成功。

 
 image
 
使用Yum安裝Elasticsearch的相關路徑文件如下: 
 
image
 
 如果在重啟的時候,

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
 
 


免責聲明!

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



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