ELK栈要安装以下开源组件:
- Elasticsearch
- Kibana
- Beats
- Logstash (可选)
Logstash是可选的。
安装Elasticsearch
Elasticsearch是一个近实时的全文搜索引擎,它有多种用途,例如作为日志系统。
要下载安装Elasticsearch,打开命令行终端,执行以下命令(deb用于Debian/Ubuntu, rpm用于Redhat/Centos/Fedora, mac用于OS X, linux用于linux, win用于Windows):
deb:
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.0-amd64.deb
sudo dpkg -i elasticsearch-7.1.0-amd64.deb
sudo /etc/init.d/elasticsearch start
rpm:
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.0-x86_64.rpm
sudo rpm -i elasticsearch-7.1.0-x86_64.rpm
sudo service elasticsearch start
mac:
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.0-darwin-x86_64.tar.gz
tar -xzvf elasticsearch-7.1.0-darwin-x86_64.tar.gz
cd elasticsearch-7.1.0
./bin/elasticsearch
linux:
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.0-linux-x86_64.tar.gz
tar -xzvf elasticsearch-7.1.0-linux-x86_64.tar.gz
cd elasticsearch-7.1.0
./bin/elasticsearch
win:
-
从Elasticsearch下载页面下载Elasticsearch 7.1.0 Windows zip文件。
-
将zip文件的内容解压到一个目录,例如:C:Program Files。
-
以管理员身份打开命令行窗口,切换到解压目录,例如:
cd C:Program Fileselasticsearch-7.1.0
-
开始Elasticsearch:
binelasticsearch.bat
确认Elasticsearch启动
要确认Elasticsearch服务是否启动,可以访问端口9200。
curl http://127.0.0.1:9200
在Windows上,如果没有安装cURL,可以用浏览器打开上面的网址。
如果一切正常,可以看到如下响应:
{
"name" : "qikegu",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "qZk2EjpQRDiYYyhccomWyw",
"version" : {
"number" : "7.1.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "606a173",
"build_date" : "2019-05-16T00:43:15.323135Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}