在Ubuntu(12.04)上安裝ElasticSearch Server

sudo apt-get update
sudo apt-get upgrade

一.安裝Java

sudo apt-get install openjdk-7-jre

二.下載ElasticSearch

github: https://github.com/elasticsearch/elasticsearch
網站: http://www.elasticsearch.org/download/
可輸入以下指令:
wget -P elasticsearch https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.2.zip
下載並解壓縮後為elasticsearch目錄,搬動到/usr/local/share

sudo mv elasticsearch /usr/local/share

三.透過 servicewrapper 把它包裝成一個 service
可參考:https://github.com/elasticsearch/elasticsearch-servicewrapper

clone下來後將檔案裡的service目錄移動到/usr/local/share/elasticsearch/bin

sudo mv servicewrapper/service /usr/local/share/elasticsearch/bin/.

四.安裝analysis-skos plugin
github:https://github.com/MR-SC/elasticsearch-analysis-skos
把analysis-skos從github上clone下來,並移動到/usr/local/share/elasticsearch/plugins目錄裡面

#注意:一開始沒安裝plugin時不會有plugins這個目錄,自己建一個就可以了

五.elasticsearch install

sudo /usr/local/share/elasticsearch/bin/service/elasticsearch install

如果需要的話可以建立smblink:(其實不需要XD)
sudo ln -s `readlink -f /usr/local/share/elasticsearch/bin/service/elasticsearch` /usr/local/bin/elasticsearch

六.修改設定檔

設定檔放在/usr/local/share/elasticsearch/bin/service/elasticsearch.conf
編輯該檔案,可以修改如下


ES_HOME設為:/usr/local/share/elasticsearch
ES_HEAP_SIZE可以維持1024

#注意:如果你的主機是EC2 micro T1,記憶體會不夠,需要至少升級到m1.small

七.啟動並檢查是否安裝成功

到/usr/local/share/elasticsearch執行 bin/elasticsearch -f
在這一步有可能遇到的會是記憶體不夠造成無法開啓,

可以到 /usr/local/share/elasticsearch/bin/service/elasticsearch.conf 檔案最上端修改 Heap 大小。

測試一下
http://domain-name:9200
如果看到下列訊息就是成功了!
{
  “ok” : true,
  “status” : 200,
  “name” : “Amiko Kobayashi”,
  “version” : {
    “number” : “0.19.8”,
    “snapshot_build” : false
  },
  “tagline” : “You Know, for Search”
}