Elasticsearch Kibana (Beats Logstash) X-Pack Angular - hello world

Elasticsearch Kibana Beats Logstash X-Pack - hello world
es参考文档
Elasticsearch权威指南(中文版):https://es.xiaoleilu.com/110_Multi_Field_Search/50_Cross_field.html
https://www.elastic.co/guide/cn/elasticsearch/guide/current/_finding_exact_values.html



首先es系列虽然是开源的,但是有些组件并不是免费的,相应的价格请参照如下:
https://www.elastic.co/subscriptions
另外es也提供云端的服务,价格参照如下:
Elastic Cloud Standard Pricing Calculator:https://www.elastic.co/cloud/as-a-service/pricing

本文旨在搭建一个初始版本的elastic search栈,包括Elasticsearch Kibana (Beats,可能暂时不会包括) Logstash(可能暂时不搭建,因为暂时采用从mongoDB用mongo-connector自动同步数据) X-Pack, Angular4

Angular4+es例子工程参考:

https://github.com/junglestory/elasticsearch-angular

https://github.com/junglestory/elasticsearch-sample-books

(注,ES官网安装es,xpack等提供msi安装版的安装文件,安装过程应该相对简单些,但是因后续生产环境不是windows,是类linux,所以此处采用类linux方式)

开始参考资料,官网地址及资料:https://www.elastic.co/cn/start?elektra=home&storm=banner


1,Download Elasticsearch and install

下载zip包,找个安装目录解压完即安装完毕:https://www.elastic.co/cn/downloads/elasticsearch

这篇文章讲解操作es的简单的基本命令,比如idex增删改查,filter,聚合查询等
Elasticsearch基础教程:http://blog.csdn.net/cnweike/article/details/33736429
《注:本文当执行curl -XPUT 'localhost:9200/customer?pretty'在powershell时报错,请参考另一篇文章《Powershell原生支持的cURL - Invoke-WebRequest 及与 cURL的使用区别》,改成相应的Invoke-WebRequest命令执行即可》,或者在Chrome下扩展插件,Postman Rest是个不错的选择


2,Download Kibana and install

Installing Kibanaedit
Kibana is provided in the following package formats: https://www.elastic.co/guide/en/kibana/current/install.html

Install Kibana on Windows
Kibana can be installed on Windows using the .zip package:https://www.elastic.co/guide/en/kibana/current/windows.html

Download Kibana,Installation Steps and Open config/kibana.yml in an editor:https://www.elastic.co/downloads/kibana


3,Install X-Pack

Security, monitoring, and more for Elasticsearch and Kibana

Install X-Pack:https://www.elastic.co/cn/downloads/x-pack#ga-release

Installing X-Pack:https://www.elastic.co/guide/en/x-pack/current/installing-xpack.html#xpack-package-installation

按照官网,执行如下命令提示connection timed out,可能是内网原因要设置proxy,各种设置后也没好用,浪费时间暂时不捣鼓了,看官网资料还可以采用offline方式安装,即下载x-pack安装文件包后本地安装

bin/elasticsearch-plugin install x-pack

bin/kibana-plugin install x-pack


https://www.elastic.co/guide/en/x-pack/current/installing-xpack.html#xpack-package-installation

The X-Pack installation scripts require direct internet access to download and install X-Pack. If your servers don’t have internet access, 
you can manually download the X-Pack zip file and transfer it to a temporary directory on the offline machines. The plugins for Elasticsearch, 
Kibana and Logstash are all included in a single zip file. 
For more information about installing X-Pack on offline machines, see the product-specific X-Pack installation instructions
Installing X-Pack in Elasticsearch
https://www.elastic.co/guide/en/elasticsearch/reference/5.6/installing-xpack-es.html

https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-5.6.2.zip

offline: 

elasticsearch-plugin install file:///path/to/file/x-pack-5.6.0.zip

kibana-plugin install file:///path/to/file/x-pack-5.6.0.zip

C:\newsavedata\kibana-5.6.0-windows-x86\bin>kibana-plugin install file:///newsavedata/x-pack-5.6.0.zip


//安装完x-pack后,浏览器访问es或者代码访问es,可能会出现权限认证的问题,需要配置权限在es,因是hello world,所以采用匿名认证方式:

https://www.elastic.co/guide/en/x-pack/current/security-getting-started.html

https://www.elastic.co/guide/en/x-pack/5.6/anonymous-access.html

# create an anoynomous user to allow interaction without auth
xpack.security.authc:
  anonymous:
    username: _es_anonymous_user 
    roles: superuser
    authz_exception: false


How To: Configure Elasticsearch Security With X-Pack

》https://interset.zendesk.com/hc/en-us/articles/115009873887-How-To-Configure-Elasticsearch-Security-with-X-Pack


4, You’re "go" for launch

#enable automatically create index, elasticsearch增加自动创建索引功能
#action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*

//本来要配置es和x-pack的自动创建索引功能,按照官网或者网上资料配置后,启动es时抛异常,根本起不来,暂时没找到原因,fuck了

org.elasticsearch.bootstrap.StartupException: ElasticsearchException[Failed to load plugin class [org.elasticsearch.xpack.XPackPlugin]]; 
nested: InvocationTargetException; nested: IllegalArgumentException[the [action.auto_create_index] setting value 
[.security,.monitoring*,.watches,.triggered_watches,.watcher-history*] is too restrictive. disable [action.auto_create_index] or set it to [.security,.security-6]];
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.0.jar:5.6.0]


Start Elasticsearch…
bin/elasticsearch
Start Kibana…
bin/kibana
//启动kibana后,提示[license][xpack] Imported license information from Elasticsearch for [data] cluster: mode: trial | status: active | expiry date: 2017-10-27T08:53:04+08:00

因为是收费的组件,试用3个月



5, Open Kibana

Open your browser…
http://localhost:5601
Enter credentials…
Username: elastic Password: changeme

#安装Kibana时出现:
#default index Error: Please specify a default index pattern 
#http://localhost:5601/
#解决的方法:
#将配置文件kibana.yml中下面一项的配置放开(#注释符去掉)即可:
#kibana.index: ".kibana"
kibana.index: ".kibana"
logstash-*

books

//当在Index pattern advanced options下面的文本框里填上之前create过的某一个index,即可出现【create】按钮




本地测试时,在angular里用js访问es,提示跨域访问失败,解决方案如下:https://segmentfault.com/q/1010000002590652

in elasticsearch.yml file

http.cors.allow-origin: "/.*/"
http.cors.enabled: true



你可能感兴趣的:(Elasticsearch)