1. 開好機器後先更新 yum repo

$ sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 

2. 安裝 elasticsearch https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html

$ sudo echo '[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseurl=https://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1' > /etc/yum.repo.d/elasticsearch.repo

$ sudo yum install elasticsearch

 

3. 設定開機自動啟動 elasticsearch

$ sudo /bin/systemctl daemon-reload

$ sudo /bin/systemctl enable elasticsearch.service

 

4. 安裝 cloud-aws 外掛 https://www.elastic.co/guide/en/elasticsearch/plugins/2.2/cloud-aws.html

$ sudo yum install java

$ sudo /usr/share/elasticsearch/bin/plugin install cloud-aws

 

5. 修改 elasticsearch.yml 設定檔

cluster.name: {YOUR_CLUSTER_NAME}

node.name: {YOUR_NODE_NAME}

network.host: _ec2_

cloud:
    aws:
        access_key: {YOUR_ACCESS_KEY}
        secret_key: {YOUR_SECERET_KEY}
        region: {YOUR_REGOIN, eg: ap-southeast}

discovery:
    type: ec2
    ec2:
        groups: {YOUR_SECURITY_GROUP}

 

6. 啟動 elasticsearch

$ sudo service elasticsearch start

 

7. 確認已和別台機器連接

$ sudo cat /var/log/messages

...

...

Mar 29 03:19:34 localhost elasticsearch: [2016-03-29 03:19:34,016][INFO ][cluster.service          ] [node-1] detected_master {node-1}{VD4PIdn6TfaQXFLBGzAHyQ}{別台的ip}{別台的ip:9300}, added {{node-1}{VD4PIdn6TfaQXFLBGzAHyQ}{別台的ip}{別台的ip:9300},}, reason: zen-disco-receive(from master [{node-1}{VD4PIdn6TfaQXFLBGzAHyQ}{別台的ip}{別台的ip:9300}])
Mar 29 03:19:34 localhost elasticsearch: [2016-03-29 03:19:34,055][INFO ][http                     ] [node-1] publish_address {自己的ip:9200}, bound_addresses {自己的ip:9200}
Mar 29 03:19:34 localhost elasticsearch: [2016-03-29 03:19:34,055][INFO ][node                     ] [node-1] started

$ curl -XGET 'http://自己的ip:9200/_cluster/health'

{"cluster_name":"verybuy-search","status":"green","timed_out":false,"number_of_nodes":2,"number_of_data_nodes":2,"active_primary_shards":0,"active_shards":0,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":100.0}

arrow
arrow

    yo 發表在 痞客邦 留言(0) 人氣()