Setup single node elasticsearch, logstash and Kibana4 in aws ec2
System Settings
1.To change hostname
Edit host name file
sudo nano /etc/hostname
sudo nano /etc/hostname
Add these contents in hostname
2. To change hosts file
To edit hosts file
sudo nano
/etc/hosts
Add ip address and
hostname in hosts file
10.200.1.X ec2-XX-XX_XX.compute-1.amazonaws.comJava installation
1. To download java
To download 1.7 use this
wget -c
--no-cookies --no-check-certificate --header "Cookie:
gpw_e24=http %3A%2F%2Fwww.oracle.com%2F;
oraclelicense=accept-securebackup-cookie"
"http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz"
–output-document="jdk-7u75-linux-x64.tar.gz"
2. Extract jdk in jvm folder
1. Create folder
jvm in /usr/lib/ path
sudo mkdir jvm
2. Move jdk file
to jvm and extract it
sudo mv
jdk-7u75-linux-x64.tar.gz /usr/lib/jvm
3.Set java home and alternatives
To set java
home
1. Open
/etc/bash.bashrc add these contents in bash.bashrc file
export
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_75
Run bash.bashrc
source
/etc/bash.bashrc
Set java alternatives
sudo
update-alternatives --install "/usr/bin/java" "java"
"/usr/lib/jvm/jdk1.7.0_75 /bin/java" 1
sudo
update-alternatives --install "/usr/bin/javac" "javac"
"/usr/lib/jvm/jdk1.7.0_75/bin/javac" 1
Download & install elasticsearch and logstash
Download Logstash 1.4.2 and elasticsearch 1.3.2 use this link
wget
https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.deb
wget https://download.elasticsearch.org/logstash/logstash/packages/debian/logstash_1.4.2-1-2c0f5a1_all.deb
Download Logstash 1.4.2 and elasticsearch 1.4.4 debian versions use this link
wget https://download.elasticsearch.org/elasticsearch/elasticsearch /elasticsearch-1.4.4.debwget https://download.elasticsearch.org/logstash/logstash/packages/debian/logstash_1.4.2-1-2c0f5a1_all.deb
Install logstash and elasticsearch
sudo dpkg -i
elasticsearch-XX.deb
sudo dpkg -i logstash-1-XX.deb
Install aws plugin
In aws need to
install aws plugin for to run elasticsearch
To download aws
plugin use this link
Install plugin
cd
/usr/share/elasticsearch
For elasticsearch
1.3.2
sudo bin/plugin install elasticsearch/elasticsearch-cloud-aws/2.3.0
sudo bin/plugin install elasticsearch/elasticsearch-cloud-aws/2.3.0
Install marvel
Marvel is used for
monitor cluster
cd
/usr/share/elasticsearch
sudo bin/plugin -i
elasticsearch/marvel/latest
Install Head
sudo bin/plugin -i
--install mobz/elasticsearch-head
Note :- plugin
install not working then manually download plugin zip and
bin/plugin --url
file:///path/to/plugin --install plugin-name
Proxy setting
bin/plugin -DproxyHost=host_name -DproxyPort=port_number --install mobz/elasticsearch-head
bin/plugin -DproxyHost=10.200.1.3 -DproxyPort=3128 --install mobz/elasticsearch-head
Install Kibana 4
To download kibana
4
Extract and Rename
kibana
tar -xvzf
kibana-4.0.1-linux-x64.tar.gz
sudo mv
kibana-4.0.1-linux-x64
kibna-4
To run kibna
Run bin/kibana on
unix, or bin\kibana.bat on Windows.
Visit
http://localhost:5601
To change settings in elasticsearch
To edit elasticsearch.yml file
sudo nano /etc/elasticserch/elasticsearch.yml
sudo nano /etc/elasticserch/elasticsearch.yml
Add these
contents in elasticsearch.yml file to run elasticsearch in aws
cluster.name:
elasticsearch_production
cloud.aws.access_key:
XXXXXXXXXXXXXXXXXXXXXXX
cloud.aws.secret_key:
XXXXXXXXXXXXXXXXXXXXXXXX
plugin.mandatory:
cloud-aws
discovery.type:
"ec2"
discovery.ec2.groups:
"XXXXXXXX"
discovery.ec2.cloud.aws.region:
"XXXXXXX"
discovery.zen.ping.multicast.enabled:
false
#discovery.zen.ping.unicast.hosts:
["XXXXXXXX.compute-1.amazonaws.com"]
Then restart
elasticsearch
To verify elasticsearch is working
Check cluster status
curl -XGET
http://localhost:9200/_cluster/health?pretty=true
Check index names
sudo curl
-XGET 'localhost:9200/_cat/indices?v'
To create delete all indexes
sudo curl
-XDELETE 'localhost:9200/*'
Use marvel to check status
http://5XXXX-XX1:9200/_plugin/marvel/
To start elasticsearch as a service
sudo update-rc.d elasticsearch defaults 95 10
sudo /etc/init.d/elasticsearch start
Bulk api
To upload json data directly into elasticsearch curl -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json
curl 'localhost:9200/_cat/indices?v'
Directory structure of elasticsearch and logstash
Elasticsearch- Binaries and stuff:
/usr/share/elasticsearch
- Plugin manager:
/usr/share/elasticsearch/bin/plugin
- Configuration:
/etc/elasticsearch/elasticsearch.yml
- Data:
/var/lib/elasticsearch/<cluster-name>
Logstash
- Binaries and stuff:
/opt/logstash
- Configuration:
/etc/logstash/conf.d
- Logs:
/var/log/logstash
Comments
Post a Comment