搭建环境基于Ubuntu1604
目录
JDK
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
ElasticSearch
# cd /usr/local
sudo wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz
sudo tar xf elasticsearch-5.4.0.tar.gz
sudo chown -R saas:saas elasticsearch-5.4.0
# cd /usr/local/elasticsearch-5.4.0
./bin/elasticsearch -d
- 测试
curl localhost:9200
{
"name" : "QsJhL7g",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "4_iMer-PSKiZ_d5Xjew5Lw",
"version" : {
"number" : "5.4.0",
"build_hash" : "780f8c4",
"build_date" : "2017-04-28T17:43:27.229Z",
"build_snapshot" : false,
"lucene_version" : "6.5.0"
},
"tagline" : "You Know, for Search"
}
Logstash
# cd /usr/local
sudo wget https://artifacts.elastic.co/downloads/logstash/logstash-5.4.0.tar.gz
sudo tar xf logstash-5.4.0.tar.gz
sudo chown -R saas:saas logstash-5.4.0
# cd /usr/local/logstash-5.4.0
vim bin/logstash.conf
input {
file {
path => ["/var/log/*.log"]
}
}
output {
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "logstash__log"
}
}
# cd /usr/local/logstash-5.4.0/bin
./logstash -f logstash.conf &
- 测试
curl localhost:9600 | json
{
"host": "saas-VirtualBox",
"version": "5.4.0",
"http_address": "127.0.0.1:9600",
"id": "a34d6617-1e55-4665-9343-fed5b7c1854f",
"name": "saas-VirtualBox",
"build_date": "2017-04-28T18:14:40Z",
"build_sha": "0037bc8cf2e9ff169bf5a08b1946c62dbeb92f9b",
"build_snapshot": false
}
这里使用nodejs的json工具格式化数据: npm i -g json
Kibana
# cd /usr/local
sudo wget https://artifacts.elastic.co/downloads/kibana/kibana-5.4.0-linux-x86_64.tar.gz
sudo tar xf kibana-5.4.0-linux-x86_64.tar.gz
sudo chown -R saas:saas kibana-5.4.0-linux-x86_64
# cd /usr/local/kibana-5.4.0-linux-x86_64
vim config/kibana.yml
server.host: "192.168.56.222"
server.name: "test-kibana"
# cd /usr/local/kibana-5.4.0-linux-x86_64/bin
./kibana &
浏览器打开: http://192.168.56.222:5601
如果出现错误: No default index pattern. You must select or create one to continue. 可以设置index为*