可以先閱讀elasticsearch on ec2了解這次許多食譜的含意
Chef是一個automate cloud infrastructure framewrok,主要語言是Ruby,適用於AWS、Rackspace等cloud service,尤其當要建立cluster servers的時候可以減少很多重複的工作
環境:
AWS ec2 m1.large
ElasticSearch: 0.19.8
Chef-solo: 跟 Chef-server比起來少了 full text search of our server attributes, executing the same command over SSH on multiple servers at once, or using a web-based GUI
目標,主要是把環境弄好把ElasticSearch安裝起來,有Nginx接應,有Monit照料,有S3當Gateway後援:
- First of all, install a specific version of ElasticSearch on the node
- Create a elasticsearch.yml file with custom configuration
- Create a separate user to run ElasticSearch
- Register a service to start ElasticSearch automatically on server boot
- Increase the open files limit for the elasticsearch user
- Configure the memory limits and other settings for the JVM
- Monitor the ElasticSearch process and cluster health with Monit
- Install the Nginx web server and use it as a proxy for ElasticSearch
- Store user credentials for HTTP authentication with Nginx
步驟:
EC2 Security Group設定開TCP 22, 8080, 9200, 9300, 9500且application連的到
開一台EC2,一個S3 bucket
curl -# -L -k https://gist.github.com/gists/2050769/download | tar xz --strip 1 -C .
node-example.json設定好之後存為node.json,另外把local端參數設定一下
HOST=EC2主機位置
SSH_OPTIONS="-o User=ec2-user -o IdentityFile=ec2要用的key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
腳本和食譜上傳到ec2
scp $SSH_OPTIONS ./bootstrap.sh ./patches.sh ./node.json ./solo.rb $HOST:/tmp
開始安裝,這裡官網的作法是傳指令給遠端
time ssh -t $SSH_OPTIONS $HOST "sudo bash /tmp/bootstrap.sh"
time ssh -t $SSH_OPTIONS $HOST "sudo bash /tmp/patches.sh"
time ssh -t $SSH_OPTIONS $HOST "sudo chef-solo --node-name es-1 -j /tmp/node.json"
#es-1是node名稱,cluster第二台就是es-2,可任意
這樣就裝好了,來檢查一下
ssh -t $SSH_OPTIONS $HOST "curl http://localhost:9200"
ssh -t $SSH_OPTIONS $HOST "sudo service elasticsearch status -v"
#從外部透過nginx
curl http://{NGINX-USERNAME}:{NGINX-PASSWORD}@$HOST:8080
#第二台之後檢查cluster設置是否成功
ssh -t $SSH_OPTIONS $HOST "curl localhost:9200/_cluster/health?pretty"
沒有留言:
張貼留言