mac elk5.0.1- Elasticsearch、Kibana、x-pack安装、数据库同步
ELK 包括以下几个产品 Elasticsearch 、Logstash、Kibana、三个产品组合简称,网官介绍:
Elasticsearch也使用Java开发并使用Lucene作为其核心来实现所有索引和搜索的功能,但是它的目的是通过简单的RESTful API来隐藏Lucene的复杂性,从而让全文搜索变得简单。
基于restful api,其它任何语言都可以支持。这是非java开发人员最大的好处,都可以用到Lucene。
一、安装Elasticsearch
官网下载最新版本,目前是5.0.1,下载产品几个版本保持一致,要不然会启动不了。
解压包,放到/usr/local, 或者其它目录都可以。
elasticsearch-5.0.1/bin/elasticsearch
运行
curl -X GET http://localhost:9200/
返回类似数据就成功
{
"name" : "qvFM1BQ",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "BWJZsv4RQtKkCTAr4tDABQ",
"version" : {
"number" : "5.0.1",
"build_hash" : "080bb47",
"build_date" : "2016-11-11T22:08:49.812Z",
"build_snapshot" : false,
"lucene_version" : "6.2.1"
},
"tagline" : "You Know, for Search"
}
二、安装Kibana可视化管理(Elasticsearch,类似于phpmyadmin管理mysql)
(官网下载 解压到本地目录,)
(kibana-5.0.1/bin/kibana)
(运行成功)
MacBook-Pro:local lifei$ kibana-5.0.1/bin/kibana
log [01:43:34.722] [info][status][plugin:kibana@5.0.1] Status changed from uninitialized to green - Ready
log [01:43:34.781] [info][status][plugin:elasticsearch@5.0.1] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [01:43:34.805] [info][status][plugin:console@5.0.1] Status changed from uninitialized to green - Ready
log [01:43:35.140] [info][status][plugin:timelion@5.0.1] Status changed from uninitialized to green - Ready
log [01:43:35.147] [info][listening] Server running at http://localhost:5601
log [01:43:35.149] [info][status][ui settings] Status changed from uninitialized to yellow - Elasticsearch plugin is yellow
log [01:43:35.168] [info][status][plugin:elasticsearch@5.0.1] Status changed from yellow to green - Kibana index ready
log [01:43:35.169] [info][status][ui settings] Status changed from yellow to green - Ready
浏览器访问:http://localhost:5601/
三、安装数据库同步工具:
https://github.com/siddontang/go-mysql-elasticsearch
目前除了go-mysql-elasticsearch插件,还有一个插件 https://github.com/jprante/elasticsearch-jdbc 但不支持最新5.0版本。
使用go-mysql-elasticsearch 发现效率并不高,还待再测试。
四、ik中文分词
https://github.com/medcl/elasticsearch-analysis-ik
es自带的分词对中文支持不够好。
安装ik分词需要重新编译java包,所以 mvn package, 会非常耗时。推荐加一个阿里的源。
MacBook-Pro:~ lifei$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.1", arch: "x86_64", family: "mac"
查看下maven安装位置,然后更改下maven源
vi /usr/local/Cellar/maven/3.3.9/libexec/conf/settings.xml
添加:http://maven.aliyun.com/nexus/content/groups/public/
五、安装x-pack
最好先把包下载在服务器,然后通过命令安装
bin/elasticsearch-plugin install file:///path/to/file/x-pack-5.0.1.zip
bin/kibana-plugin install file:///path/to/file/x-pack-5.0.1.zip
安装好后,通过kibana访问,默认账号/密码:elastic/changeme
x-pack提供一个月的实用期,可以去申请一个basic license,下载license,
在es服务器上面执行:
1提交license
curl -XPUT -u elastic 'http://127.0.0.1:9200/_xpack/license' -d @license.json
2、第二次同意
curl -XPUT -u elastic 'http://127.0.0.1:9200/_xpack/license?acknowledge=true' -d @license.json
关于es更多深入理解:https://segmentfault.com/a/1190000003502849