2014年8月14日 星期四

ubuntu 上安裝 Elasticsearch Cluster

1. 參考 Installing ElasticSearch on Ubuntu 14.04 ,分別在欲加入 Elasticsearch Cluster 的每部機器上完成安裝

### Install  Oracle Java (改安裝 Oracle Java)
cd /tmp
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
 
### Download and Install ElasticSearch ver 1.3.2
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.deb
sudo dpkg -i elasticsearch-1.3.2.deb
 
### Install the Java Service Wrapper for ElasticSearch
curl -L http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
sudo mkdir /usr/local/share/elasticsearch
sudo mkdir /usr/local/share/elasticsearch/bin
sudo mv *servicewrapper*/service /usr/local/share/elasticsearch/bin/
rm -Rf *servicewrapper*
sudo /usr/local/share/elasticsearch/bin/service/elasticsearch install
sudo ln -s `readlink -f /usr/local/share/elasticsearch/bin/service/elasticsearch` /usr/local/bin/rcelasticsearch
### Start ElasticSearch
sudo service elasticsearch start
 
### Make sure service is running
curl http://localhost:9200
 
### Should return something like this:
#{
# "status" : 200,
# "name" : "Storm",
# "version" : {
# "number" : "1.3.1",
# "build_hash" : "2de6dc5268c32fb49b205233c138d93aaf772015",
# "build_timestamp" : "2014-07-28T14:45:15Z",
# "build_snapshot" : false,
# "lucene_version" : "4.9"
# },
# "tagline" : "You Know, for Search"
#}

2. 分別修改每部機器上 /etc/elasticsearch/elasticsearch.yml 設定

cluster.name: elasticsearch
node.name: "elastic_your_nodename"

3. 重新啟動 elasticsearch

sudo service elasticsearch restart

4. 測試 Elasticsearch Cluster 是否有多個 node 出現?本例為2個nodes 

curl -XGET http://elastic_your_nodename:9200/_cluster/health?pretty

{
  "cluster_name" : "elasticsearch",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 2,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 5,
  "active_shards" : 10,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0
}
#

2014年8月13日 星期三

Mac OS X Client 以 ssh 自動登入 ubuntu server


1. 於Mac OS X開啟終端機"terminal" 程式

ssh-keygen -t rsa (接著連續按下幾次Enter)
cat ~/.ssh/id_rsa.pub | ssh yourname@ubuntu.server "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"


2. 於Mac OS X開啟終端機"terminal" 程式

ssh yourname@ubuntu.server  (應該已能自動登入,免輸入ssh密碼囉)


#